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.



733
734
735
736
737
738
739
740
741
742
743
744
745
746
# File 'lib/dommy/event.rb', line 733

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.



718
719
720
# File 'lib/dommy/event.rb', line 718

def client_x
  @client_x
end

#client_yObject (readonly)

Returns the value of attribute client_y.



718
719
720
# File 'lib/dommy/event.rb', line 718

def client_y
  @client_y
end

#forceObject (readonly)

Returns the value of attribute force.



718
719
720
# File 'lib/dommy/event.rb', line 718

def force
  @force
end

#identifierObject (readonly)

Returns the value of attribute identifier.



718
719
720
# File 'lib/dommy/event.rb', line 718

def identifier
  @identifier
end

#page_xObject (readonly)

Returns the value of attribute page_x.



718
719
720
# File 'lib/dommy/event.rb', line 718

def page_x
  @page_x
end

#page_yObject (readonly)

Returns the value of attribute page_y.



718
719
720
# File 'lib/dommy/event.rb', line 718

def page_y
  @page_y
end

#radius_xObject (readonly)

Returns the value of attribute radius_x.



718
719
720
# File 'lib/dommy/event.rb', line 718

def radius_x
  @radius_x
end

#radius_yObject (readonly)

Returns the value of attribute radius_y.



718
719
720
# File 'lib/dommy/event.rb', line 718

def radius_y
  @radius_y
end

#rotation_angleObject (readonly)

Returns the value of attribute rotation_angle.



718
719
720
# File 'lib/dommy/event.rb', line 718

def rotation_angle
  @rotation_angle
end

#screen_xObject (readonly)

Returns the value of attribute screen_x.



718
719
720
# File 'lib/dommy/event.rb', line 718

def screen_x
  @screen_x
end

#screen_yObject (readonly)

Returns the value of attribute screen_y.



718
719
720
# File 'lib/dommy/event.rb', line 718

def screen_y
  @screen_y
end

#targetObject (readonly)

Returns the value of attribute target.



718
719
720
# File 'lib/dommy/event.rb', line 718

def target
  @target
end

Instance Method Details

#__js_get__(key) ⇒ Object



748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
# File 'lib/dommy/event.rb', line 748

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