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: https://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.



1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
# File 'lib/dommy/event.rb', line 1141

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.



1126
1127
1128
# File 'lib/dommy/event.rb', line 1126

def client_x
  @client_x
end

#client_yObject (readonly)

Returns the value of attribute client_y.



1126
1127
1128
# File 'lib/dommy/event.rb', line 1126

def client_y
  @client_y
end

#forceObject (readonly)

Returns the value of attribute force.



1126
1127
1128
# File 'lib/dommy/event.rb', line 1126

def force
  @force
end

#identifierObject (readonly)

Returns the value of attribute identifier.



1126
1127
1128
# File 'lib/dommy/event.rb', line 1126

def identifier
  @identifier
end

#page_xObject (readonly)

Returns the value of attribute page_x.



1126
1127
1128
# File 'lib/dommy/event.rb', line 1126

def page_x
  @page_x
end

#page_yObject (readonly)

Returns the value of attribute page_y.



1126
1127
1128
# File 'lib/dommy/event.rb', line 1126

def page_y
  @page_y
end

#radius_xObject (readonly)

Returns the value of attribute radius_x.



1126
1127
1128
# File 'lib/dommy/event.rb', line 1126

def radius_x
  @radius_x
end

#radius_yObject (readonly)

Returns the value of attribute radius_y.



1126
1127
1128
# File 'lib/dommy/event.rb', line 1126

def radius_y
  @radius_y
end

#rotation_angleObject (readonly)

Returns the value of attribute rotation_angle.



1126
1127
1128
# File 'lib/dommy/event.rb', line 1126

def rotation_angle
  @rotation_angle
end

#screen_xObject (readonly)

Returns the value of attribute screen_x.



1126
1127
1128
# File 'lib/dommy/event.rb', line 1126

def screen_x
  @screen_x
end

#screen_yObject (readonly)

Returns the value of attribute screen_y.



1126
1127
1128
# File 'lib/dommy/event.rb', line 1126

def screen_y
  @screen_y
end

#targetObject (readonly)

Returns the value of attribute target.



1126
1127
1128
# File 'lib/dommy/event.rb', line 1126

def target
  @target
end

Instance Method Details

#__js_get__(key) ⇒ Object



1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
# File 'lib/dommy/event.rb', line 1156

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
  else
    Bridge::ABSENT
  end
end