-
Notifications
You must be signed in to change notification settings - Fork 6.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
added option to hide cursor in fullscreen mode #536
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -397,6 +397,33 @@ | |
scale: 1 | ||
}; | ||
|
||
// Hide the mouse cursor in fullscreenmode after the configured | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We are moving to a plugin architecture. So instead of a patch against impress.js, you should write this as a plugin. See https://github.com/henrikingo/impress.js/blob/myfork/src/plugins/README.md for a detailed explanation. If you want to write a PR against that repo, you're welcome to do so. Alternatively, if you want to do a PR against the impress/impress.js repo in its current state, you could still write this as a "plugin" By adding a separate |
||
// amount of milliseconds without movement | ||
if(rootData.hideMouseAfter) { | ||
var mouseMoveTimer = null, | ||
isCursorVisible = true; | ||
|
||
var hideCursor = function() { | ||
//isFullscreen | ||
if(!window.screenTop && !window.screenY){ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This if() is actually a bit obscure. It would be more readable if you implement a helper function isFullscreen(), which returns true when this if is true. (I can get it since there is the comment, but would prefer the helper function, especially as this code moves to a separate plugin, so an extra line of code or two isn't an issue.) |
||
mouseMoveTimer = null; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm unsure about this line. If someone were to call hideCursor() some other way than via setTimeout() timeout triggering, then mouseMoveTimer will be null but the timeout will still expire? Wouldn't it be better to call window.clearTimeout(mouseMoveTimer) here? Alternatively, I'm not sure you need to do anything about mouseMoveTimer here. Wouldn't this work just as well if you just leave this line out? |
||
document.body.style.cursor = "none"; | ||
isCursorVisible = false; | ||
} | ||
}; | ||
|
||
document.onmousemove = function() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think you should use document.addEventListener() instead. Other than that I agree with this approach. |
||
if (mouseMoveTimer) { | ||
window.clearTimeout(mouseMoveTimer); | ||
} | ||
if (!isCursorVisible) { | ||
document.body.style.cursor = "default"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If the user wanted to theme the cursor with css, you will now unset that. You need to save the original cursor value when hiding it, then set it back to original value here. |
||
isCursorVisible = true; | ||
} | ||
mouseMoveTimer = window.setTimeout(hideCursor, rootData.hideMouseAfter); | ||
}; | ||
} | ||
|
||
initialized = true; | ||
|
||
triggerEvent(root, "impress:init", { api: roots[ "impress-root-" + rootId ] }); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi sclausen
Good idea and easy to implement.
IMO this feature needn't be optional. (Not adding an option benefits the goal of simplicity.) I don't think anyone will miss the pointer if we just hide it always after 3 seconds of inactivity. (I can see that someone would want to leave the mouse pointer pointing at something on a slide. But that should be rare. You'd usually move the pointer to point at something, but that would still work. Also, it is more common to use laser pointers, etc.)