aboutsummaryrefslogtreecommitdiffstats
path: root/content_scripts/vimium_frontend.coffee
diff options
context:
space:
mode:
authorStephen Blott2014-12-14 15:36:15 +0000
committerStephen Blott2014-12-14 15:36:15 +0000
commit9c677fc91cd2641c709bb1afe03466c92b0ee0ea (patch)
tree273e400ab17e8eac0fc0da56a2541f35f1e6ce0c /content_scripts/vimium_frontend.coffee
parentd5cdffe53c78f21b49ef27d590199d3a453922ac (diff)
downloadvimium-9c677fc91cd2641c709bb1afe03466c92b0ee0ea.tar.bz2
Minor refactoring of CursorHider.
Diffstat (limited to 'content_scripts/vimium_frontend.coffee')
-rw-r--r--content_scripts/vimium_frontend.coffee19
1 files changed, 8 insertions, 11 deletions
diff --git a/content_scripts/vimium_frontend.coffee b/content_scripts/vimium_frontend.coffee
index aeb74dcd..9478a7d5 100644
--- a/content_scripts/vimium_frontend.coffee
+++ b/content_scripts/vimium_frontend.coffee
@@ -1089,23 +1089,20 @@ Tween =
CursorHider =
#
# Hides the cursor when the browser scrolls, and prevent mouse from hovering while invisible
+ # NOTE(smblott) onScroll and onMouseMove events come in pairs.
#
cursorHideStyle: null
isScrolling: false
- showCursor: ->
- @cursorHideStyle.remove() if @cursorHideStyle.parentElement
- hideCursor: ->
- document.head.appendChild @cursorHideStyle unless @cursorHideStyle.parentElement
-
- onMouseMove: (event) ->
- if CursorHider.isScrolling # This event was caused by scrolling, don't show the cursor.
- CursorHider.isScrolling = false
- else
- CursorHider.showCursor()
onScroll: (event) ->
CursorHider.isScrolling = true
- CursorHider.hideCursor()
+ unless CursorHider.cursorHideStyle.parentElement
+ document.head.appendChild CursorHider.cursorHideStyle
+
+ onMouseMove: (event) ->
+ if CursorHider.cursorHideStyle.parentElement and not CursorHider.isScrolling
+ CursorHider.cursorHideStyle.remove()
+ CursorHider.isScrolling = false
init: ->
@cursorHideStyle = document.createElement("style")