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: https://w3c.github.io/touch-events/#touchevent-interface

Constant Summary

Constants inherited from Event

Event::AT_TARGET, Event::BUBBLING_PHASE, Event::CAPTURING_PHASE, Event::NONE

Instance Attribute Summary collapse

Attributes inherited from Event

#type

Instance Method Summary collapse

Methods inherited from Event

#__internal_clear_propagation_flags__, #__internal_mark_trusted__, #__internal_prepare_for_dispatch__, #__internal_record_path__, #__internal_run_passive__, #__internal_set_current_target__, #__internal_set_dispatch_flag__, #__internal_set_event_phase__, #__js_call__, #__js_set__, #bubbles?, #default_prevented?, #immediate_propagation_stopped?, #init_event, #propagation_stopped?

Methods included from Bridge::Methods

included

Constructor Details

#initialize(type, init = nil) ⇒ TouchEvent

Returns a new instance of TouchEvent.



1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
# File 'lib/dommy/event.rb', line 1237

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.



1248
1249
1250
# File 'lib/dommy/event.rb', line 1248

def changed_touches
  @changed_touches
end

#target_touchesObject (readonly)

Returns the value of attribute target_touches.



1248
1249
1250
# File 'lib/dommy/event.rb', line 1248

def target_touches
  @target_touches
end

#touchesObject (readonly)

Returns the value of attribute touches.



1248
1249
1250
# File 'lib/dommy/event.rb', line 1248

def touches
  @touches
end

Instance Method Details

#__js_get__(key) ⇒ Object



1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
# File 'lib/dommy/event.rb', line 1250

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