4.0.0 • Published 2 years ago

@straw-hat/react-fullscreen v4.0.0

Weekly downloads
54
License
MIT
Repository
github
Last release
2 years ago

@straw-hat/react-fullscreen

React hook for interacting with the Fullscreen API.

Usage

An example of a fullscreen button using https://material-ui.com/.

import IconButton from '@material-ui/core/IconButton';
import FullscreenIcon from '@material-ui/icons/Fullscreen';
import FullscreenExitIcon from '@material-ui/icons/FullscreenExit';
import * as React from 'react';

// 1. Import the dependency.
import { useFullscreen } from '@straw-hat/react-fullscreen';

export function FullscreenButton() {
  // 2. Create a `ref` that with the targeted element that will display in
  // fullscreen mode.
  const target = React.useRef(window.document.body);

  // 3. Pass the targeted element to the hook
  const { isFullscreen, toggleFullscreen } = useFullscreen(target);

  // 4. Use the exposed API in your component.
  return (
    <IconButton color="inherit" onClick={toggleFullscreen}>
      {isFullscreen ? <FullscreenExitIcon /> : <FullscreenIcon />}
    </IconButton>
  );
}
4.0.0

2 years ago

3.0.2

3 years ago

3.0.1

4 years ago

3.0.0

4 years ago

2.0.0

4 years ago

1.2.2

4 years ago

1.2.1

5 years ago

1.1.1

5 years ago

1.1.0

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago

0.1.0

6 years ago