diff options
| author | Stephen Blott | 2018-06-15 15:41:19 +0100 | 
|---|---|---|
| committer | Stephen Blott | 2018-06-15 15:41:22 +0100 | 
| commit | 4cf37b5c5e9ba7b8e4b4c72a960761624d8151e8 (patch) | |
| tree | 754518c68da2441513a95c322333f6045738768a | |
| parent | 5745bb344959a61297fc16e00bb6de0a2a8744d9 (diff) | |
| download | vimium-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.
| -rw-r--r-- | content_scripts/marks.coffee | 7 | 
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 | 
