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

react-fullscreenable

v2.5.1-0

Published

React higher order component that provides fullscreen API to the enhanced component

Downloads

1,150

Readme

react-fullscreenable

This is a higher order component that enhances any component with props that allow it to enter native fullscreen.

Changelog

  • 2.5.0 - Package and test hygiene for React 16. Thanks @schneidmaster.

  • 2.4.3 - Fix for issue #3. Native fullscreen detection fixed in Firefox.

  • 2.4.2 - Fix for issue #2. Update issue #2 or create a new one as needed if this is causing issues for you. Any feedback appreciated!

  • 2.4.0 - Feature: Component now accepts prop isPseudoFullscreen that will immediately enter into pseudoFullscreen when passed as true. This cannot work with native fullscreen since that requires a user-generated event in order for the request to be fulfilled by the browser.

  • 2.3.1 - Bugfix: Component now disposes of event handlers and inline styles during componentWillUnmount() that would otherwise leak if component was unmounted while in pseudo fullscreen.

  • 2.3.0 - Component now accepts a callback function as optional prop onFullscreenChange that will be called whenever fullscreen is entered or exited.

  • 2.2.1 - Now using prop-types npm module to be compatible with React beyond 15.5.

  • 2.2.0 - Component now sets body style to prevent scrolling document in background. - Fixed issue where TouchMove events that made it to the component would be prevented, which caused jitter during native scroll. - Fixed bug where scrollY was not restored in pseudo fullscreen.

  • 2.1.1 - Now Universal. Added DOM check before checking if native fullscreen is available on document.

Usage

The first provided prop is a boolean isFullscreen that updates when the fullscreen change event fires. The second is a function toggleFullscreen that must be attached to a node used for toggling fullscreen by the user. Note: You cannot call .toggleFullscreen outside of an actual user event or the browser will throw an error. (Unless using forcePseudoFullscreen.)

When native fullscreen is not possible (either because it is disabled or because it is not supported) this component will fall back to a pseudo-fullscreen effect. This is achieved by sizing and positioning the wrapper node to fit the window. When in either mode the prop viewportDimensions is provided to the wrapped component as:

{
    height: <window.clientHeight>,
    width: <window.clientWidth>
}

viewportDimensions is otherwise passed as null. Device orientation and other window resize events will update these dimensions. This allows you to size the child components as needed.

Make these changes in the component you want to enhance with fullscreen. In these examples we'll call it DemoComponent:

  1. Import Fullscreenable. (See ./example/DemoComponent.js)

    import Fullscreenable from 'react-fullscreenable';
  2. Add the props isFullscreen, toggleFullscreen and viewportDimensions. forcePseudoFullscreen will also be passed down if it was passed into the enhanced component.

    DemoComponent.propTypes = {
        isFullscreen: PropTypes.bool,
        toggleFullscreen: PropTypes.func
    };
  3. Use the toggleFullscreen prop on a button or other node in the render method.

    <button onClick={this.props.toggleFullscreen}>Fullscreen</button>
  4. Enhance the component with Fullscreenable and export it however it makes sense for you.

    const FullscreenableDemoComponent = Fullscreenable()(DemoComponent);
    
    // You could also make this a named export instead of the default if you want the flexibility to use the component with or without the fullscreen enhancement.
    export default FullscreenableDemoComponent;
  5. Simply import and use your component the same way as you normally would. (See ./example/demo.js)

    import DemoComponent from '../path/to/DemoComponent';

Also take a look at ./example/demo.css. No CSS is required for this component to function correctly. However you will probably want rules for some child elements. demo.css is a good starting point.

Development

npm i
npm run start

Your browser should open to the live demo page.

Testing

Tests are written with Jest and Enzyme.

npm t

[email protected]