aboutsummaryrefslogtreecommitdiffstats
path: root/content_scripts
diff options
context:
space:
mode:
authorStephen Blott2018-06-15 15:41:19 +0100
committerStephen Blott2018-06-15 15:41:22 +0100
commit4cf37b5c5e9ba7b8e4b4c72a960761624d8151e8 (patch)
tree754518c68da2441513a95c322333f6045738768a /content_scripts
parent5745bb344959a61297fc16e00bb6de0a2a8744d9 (diff)
downloadvimium-4cf37b5c5e9ba7b8e4b4c72a960761624d8151e8.tar.bz2
Use hash (too) for local marks.
First, I *very rarely* use local marks. They just don't seem as useful in a browser as they are in a text editor. However, on a page like GMail, I do often want to jump back and forward between my labels. These are different locations hashes (anchors). The idea here is to make local marks useful for this case. If the scroll positions (X and Y) are both 0, and the hash (anchor) is present in the mark and non-empty, then change the hash instead of scrolling. On first tests, this appears to work nicely for changing labels in GMail. I'm sure there are other uses. This change shouldn't interfere with use cases where the user has scrolled within the page.
Diffstat (limited to 'content_scripts')
-rw-r--r--content_scripts/marks.coffee7
1 files changed, 5 insertions, 2 deletions
diff --git a/content_scripts/marks.coffee b/content_scripts/marks.coffee
index fb1d1b1d..3690908d 100644
--- a/content_scripts/marks.coffee
+++ b/content_scripts/marks.coffee
@@ -15,7 +15,7 @@ Marks =
"vimiumMark|#{window.location.href.split('#')[0]}|#{keyChar}"
getMarkString: ->
- JSON.stringify scrollX: window.scrollX, scrollY: window.scrollY
+ JSON.stringify scrollX: window.scrollX, scrollY: window.scrollY, hash: window.location.hash
setPreviousPosition: ->
markString = @getMarkString()
@@ -84,7 +84,10 @@ Marks =
if markString?
@setPreviousPosition()
position = JSON.parse markString
- window.scrollTo position.scrollX, position.scrollY
+ if position.hash and position.scrollX == 0 and position.scrollY == 0
+ window.location.hash = position.hash
+ else
+ window.scrollTo position.scrollX, position.scrollY
@showMessage "Jumped to local mark", keyChar
else
@showMessage "Local mark not set", keyChar