Method: Element#mouse_event

Defined in:
lib/red_query/element.rb

#mouse_event(block) ⇒ Object



163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
# File 'lib/red_query/element.rb', line 163

def mouse_event(block)
  preventer = Proc.new { `#{native_event}.preventDefault()` }
  
  Proc.new { |native_event|
    # `console.log(#{native_event})`
    block.call({
      :client_x => `#{native_event}.clientX`,
      :client_y => `#{native_event}.clientY`,
      :page_x => `#{native_event}.pageX`,
      :page_y => `#{native_event}.pageY`,
      :screen_x => `#{native_event}.screenX`,
      :screen_y => `#{native_event}.screenY`,
      :prevent => preventer,
    })
  }
end