Class: Dommy::TouchEvent

Inherits:
Event
  • Object
show all
Defined in:
lib/dommy/event.rb

Overview

‘TouchEvent` — fires for touchstart / touchmove / touchend / touchcancel. Carries three TouchLists plus modifier keys.

Spec: w3c.github.io/touch-events/#touchevent-interface

Constant Summary

Constants inherited from Event

Event::JS_METHOD_NAMES

Instance Attribute Summary collapse

Attributes inherited from Event

#type

Instance Method Summary collapse

Methods inherited from Event

#__internal_prepare_for_dispatch__, #__internal_record_path__, #__internal_set_current_target__, #__js_call__, #__js_method_names__, #__js_set__, #bubbles?, #default_prevented?, #immediate_propagation_stopped?, #init_event, #propagation_stopped?

Constructor Details

#initialize(type, init = nil) ⇒ TouchEvent

Returns a new instance of TouchEvent.



680
681
682
683
684
685
686
687
688
689
# File 'lib/dommy/event.rb', line 680

def initialize(type, init = nil)
  super
  @touches = TouchList.new(Array(read_init(init, "touches") || []))
  @target_touches = TouchList.new(Array(read_init(init, "targetTouches") || []))
  @changed_touches = TouchList.new(Array(read_init(init, "changedTouches") || []))
  @alt_key = !!read_init(init, "altKey")
  @ctrl_key = !!read_init(init, "ctrlKey")
  @shift_key = !!read_init(init, "shiftKey")
  @meta_key = !!read_init(init, "metaKey")
end

Instance Attribute Details

#changed_touchesObject (readonly)

Returns the value of attribute changed_touches.



691
692
693
# File 'lib/dommy/event.rb', line 691

def changed_touches
  @changed_touches
end

#target_touchesObject (readonly)

Returns the value of attribute target_touches.



691
692
693
# File 'lib/dommy/event.rb', line 691

def target_touches
  @target_touches
end

#touchesObject (readonly)

Returns the value of attribute touches.



691
692
693
# File 'lib/dommy/event.rb', line 691

def touches
  @touches
end

Instance Method Details

#__js_get__(key) ⇒ Object



693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
# File 'lib/dommy/event.rb', line 693

def __js_get__(key)
  case key
  when "touches"
    @touches
  when "targetTouches"
    @target_touches
  when "changedTouches"
    @changed_touches
  when "altKey"
    @alt_key
  when "ctrlKey"
    @ctrl_key
  when "shiftKey"
    @shift_key
  when "metaKey"
    @meta_key
  else
    super
  end
end