1.0.3 • Published 3 years ago

@gitgw/use-fullscreen v1.0.3

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

@gitgw/use-fullscreen

React Hook to make any element go Fullscreen.

Installation

npm

npm i @gitgw/use-fullscreen

yarn

yarn add @gitgw/use-fullscreen

Usage

import React from "react";
import useFullscreen from "@gitgw/use-fullscreen";

function App() {
  const onChange = (isFull) => {
    console.log("onChange");
  }
  const { element, enterFullScreen, exitFullScreen } = useFullscreen(onChange);

  return (
    <div className="App">
      <button onClick={enterFullScreen}>enterFullScreen</button>;
      <button onClick={exitFullScreen}>exitFullScreen</button>;
    </div>
  );
}

Arguments

ArgumentTypeDescriptionArgumentsRequired
onChangeFunctionFunction to be called when the screen goes Fullscreen or exits isisFull: Booleanno

Return

useFullscreen returns an object containing the following: Return value|Type|Description| |-|-|-| |element|React ref|Ref to add to the element that you want to make fullscreen |enterFullScreen|Function|Function to make the element enter fullscreen |exitFullScreen|Function|Function to make the document exit fullscreen