diff options
| author | Stephen Blott | 2014-12-14 15:17:01 +0000 |
|---|---|---|
| committer | Stephen Blott | 2014-12-14 15:17:01 +0000 |
| commit | d5cdffe53c78f21b49ef27d590199d3a453922ac (patch) | |
| tree | daf15a9192a463410fa84c188f04c6f0e4da8d17 | |
| parent | 99e387f9cb6654d88ba0fe5de1059b9d0df481b5 (diff) | |
| parent | 69c117102eb419baa649cccc770bffea5177b1e1 (diff) | |
| download | vimium-d5cdffe53c78f21b49ef27d590199d3a453922ac.tar.bz2 | |
Merge branch 'hideMouseOnLinux' of https://github.com/mrmr1993/vimium into mrmr1993-hideMouseOnLinux
| -rw-r--r-- | content_scripts/vimium_frontend.coffee | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/content_scripts/vimium_frontend.coffee b/content_scripts/vimium_frontend.coffee index ebdbb9aa..aeb74dcd 100644 --- a/content_scripts/vimium_frontend.coffee +++ b/content_scripts/vimium_frontend.coffee @@ -201,6 +201,7 @@ initializeOnDomReady = -> # Tell the background page we're in the dom ready state. chrome.runtime.connect({ name: "domReady" }) + CursorHider.init() registerFrame = -> # Don't register frameset containers; focusing them is no use. @@ -1085,6 +1086,36 @@ Tween = value = (elapsed / state.duration) * (state.to - state.from) + state.from state.onUpdate(value) +CursorHider = + # + # Hides the cursor when the browser scrolls, and prevent mouse from hovering while invisible + # + 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() + + init: -> + @cursorHideStyle = document.createElement("style") + @cursorHideStyle.innerHTML = """ + body * {pointer-events: none !important; cursor: none !important;} + body {cursor: none !important;} + """ + window.addEventListener "mousemove", @onMouseMove + window.addEventListener "scroll", @onScroll + initializePreDomReady() window.addEventListener("DOMContentLoaded", registerFrame) window.addEventListener("unload", unregisterFrame) |
