From 9de1a61e83403208c1265764895a9fde0bc9498e Mon Sep 17 00:00:00 2001 From: Jon Leighton Date: Wed, 11 Jul 2012 22:58:17 +0100 Subject: [PATCH] no need for scrollIntoView param --- lib/capybara/poltergeist/client/compiled/node.js | 12 ++++-------- lib/capybara/poltergeist/client/node.coffee | 11 ++++++----- 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/lib/capybara/poltergeist/client/compiled/node.js b/lib/capybara/poltergeist/client/compiled/node.js index 41541508..15750fe5 100644 --- a/lib/capybara/poltergeist/client/compiled/node.js +++ b/lib/capybara/poltergeist/client/compiled/node.js @@ -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) { @@ -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') { @@ -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); diff --git a/lib/capybara/poltergeist/client/node.coffee b/lib/capybara/poltergeist/client/node.coffee index eb7fafcd..7f0fcd76 100644 --- a/lib/capybara/poltergeist/client/node.coffee +++ b/lib/capybara/poltergeist/client/node.coffee @@ -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() @@ -31,6 +28,8 @@ class Poltergeist.Node } click: -> + this.scrollIntoView() + pos = this.clickPosition() test = this.clickTest(pos.x, pos.y) @@ -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)