-
Notifications
You must be signed in to change notification settings - Fork 58
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
Fullscreen button #121
Fullscreen button #121
Conversation
Browsers implement the fullscreen api in different ways so we use the Fscreen library to handle the fullscreen request. This is the library recommended in the mozilla docs: https://developer.mozilla.org/en-US/docs/Web/API/Fullscreen_API
We want the button to show up when the mouse is active, so it has to listen to mouse events on the whole body. Seeing how there isn't a place for internal react components and because it is so simple we just use an click listener instead of react.
|
||
window.jQuery = window.$ = $; | ||
|
||
Kitto.start(); | ||
|
||
var i = null; |
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.
application.js is meant for the user to extend / modify appearance and behaviour.
Let's have this in an initializeFullScreenButton
function in https://github.com/kittoframework/kitto/blob/master/priv/static/kitto.js also move the fscreen
import there.
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.
Something like the following (haven't tried it):
function initializeFullScreenButton() {
var timer;
var $button = $('.fullscreen-button');
$('body').on('mousemove', function() {
clearTimeout(timer);
if (!$button.hasClass('active')) { $button.addClass('active') }
timer = setTimeout(function() { $button.removeClass('active') }, 1000);
})
$button.on('click', function() {
fscreen.requestFullscreen(document.getElementById('container'));
})
return this;
}
which will be called in Kitto.start
@@ -16,6 +16,8 @@ | |||
<%= @template %> | |||
</div> | |||
|
|||
<i class="fullscreen-button fa fa-arrows-alt"></i> |
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.
Let's have this before the #container div.
Merged! 9d8c391 |
Add a button to enable full screen mode. (Closes #19 )
The tiny icon in the top right:
Test it out here!
The fullscreen API is a bit of mess across multiple browsers so it uses the fscreen library to handle the api call. This is the library recommended in the mozilla docs.
Since we want the button to show up when moving the mouse anywhere on the screen it listens to mouse move events on
body
. There doesn't seem to be a place for internal react components so while the button could be a component I think it makes more sense to just have the onClick listener.