Class: Dommy::Touch

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

Overview

‘Touch` — a single touch point on a touch-capable surface. Constructed by tests; tied to a target element and coordinate set.

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(init = {}) ⇒ Touch

Returns a new instance of Touch.



564
565
566
567
568
569
570
571
572
573
574
575
576
577
# File 'lib/dommy/event.rb', line 564

def initialize(init = {})
  @identifier = (init["identifier"] || init[:identifier] || 0).to_i
  @target = init["target"] || init[:target]
  @client_x = (init["clientX"] || init[:clientX] || 0).to_f
  @client_y = (init["clientY"] || init[:clientY] || 0).to_f
  @page_x = (init["pageX"] || init[:pageX] || @client_x).to_f
  @page_y = (init["pageY"] || init[:pageY] || @client_y).to_f
  @screen_x = (init["screenX"] || init[:screenX] || @client_x).to_f
  @screen_y = (init["screenY"] || init[:screenY] || @client_y).to_f
  @radius_x = (init["radiusX"] || init[:radiusX] || 0).to_f
  @radius_y = (init["radiusY"] || init[:radiusY] || 0).to_f
  @rotation_angle = (init["rotationAngle"] || init[:rotationAngle] || 0).to_f
  @force = (init["force"] || init[:force] || 0).to_f
end

Instance Attribute Details

#client_xObject (readonly)

Returns the value of attribute client_x.



549
550
551
# File 'lib/dommy/event.rb', line 549

def client_x
  @client_x
end

#client_yObject (readonly)

Returns the value of attribute client_y.



549
550
551
# File 'lib/dommy/event.rb', line 549

def client_y
  @client_y
end

#forceObject (readonly)

Returns the value of attribute force.



549
550
551
# File 'lib/dommy/event.rb', line 549

def force
  @force
end

#identifierObject (readonly)

Returns the value of attribute identifier.



549
550
551
# File 'lib/dommy/event.rb', line 549

def identifier
  @identifier
end

#page_xObject (readonly)

Returns the value of attribute page_x.



549
550
551
# File 'lib/dommy/event.rb', line 549

def page_x
  @page_x
end

#page_yObject (readonly)

Returns the value of attribute page_y.



549
550
551
# File 'lib/dommy/event.rb', line 549

def page_y
  @page_y
end

#radius_xObject (readonly)

Returns the value of attribute radius_x.



549
550
551
# File 'lib/dommy/event.rb', line 549

def radius_x
  @radius_x
end

#radius_yObject (readonly)

Returns the value of attribute radius_y.



549
550
551
# File 'lib/dommy/event.rb', line 549

def radius_y
  @radius_y
end

#rotation_angleObject (readonly)

Returns the value of attribute rotation_angle.



549
550
551
# File 'lib/dommy/event.rb', line 549

def rotation_angle
  @rotation_angle
end

#screen_xObject (readonly)

Returns the value of attribute screen_x.



549
550
551
# File 'lib/dommy/event.rb', line 549

def screen_x
  @screen_x
end

#screen_yObject (readonly)

Returns the value of attribute screen_y.



549
550
551
# File 'lib/dommy/event.rb', line 549

def screen_y
  @screen_y
end

#targetObject (readonly)

Returns the value of attribute target.



549
550
551
# File 'lib/dommy/event.rb', line 549

def target
  @target
end

Instance Method Details

#__js_get__(key) ⇒ Object



579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
# File 'lib/dommy/event.rb', line 579

def __js_get__(key)
  case key
  when "identifier"
    @identifier
  when "target"
    @target
  when "clientX"
    @client_x
  when "clientY"
    @client_y
  when "pageX"
    @page_x
  when "pageY"
    @page_y
  when "screenX"
    @screen_x
  when "screenY"
    @screen_y
  when "radiusX"
    @radius_x
  when "radiusY"
    @radius_y
  when "rotationAngle"
    @rotation_angle
  when "force"
    @force
  end
end