GithubHelp home page GithubHelp logo

ember-fullscreen's Introduction

ember-fullscreen

Ember Observer Score npm version

Fullscreen API packaged as an Ember service.

ember-fullscreen uses Screenfull for the all the Fullscreen API calls. This means that ember-fullscreen will work on every browser that supports fullscreen API/screenfull: http://caniuse.com/fullscreen

Check minimal demo.

Installation

ember-fullscreen is an ember-cli addon. Just run the install command on your ember-cli project:

ember install ember-fullscreen

For more information on using ember-cli, visit http://www.ember-cli.com/.

Usage

Inject the service anywhere you need it by adding fullscreen: Ember.inject.service(). The fullscreen service has the following properties and methods:

  • .isAvailable - A boolean that represents whether you are allowed to enter fullscreen.

  • .isEnabled - A boolean that represents whether you are in fullscreen mode.

  • .enable() - Enters fullscreen mode. Accepts a DOM element. Default is <html>. If called with another element than the currently active, it will switch to that if it's a decendant. Yes, you can make DOM elements fullscreen.

  • .disable() - Disables fullscreen mode.

  • .toggle() - Enables fullscreen mode if not active, disables if active. Also accepts an optional DOM element.

  • .on('error', ...) - Fullscreen service includes Ember.Evented mixin. When a fullscreen request fails, ember-fullscreen triggers an error event.

  • .on('fullscreenChange', ...) - When the fullscreen state changes, ember-fullscreen notifies the new isEnabled state.

Examples

Create a button in your controller with an action that toggles fullscreen mode:

export default Controller.extend({
  fullscreen: service(),
  actions: {
    toggleFullscreen() {
      this.get('fullscreen').toggle();
    }
  }
});

Use it on your templates to conditionally render depending on a boolean:

{{#if fullscreen.isEnabled}}
  I'm fullscreen
{{else}}
  I'm NOT fullscreen
{{/if}}

Only display a button to enter fullscreen if the browser supports it:

{{#if fullscreen.isAvailable}}
  <button onclick={{action "toggleFullscreen"}}>
    Toggle fullscreen
  </button>
{{/if}}

A simple component that sets its own element to fullscreen on click:

export default Component.extend({
  fullscreen: service(),
  click() {
    this.get('fullscreen').toggle(this.element);
  }
});

Bind an icon class depending on wether we're in fullscreen:

{{!-- Uses font-awesome --}}
<i class="{{if fullscreen.isEnabled "fa-compress" "fa-expand"}}"></i>

ember-fullscreen's People

Contributors

aklkv avatar dependabot-support avatar dependabot[bot] avatar dmuneras avatar ember-tomster avatar jonnedeprez avatar jpadilla avatar luizcarraro avatar luketheobscure avatar miguelcobain avatar rmachielse avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

ember-fullscreen's Issues

Remove autoinjection

I keep reading that autoinjection is an anti-pattern. Are you interested in this as a contribution?

using this service for the purposes of the the CSS classing capability only

I use ember-fullscreen to go into full-screen mode and it works very nicely. I need the ability to go somewhat full-screen where I toggle the CSS class but without entering full-screen mode. I would love to reuse the service provided to use the toggle method but without having to pass in a DOM element. Otherwise, I would need to rewrite a very similar service.

I realize this extends slightly beyond the intended scope of this addon so not expecting to go through, just wanted to see if it was an option. Thanks!

Use npm instead of bower

Hi @miguelcobain

We are trying to drop our bower dependencies, and this project has come up as an addon that still depends on one.
I could make a pr switching this to npm, however the project seems a bit outdated overall.
What are your plans with this project?

Unit tests?

Not really sure how to test fullscreen capabilities.
Should we mock screenfull?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.