Sha256: c0462d98b2d0bb1088e596bf78c41d23462daa9be8e0bfff54ad4863999f1e70
Contents?: true
Size: 1.24 KB
Versions: 2
Compression:
Stored size: 1.24 KB
Contents
module Browser; class Event class DeviceMotion < Event def self.supported? Browser.supports? 'Event.DeviceMotion' end Acceleration = Struct.new(:x, :y, :z) class Definition < Definition def acceleration=(value) `#@native.acceleration = #{value.to_n}` end def acceleration_with_gravity=(value) `#@native.accelerationIncludingGravity = #{value.to_n}` end def rotation=(value) `#@native.rotationRate = #{value}` end def interval=(value) `#@native.interval = #{value}` end end if Browser.supports? 'Event.constructor' def self.construct(name, desc) `new DeviceMotionEvent(#{name}, #{desc})` end elsif Browser.supports? 'Event.create' def self.construct(name, desc) %x{ var event = document.createEvent("DeviceMotionEvent"); event.initDeviceMotionEvent(name, desc.bubbles, desc.cancelable, desc.acceleration, desc.accelerationIncludingGravity, desc.rotationRate, desc.interval); return event; } end end if supported? alias_native :acceleration alias_native :acceleration_with_gravity, :accelerationIncludingGravity alias_native :rotation, :rotationRate alias_native :interval end end; end
Version data entries
2 entries across 2 versions & 2 rubygems
Version | Path |
---|---|
diamonds-0.1.5 | lib/diamonds/opal/browser/event/device_motion.rb |
opal-browser-0.2.0 | opal/browser/event/device_motion.rb |