Skip to content

Commit 117dd20

Browse files
committed
use Element::scrollBy if it exists
1 parent 3267b00 commit 117dd20

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

content_scripts/scroller.coffee

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,12 @@ getDimension = (el, direction, amount) ->
5656
performScroll = (element, direction, amount) ->
5757
axisName = scrollProperties[direction].axisName
5858
before = element[axisName]
59-
element[axisName] += amount
59+
if typeof element.scrollBy is "function"
60+
scrollArg = behavior: "instant"
61+
scrollArg[if axisName is "x" then "left" else "top"] = amount
62+
element.scrollBy scrollArg
63+
else
64+
element[axisName] += amount
6065
element[axisName] != before
6166

6267
# Test whether `element` should be scrolled. E.g. hidden elements should not be scrolled.

0 commit comments

Comments
 (0)