# react-request-fullscreen

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

Latest version **1.1.2** (published 2019-08-28) · MIT license · 0 weekly downloads

## Install

```sh
npm install react-request-fullscreen
pnpm add react-request-fullscreen
yarn add react-request-fullscreen
bun add react-request-fullscreen
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.2 |
| Published | 2019-08-28 |
| First published | 2018-10-27 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 22.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 3 |
| Author | Bingbing Tu |
| Maintainers | tubb |
| Keywords | fullscreen, react |

## Links

- npm: https://www.npmjs.com/package/react-request-fullscreen
- Repository: https://github.com/TUBB/react-fullscreen
- Homepage: https://github.com/TUBB/react-fullscreen#readme
- Issues: https://github.com/TUBB/react-fullscreen/issues
- npm.io page: https://npm.io/package/react-request-fullscreen

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 1.1.2 (latest) — 2019-08-28
- 1.1.1 — 2019-08-22
- 1.1.0 — 2019-08-21
- 1.0.9 — 2019-08-21
- 1.0.8 — 2019-08-19
- 1.0.7 — 2019-08-18
- 1.0.6 — 2019-08-18
- 1.0.5 — 2018-11-09
- 1.0.4 — 2018-10-31
- 1.0.3 — 2018-10-30
- 1.0.2 — 2018-10-29
- 1.0.1 — 2018-10-28
- 1.0.0 — 2018-10-27

## README

# react-request-fullscreen 
Request fullscreen feature for browsers, used as a react component.

## npm install
```script
npm i react-request-fullscreen
```

## Demo
[Example](http://tubb.github.io/react-fullscreen/example.html)

## Usage
[FulllScreen](https://github.com/TUBB/react-fullscreen/blob/master/src/FullScreen.js) is a react component, so you can do like this.
```javascript
import FullScreen from 'react-request-fullscreen';
```
```javascript
render() {
    return (
        <FullScreen />
    );
}
```
After that, use the [FulllScreen](https://github.com/TUBB/react-fullscreen/blob/master/src/FullScreen.js) refs(`fullScreen()`) to request or exit fullscreen feature for browsers.
```javascript
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](https://github.com/TUBB/react-fullscreen/blob/master/src/example/App.js) 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](https://github.com/chrisdickinson/fullscreen)

## License
[MIT](https://opensource.org/licenses/MIT)

---
_Source: https://npm.io/package/react-request-fullscreen · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
