npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

screenfull-es6

v0.1.3

Published

Simple wrapper for cross-browser usage of the JavaScript Fullscreen API

Downloads

196

Readme

ScreenFull-ES6

ScreenFull-ES6 based on screenfull.js

Overview

Simple wrapper for cross-browser usage of the JavaScript Fullscreen API, which lets you bring the page or any element into fullscreen. Smoothens out the browser implementation differences, so you don't have to.

Demo

Install

$ npm install --save screenfull-es6

Also available on unpkg.com or jsdelivr.

Support

Supported browsers

Documentation

Examples

Fullscreen the page

document.getElementById('button').addEventListener('click', () => {
	if (ScreenFull.enabled) ScreenFull.request();
});

Fullscreen an element

const el = document.getElementById('target');

document.getElementById('button').addEventListener('click', () => {
	if (ScreenFull.enabled) ScreenFull.request(el); 
});

Fullscreen an element with jQuery

const target = $('#target')[0]; // Get DOM element from jQuery collection

$('#button').on('click', () => {
	if (ScreenFull.enabled) ScreenFull.request(target);
});

Detect fullscreen change

if (ScreenFull.enabled) {
	ScreenFull.on('change', () => {
		console.log('Am I fullscreen?', ScreenFull.isFullscreen ? 'Yes' : 'No');
	});
}

Remove listeners with:

ScreenFull.off('change', callback);

Detect fullscreen error

if (ScreenFull.enabled) {
	ScreenFull.on('error', event => {
		console.error('Failed to enable fullscreen', event);
	});
}

See the demo for more examples, or view the source.

Fullscreen the page with Angular 2

import {Directive, HostListener} from '@angular/core';
import ScreenFull from 'screenfull-es6';

@Directive({
	selector: '[toggleFullscreen]'
})
export class ToggleFullscreenDirective {
	@HostListener('click') onClick() {
		if (ScreenFull.enabled) {
			ScreenFull.toggle();
		}
	}
}
<button toggleFullscreen>Toggle fullscreen<button>

Fullscreen the page with Vue.JS

<template>
  <button v-on:click="toggleFullscreen">Toggle fullscreen</button>
</template>

<script>
import ScreenFull from 'screenfull-es6';
export default {
  methods: {
    toggleFullscreen(){
      if (ScreenFull.enabled) {
        ScreenFull.toggle();
      }
    }
  }
}
</script>

Methods

.request()

Make an element fullscreen.

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.

If your page is inside an <iframe> you will need to add a allowfullscreen attribute (+ webkitallowfullscreen and mozallowfullscreen).

Keep in mind that the browser will only enter fullscreen when initiated by user events like click, touch, key.

.exit()

Brings you out of fullscreen.

.toggle()

Requests fullscreen if not active, otherwise exits.

.on(event, function)

Events: change error

Add a listener for when the browser switches in and out of fullscreen or when there is an error.

.off(event, function)

Remove a previously registered event listener.

.onchange(function)

Alias for .on('change', function)

.onerror(function)

Alias for .on('error', function)

Properties

.isFullscreen

Returns a boolean whether fullscreen is active.

.element

Returns the element currently in fullscreen, otherwise null.

.enabled

Returns a boolean whether you are allowed to enter fullscreen. If your page is inside an <iframe> you will need to add a allowfullscreen attribute (+ webkitallowfullscreen and mozallowfullscreen).

License

MIT © Sindre Sorhus, modified by Aleksandr Tar