Skip to content

Instantly share code, notes, and snippets.

@nowk
Created September 27, 2012 20:45
Show Gist options
  • Save nowk/3796369 to your computer and use it in GitHub Desktop.
Save nowk/3796369 to your computer and use it in GitHub Desktop.
A basic wrapper for drag and drop simulation
class DragAndDropSimulator
def initialize(page, drag)
@page = page
@drag = drag
end
def up(num)
drag_and_drop(num)
end
def down(num)
drag_and_drop(num*-1)
end
private
def drag_and_drop(num)
@page.execute_script %{
$.getScript("https://raw.github.com/nowk/jquery.simulate.drag-sortable.js/master/jquery.simulate.drag-sortable.js", function() {
$("#{@drag}").simulateDragSortable({move: #{num}, handle: '.handle'});
});
}
end
end
def drag_and_drop(selector)
DragAndDropSimulator.new(page, selector)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment