From 9c677fc91cd2641c709bb1afe03466c92b0ee0ea Mon Sep 17 00:00:00 2001 From: Stephen Blott Date: Sun, 14 Dec 2014 15:36:15 +0000 Subject: Minor refactoring of CursorHider. --- content_scripts/vimium_frontend.coffee | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) (limited to 'content_scripts') 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") -- cgit v1.2.3