Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-request-fullscreen

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-request-fullscreen

Request fullscreen feature for browsers, used as a react component.

  • 1.1.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

react-request-fullscreen

Request fullscreen feature for browsers, used as a react component.

npm install

npm i react-request-fullscreen

Demo

Example

Usage

FulllScreen is a react component, so you can do like this.

import FullScreen from 'react-request-fullscreen';
render() {
    return (
        <FullScreen />
    );
}

After that, use the FulllScreen refs(fullScreen()) to request or exit fullscreen feature for browsers.

import React from 'react'
import ReactDOM from 'react-dom'
import FullScreen, { fullScreenSupported } from '../index'
// import FullScreen, { fullScreenSupported } from 'react-request-fullscreen'
import './App.less'

class App extends React.Component {
  constructor (props) {
    super(props)
    this.state = {
      isFullScreen: false
    }
  }

  onFullScreenChange (isFullScreen) {
    this.setState({
      isFullScreen
    })
  }

  requestOrExitFullScreen () {
    this.fullScreenRef.fullScreen()
  }

  requestOrExitFullScreenByElement () {
    this.elFullScreenRef.fullScreen(this.elRef)
  }

  render () {
    const { isFullScreen } = this.state
    return (
      <div className='app'>
        <p>Browser support fullscreen feature: {`${fullScreenSupported()}`}</p>
        <p>Browser is fullscreen: {`${isFullScreen}`}</p>
        <FullScreen ref={ref => { this.fullScreenRef = ref }} onFullScreenChange={this.onFullScreenChange.bind(this)}>
          <div
            className='rq'
            onClick={this.requestOrExitFullScreen.bind(this)}
          >
            {!isFullScreen ? 'Request FullScreen' : 'Exit FullScreen'}
          </div>
        </FullScreen>
        <FullScreen ref={ref => { this.elFullScreenRef = ref }}>
          <div
            className='el-rq'
            ref={ref => { this.elRef = ref }}
            onClick={this.requestOrExitFullScreenByElement.bind(this)}
          >
            {!isFullScreen ? 'Request FullScreen by Element' : 'Exit FullScreen by Element'}
          </div>
        </FullScreen>
        <br />
        <a href='https://github.com/TUBB/react-fullscreen'>GITHUB</a>
      </div>
    )
  }
}

ReactDOM.render(
  <App />,
  document.getElementById('root')
)

Please see Demo project for detail.

API

  • FullScreen.fullScreen(element?: HTMLElement) request or exit fullscreen feature.
  • fullScreenSupported() whether fullscreen feature is supported for the browser.
  • isFullScreen() the browser is fullscreen or not.

Note

Most code is come from chrisdickinson/fullscreen

License

MIT

Keywords

FAQs

Package last updated on 28 Aug 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc