GithubHelp home page GithubHelp logo

fullscreen-api's Introduction

<fullscreen-api>

A simple Polymer based Web Component wrapper for the HTML5 full screen API.

Please refer to the component page for more informations.

Available Web Components

  • fullscreen-api: The most flexible, comes without UI but with bindable attributes. Ideal when you need to dynamically set the element to display fullscreen (e.g. building and image gallery).
  • fullscreen-icon-button: Prepackaged material icon-button. Drop it on your page, tap it and it works.

Both elements share a common API and let you define what to display in full screen mode (via the target attribute) and toggle normal/full screen mode by calling the toggleFullscreen() method.

Note that this method MUST be triggered directly by user interaction (typically in a native onclick or Polymer's on-click handler). If no target is set, the whole page (more specifically document.documentElement) will be displayed full screen.

Attributes

  • target : The element to display full screen (document.documentElement by default), or the selector to use to automatically find that element. Note that changing the target while in full screen mode will not have any effect, as toggling between display modes MUST be triggered by user interaction.

  • fullscreen : Read-only flag (boolean) indicating if an element is being displayed full screen.

  • fullscreenAvailable : Read-only flag (boolean) indicating if full screen mode is available on the browser (Safari on iOS does not support it).

Methods

  • toggleFullscreen() : Toggle between full screen and normal display mode. MUST be triggered directly by user interaction (typically in a native 'onclick' or Polymer's 'on-click' handler).

  • exitFullscreen() : Exit full screen mode (if toggled).

Examples

  • fullscreen-api
<template is="dom-bind">
	<fullscreen-api id="fsapi" fullscreen-available="{{fullscreenAvailable}}"></fullscreen-api>

	<button type="button" onclick="goFullscreen()" hidden$="[[!fullscreenAvailable]]">Display this page in full screen mode</button>

	<div id="errorDiv" hidden$="[[fullscreenAvailable]]">
		Your browser does not support the HTML5 full screen API... :(
	</div>
</template>

<script>
	function goFullscreen() {
	  var fsapi = document.querySelector('#fsapi');
	  fsapi.toggleFullscreen();
	}
</script>
  • fullscreen-icon-button
    <fullscreen-icon-button target="#myElementToDisplayFullscreen" title="fullscreen" alt="fullscreen" tabindex="0"></fullscreen-icon-button>

Demo!

Link

Iframe demo

License

MIT License

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.