Skip to content

Commit

Permalink
no need for scrollIntoView param
Browse files Browse the repository at this point in the history
  • Loading branch information
jonleighton committed Jul 11, 2012
1 parent cb5ecaf commit 9de1a61
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 13 deletions.
12 changes: 4 additions & 8 deletions lib/capybara/poltergeist/client/compiled/node.js
Expand Up @@ -28,14 +28,8 @@ Poltergeist.Node = (function() {
_fn(name);
}

Node.prototype.clickPosition = function(scrollIntoView) {
Node.prototype.clickPosition = function() {
var middle, pos, viewport;
if (scrollIntoView == null) {
scrollIntoView = true;
}
if (scrollIntoView) {
this.scrollIntoView();
}
viewport = this.page.viewportSize();
pos = this.position();
middle = function(start, end, size) {
Expand All @@ -49,6 +43,7 @@ Poltergeist.Node = (function() {

Node.prototype.click = function() {
var pos, test;
this.scrollIntoView();
pos = this.clickPosition();
test = this.clickTest(pos.x, pos.y);
if (test.status === 'success') {
Expand All @@ -60,8 +55,9 @@ Poltergeist.Node = (function() {

Node.prototype.dragTo = function(other) {
var otherPosition, position;
this.scrollIntoView();
position = this.clickPosition();
otherPosition = other.clickPosition(false);
otherPosition = other.clickPosition();
this.page.sendEvent('mousedown', position.x, position.y);
this.page.sendEvent('mousemove', otherPosition.x, otherPosition.y);
return this.page.sendEvent('mouseup', otherPosition.x, otherPosition.y);
Expand Down
11 changes: 6 additions & 5 deletions lib/capybara/poltergeist/client/node.coffee
Expand Up @@ -15,10 +15,7 @@ class Poltergeist.Node
this.prototype[name] = (args...) ->
@page.nodeCall(@id, name, args)

clickPosition: (scrollIntoView = true) ->
if scrollIntoView
this.scrollIntoView()

clickPosition: ->
viewport = @page.viewportSize()
pos = this.position()

Expand All @@ -31,6 +28,8 @@ class Poltergeist.Node
}

click: ->
this.scrollIntoView()

pos = this.clickPosition()
test = this.clickTest(pos.x, pos.y)

Expand All @@ -40,8 +39,10 @@ class Poltergeist.Node
throw new Poltergeist.ClickFailed(test.selector, pos)

dragTo: (other) ->
this.scrollIntoView()

position = this.clickPosition()
otherPosition = other.clickPosition(false)
otherPosition = other.clickPosition()

@page.sendEvent('mousedown', position.x, position.y)
@page.sendEvent('mousemove', otherPosition.x, otherPosition.y)
Expand Down

0 comments on commit 9de1a61

Please sign in to comment.