From bc4f3ecac81fd8f174b8c3ad92a0998ada8f7992 Mon Sep 17 00:00:00 2001 From: Stephen Blott Date: Thu, 4 Jun 2015 15:14:10 +0100 Subject: Global marks; focus and only scroll in the main frame. --- content_scripts/vimium_frontend.coffee | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'content_scripts') diff --git a/content_scripts/vimium_frontend.coffee b/content_scripts/vimium_frontend.coffee index f644ea35..dc083e6c 100644 --- a/content_scripts/vimium_frontend.coffee +++ b/content_scripts/vimium_frontend.coffee @@ -147,7 +147,7 @@ initializePreDomReady = -> focusFrame: (request) -> if (frameId == request.frameId) then focusThisFrame request refreshCompletionKeys: refreshCompletionKeys getScrollPosition: -> scrollX: window.scrollX, scrollY: window.scrollY - setScrollPosition: (request) -> setScrollPosition request.scrollX, request.scrollY + setScrollPosition: setScrollPosition executePageCommand: executePageCommand currentKeyQueue: (request) -> keyQueue = request.keyQueue @@ -264,11 +264,15 @@ executePageCommand = (request) -> refreshCompletionKeys(request) -setScrollPosition = (scrollX, scrollY) -> - if (scrollX > 0 || scrollY > 0) - DomUtils.documentReady -> - Marks.setPreviousPosition() - window.scrollTo scrollX, scrollY +# Set the scroll position (but only in the main frame). Some pages (like Facebook) get confused if you set +# the scroll position in all frames. +setScrollPosition = ({ scrollX, scrollY }) -> + if DomUtils.isTopFrame() + if scrollX > 0 or scrollY > 0 + DomUtils.documentReady -> + window.focus() + Marks.setPreviousPosition() + window.scrollTo scrollX, scrollY # # Called from the backend in order to change frame focus. -- cgit v1.2.3