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

@cmchu/screen-full

v0.0.1

Published

This module provides a straightforward set of APIs to control the browser's fullscreen functionality and listen for changes and errors in the fullscreen state. By encapsulating the native fullscreen APIs, it enables developers to uniformly handle fullscre

Downloads

2

Readme

Screenfull.js

Introduction

This module provides a straightforward set of APIs to control the browser's fullscreen functionality and listen for changes and errors in the fullscreen state. By encapsulating the native fullscreen APIs, it enables developers to uniformly handle fullscreen operations across different browsers.

Installation

使用 npm 或者 yarn 安装:

npm install @cmchu/screen-full
# or
yarn add @cmchu/screen-full

Usage

Importing the Module

First, import the screenfull module into your project.

import screenfull from '@cmchu/screen-full';

Core Functions

  • Check & Request Fullscreen

    • screenfull.isEnabled: Checks if the current browser supports fullscreen mode.
    • screenfull.isFullscreen: Checks if the current page is in fullscreen.
    • screenfull.request() or screenfull.requestFullscreen(element?, options?): Requests to make an element fullscreen. If no element is specified, it attempts to make the entire document fullscreen by default.
  • Exit Fullscreen

    • screenfull.exit() or screenfull.exitFullscreen(element?): Exits fullscreen mode. If no element is specified, it attempts to exit the current fullscreen element.
  • Event Listening

    • screenfull.onChange(callback) or screenfull.fullscreenchange(callback): Listens for changes in the fullscreen state.
    • screenfull.onError(callback) or screenfull.fullscreenerror(callback): Listens for fullscreen errors.
  • Get Fullscreen Element

    • screenfull.fullElement: Retrieves the current fullscreen element.

Keyboard Controls

  • The module automatically intercepts the default behavior of the F11 and Esc keys to implement one-click fullscreen entry/exit functionality.

API Reference

  • screenfull.isEnabled: A boolean indicating whether the browser supports the fullscreen API.
  • screenfull.isFullscreen: A boolean indicating whether the current page is in fullscreen mode.
  • screenfull.request(element?, options?): Enters fullscreen. Optional parameters include the element to be made fullscreen and fullscreen options.
  • screenfull.exit(element?): Exits fullscreen mode.
  • screenfull.onChange(callback): Registers a listener for changes in the fullscreen state.
  • screenfull.onError(callback): Registers a listener for fullscreen errors.
  • screenfull.fullElement: Retrieves the current DOM element in fullscreen.
  • handleKeyDown(event): An internal function handling keyboard events, automatically responding to F11 and Esc keys.

Considerations

  • Ensure compliance with the Same-Origin Policy and user interaction requirements in practical applications, as some browsers may restrict non-user-initiated fullscreen operations.
  • The module includes automatic handling of F11 and Esc shortcut keys. Modify or remove this logic as per your application's needs.

Example

import screenfull from '@cmchu/screen-full';

if (screenfull.isEnabled) {
  screenfull.request(); // Enter fullscreen
  screenfull.onChange(() => { // Listen for fullscreen state changes
    if (screenfull.isFullscreen) {
      console.log("Entered fullscreen");
    } else {
      console.log("Exited fullscreen");
    }
  });
} else {
  console.log("Your browser does not support the fullscreen API.");
}

License

This code example is licensed under the MIT License. Please adhere to the terms of relevant open-source licenses when using it.