opal/browser/event/drag.rb in opal-browser-0.2.0 vs opal/browser/event/drag.rb in opal-browser-0.3.0
- old
+ new
@@ -1,16 +1,18 @@
module Browser; class Event
-# TODO: handle transfers
class Drag < Event
+ handles 'drag', 'dragend', 'dragenter', 'dragexit', 'dragleave', 'dragover',
+ 'dragstart', 'drop'
+
def self.supported?
Browser.supports? 'Event.Drag'
end
class Definition < Definition
class Client
- include Native
+ include Native::Wrapper
def x=(value)
`#@native.clientX = #{value}`
end
@@ -18,11 +20,11 @@
`#@native.clientY = #{value}`
end
end
class Screen
- include Native
+ include Native::Wrapper
def x=(value)
`#@native.screenX = #{value}`
end
@@ -58,11 +60,11 @@
def related=(elem)
`#@native.relatedTarget = #{Native.convert(elem)}`
end
def transfer=(value)
- `#@native.dataTransfer = #{Native.convert(elem)}`
+ `#@native.dataTransfer = #{Native.convert(value)}`
end
end
if Browser.supports? 'Event.constructor'
def self.construct(name, desc)
@@ -108,12 +110,14 @@
def related
DOM(`#@native.relatedTarget`)
end
+ # Returns a {DataTransfer} related to this event
+ #
# @see https://developer.mozilla.org/en-US/docs/Web/API/DataTransfer
def transfer
- raise NotImplementedError
+ DataTransfer.new(`#@native.dataTransfer`)
end
end
end; end