Sha256: 5104ac3b96f42f9a51e601fb183793b5efb941eaa3ed540da21042df07aed8d6

Contents?: true

Size: 943 Bytes

Versions: 2

Compression:

Stored size: 943 Bytes

Contents

# backtick_javascript: true

module Browser; class Event

class DeviceOrientation < Event
  handles 'deviceorientation'

  def self.supported?
    Browser.supports? 'Event.DeviceOrientation'
  end

  class Definition < Definition
    alias_native :absolute=
    alias_native :alpha=
    alias_native :beta=
    alias_native :gamma=
  end

  if Browser.supports? 'Event.constructor'
    def self.construct(name, desc)
      `new DeviceOrientationEvent(#{name}, #{desc})`
    end
  elsif Browser.supports? 'Event.create'
    def self.construct(name, desc)
      %x{
        var event = document.createEvent("DeviceOrientationEvent");
            event.initDeviceOrientationEvent(name, desc.bubbles, desc.cancelable,
              desc.alpha, desc.beta, desc.gamma, desc.absolute);

        return event;
      }
    end
  end if supported?

  alias_native :absolute
  alias_native :alpha
  alias_native :beta
  alias_native :gamma
end

end; end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
opal-browser-0.3.5 opal/browser/event/device_orientation.rb
opal-browser-0.3.4 opal/browser/event/device_orientation.rb