aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorgdh19952018-08-27 22:06:00 +0800
committergdh19952018-08-27 22:06:00 +0800
commit117dd20cc60030d79bc79d793ff3de4ea5514ad1 (patch)
tree1c8fc48a8827a9b878b0ef4d25fdc8ed06f435eb
parent3267b00cf98082213d754bb817e9d56e47998dfb (diff)
downloadvimium-117dd20cc60030d79bc79d793ff3de4ea5514ad1.tar.bz2
use Element::scrollBy if it exists
-rw-r--r--content_scripts/scroller.coffee7
1 files changed, 6 insertions, 1 deletions
diff --git a/content_scripts/scroller.coffee b/content_scripts/scroller.coffee
index 7202c682..2ce4d13b 100644
--- a/content_scripts/scroller.coffee
+++ b/content_scripts/scroller.coffee
@@ -56,7 +56,12 @@ getDimension = (el, direction, amount) ->
performScroll = (element, direction, amount) ->
axisName = scrollProperties[direction].axisName
before = element[axisName]
- element[axisName] += amount
+ if typeof element.scrollBy is "function"
+ scrollArg = behavior: "instant"
+ scrollArg[if axisName is "x" then "left" else "top"] = amount
+ element.scrollBy scrollArg
+ else
+ element[axisName] += amount
element[axisName] != before
# Test whether `element` should be scrolled. E.g. hidden elements should not be scrolled.