1.0.0 • Published 3 years ago

@ziphooks/use-fullscreen v1.0.0

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

@ziphooks/use-fullscreen

React Hook for change a component to fullscreen mode and normal mode.

Installation

yarn

yarn add @ziphooks/use-fullscreen

npm

npm i @ziphooks/use-fullscreen

Usage

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

function App() {
  const { element, triggerFull, exitFull } = useFullscreen(isFull => alert(isFull ? "I am FULL" : "I am not FULL")));
  return (
    <div ref={element}>
      <h1>Hello</h1>
      <button onClick={triggerFull}>Enter Fullscreen</button>
      <button onClick={exitFull}>Exit Fullscreen</button>
    </div>
  );
};

Arguments

ArgumentTypeDescriptionRequired
onChangeFunctionA function to be called when the screen goes Fullscreen or exits isfalse

Return

Return valueTypeDescription
elementReact RefA ref to add to the element that you want to make fullscreen
triggerFullFunctionA function to make the element enter fullscreen
exitFullFunctionA function to make the document exit fullscreen