Skip to content
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

Conversation

nicholasRutherford
Copy link
Contributor

Add a button to enable full screen mode. (Closes #19 )

The tiny icon in the top right:
image

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.

Nicholas Rutherford added 2 commits October 15, 2017 14:33
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.
@coveralls
Copy link

Coverage Status

Coverage remained the same at 88.732% when pulling 348e6bf on nicholasRutherford:fullscreen-button into 9db6e2a on kittoframework:master.


window.jQuery = window.$ = $;

Kitto.start();

var i = null;
Copy link
Member

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.

Copy link
Member

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>
Copy link
Member

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.

@kittoframework kittoframework deleted a comment from coveralls Oct 17, 2017
@kittoframework kittoframework deleted a comment from coveralls Oct 17, 2017
@kittoframework kittoframework deleted a comment from coveralls Oct 17, 2017
zorbash added a commit that referenced this pull request Feb 11, 2018
@zorbash
Copy link
Member

zorbash commented Feb 11, 2018

Merged! 9d8c391
Thanks @nicholasRutherford 🎊

@zorbash zorbash closed this Feb 11, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants