Skip to content

Commit

Permalink
borrowed basic implementation of drag_to from capybara-envjs
Browse files Browse the repository at this point in the history
  • Loading branch information
boblail authored and vinibaggio committed Jan 20, 2011
1 parent 315f8a0 commit 484a1ac
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions lib/capybara/driver/zombie_driver.rb
Expand Up @@ -84,6 +84,19 @@ def click
browser_wait :fire, "click".inspect, native_ref
end

def drag_to(element)
# https://github.com/smparkes/capybara-envjs/blob/master/lib/capybara/driver/envjs_driver.rb
# distance stuff is arbitrary at this point, to make jquery.ui happy ...
browser_wait :fire, "mousedown".inspect, self.native_ref, encode({:button => 1, :pageX => 0, :pageY => 0})
browser_wait :fire, "mousemove".inspect, element.native_ref, encode({:button => 1, :pageX => 1, :pageY => 1})
browser_wait :fire, "mousemove".inspect, element.native_ref, encode({:button => 1, :pageX => 0, :pageY => 0})
browser_wait :fire, "mouseup".inspect, element.native_ref, encode({:button => 1, :pageX => 0, :pageY => 0})
end

def native_ref
"pointers[#{@native}]"
end

private

def select_node
Expand All @@ -94,9 +107,6 @@ def native_json(call)
socket_json "#{native_ref}#{call}"
end

def native_ref
"pointers[#{@native}]"
end
end

class Headers
Expand Down

0 comments on commit 484a1ac

Please sign in to comment.