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

wholescreen.js

v0.3.1

Published

Minimal cross-browser wrapper of the Fullscreen API. Handles vendor prefixes for you!

Downloads

8

Readme

Greenkeeper badge

wholescreen.js

Tiny wrapper (~40 lines of code) for the Fullscreen API.

  • Handles all vendor prefixes for you
  • Has a simple API that resembles the standard API
  • Supports UMD, standalone ES6 modules, require.js and AMD as separate files so you can import it anwhere.
  • Comes with TypeScript definitions (since it's written in TypeScript)
  • Detects each of the browser properties individually, meaning wider support, and safer for browser changes. All while using less code.
  • Probably the smallest Fullscreen API wrapper (but they're all pretty small)

Installation

npm install --save wholescreen.js

Or

yarn add wholescreen.js

Or you can use the jsdelivr CDN

<script src="https://cdn.jsdelivr.net/npm/wholescreen.js"></script>

Usage example

import wholescreen from 'wholescreen.js';

const element = document.querySelector('.some-element');

// Check for support
if (wholescreen.supported) {
	// listen to changes
	wholescreen.on('change', () => {
		// Log change based on `wholescreen.active`
		console.log(`Fullscreen ${wholescreen.active ? 'enabled' : 'disabled'}`)
	});

	// Activate fullscreen mode on button click
	// You should only request fullscreen from events like this, or browsers will deny the request.
	document.querySelector('.button').addEventListener('click', () => {
		// If you pass an element as the second argument the element will fullscreen instead of the window
		wholescreen.request();
	});
}

API

The API was designed to generally use the same names as the standard API (without the word fullscreen in everything since it's implied). There is one exception: fullscreenEnabled was renamed to supported, to avoid the misleading standard name. It also has a couple of useful additions over the standard API.

Getters

| Property | type | Description | |-------------|-----------|---------------| | supported | boolean | Check device / browser support and if the window has permission to use fullscreen (requires special parameter for iframes) | | active | boolean | Check if an element is currently fullscreened | | element | Node | The dom node (element) currently fullscreened (or null if none) |

Methods

| Method | arguments | Description | |-------------|-------------------------------|---------------| | request() | element | Activate fullscreen for the element, or the window if the element argument is missing | | toggle() | element, enable | Toggle fullscreen for the element. Will toggle based on the optional enable argument if present, otherwise it will reverse active. If another element is fullscreened, it will restore it first | | exit() | - | Exit fullscreen | | on() | type, listener, options | Listen for wholescreen events. Works exactly like addEventListener, except it (only) supports custom wholescreen event types change and error | | off() | type, listener, options | Remove wholescreen event listener. Works exactly like removeEventListener, except it (only) supports custom wholescreen event types change and error |

Browser API

If you need to get the original method and property names for the current browser, these are available as wholescreen.events and wholescreen.props

Support

Browsers support

Alternatives

  • screenfull.js - The first and most well used Fullscreen API wrapper. Uses commonjs module declaration. The wholescreen.js API is very similar to screenfull.js (not by intention). screenfull also support the legacy syntax with an additional optional argument for allowing keyboard input.
  • fscreen - Small alternative. Handles all the common prefixes, but not the older Safari ones (you can most likely do without them). Uses es6-module declaration. The API is more verbose than screenfull.js and wholescreen.js