aboutsummaryrefslogtreecommitdiffstats
path: root/content_scripts/scroller.coffee
diff options
context:
space:
mode:
Diffstat (limited to 'content_scripts/scroller.coffee')
-rw-r--r--content_scripts/scroller.coffee13
1 files changed, 13 insertions, 0 deletions
diff --git a/content_scripts/scroller.coffee b/content_scripts/scroller.coffee
index f31c4a6b..43fad87e 100644
--- a/content_scripts/scroller.coffee
+++ b/content_scripts/scroller.coffee
@@ -254,5 +254,18 @@ Scroller =
else if window.innerHeight < rect.bottom
CoreScroller.scroll activatedElement, "y", 50 + rect.bottom - window.innerHeight, false
+ scrollToPosition: (element, top, left) ->
+ padding = 20
+ bottom = top + padding
+ right = left + padding
+
+ element.scrollTop = top if top <= element.scrollTop
+ element.scrollLeft = left if left <= element.scrollLeft
+
+ if element.scrollTop + element.clientHeight <= bottom
+ element.scrollTop = bottom - element.clientHeight
+ if element.scrollLeft + element.clientWidth <= right
+ element.scrollLeft = right - element.clientWidth
+
root = exports ? window
root.Scroller = Scroller