Sha256: 3c595482cf5a55e1a97ee95d6aabf18d0be3c26878c8a3791c0a923ce607d307

Contents?: true

Size: 977 Bytes

Versions: 1

Compression:

Stored size: 977 Bytes

Contents

module Browser; module DOM; class Event

class Touch < Event
  def self.supported?
    not $$[:TouchEvent].nil?
  end

  class Definition < Definition
    def alt!
      `#@native.altKey = true`
    end

    def ctrl!
      `#@native.ctrlKey = true`
    end

    def meta!
      `#@native.metaKey = true`
    end

    def shift!
      `#@native.shiftKey = true`
    end
  end

  def self.create(name, &block)
    new(`new TouchEvent(#{name}, #{Definition.new(&block)})`)
  end

  def alt?
    `#@native.altKey`
  end

  def ctrl?
    `#@native.ctrlKey`
  end

  def meta?
    `#@native.metaKey`
  end

  def shift?
    `#@native.shiftKey`
  end

  # TODO: implement touches and targetTouches

  def cancel?
    name.downcase == 'touchcancel'
  end

  def end?
    name.downcase == 'touchend'
  end

  def leave?
    name.downcase == 'touchleave'
  end

  def move?
    name.downcase == 'touchmove'
  end

  def start?
    name.downcase == 'touchstart'
  end
end

end; end; end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
opal-browser-0.1.0.beta1 opal/browser/dom/event/touch.rb