Giter Club home page Giter Club logo

react-fullscreen's Introduction

React Fullscreen

A React component that sets its children to fullscreen using the Fullscreen API, normalized using fscreen.

Usage

* Install.

yarn add react-full-screen

* Import component and hook

import { FullScreen, useFullScreenHandle } from "react-full-screen";

* Setup and render.

You must use one handle per full screen element. It is not possible to start in Fullscreen. Fullscreen must be enabled from a user action such as onClick.

import React, {useCallback} from 'react';
import { FullScreen, useFullScreenHandle } from "react-full-screen";

function App() {
  const handle = useFullScreenHandle();

  return (
    <div>
      <button onClick={handle.enter}>
        Enter fullscreen
      </button>

      <FullScreen handle={handle}>
        Any fullscreen content here
      </FullScreen>
    </div>
  );
}

export default App;

When you have many elements you need one handle per element.

import React, {useCallback} from 'react';
import { FullScreen, useFullScreenHandle } from "react-full-screen";

function App() {
  const screen1 = useFullScreenHandle();
  const screen2 = useFullScreenHandle();

  const reportChange = useCallback((state, handle) => {
    if (handle === screen1) {
      console.log('Screen 1 went to', state, handle);
    }
    if (handle === screen2) {
      console.log('Screen 2 went to', state, handle);
    }
  }, [screen1, screen2]);

  return (
    <div>
      <button onClick={screen1.enter}>
        First
      </button>

      <button onClick={screen2.enter}>
        Second
      </button>

      <FullScreen handle={screen1} onChange={reportChange}>
        <div className="full-screenable-node" style={{background: "red"}}>
          First
          <button onClick={screen2.enter}>
            Switch
          </button>
          <button onClick={screen1.exit}>
            Exit
          </button>
        </div>
      </FullScreen>

      <FullScreen handle={screen2} onChange={reportChange}>
        <div className="full-screenable-node" style={{background: "green"}}>
          Second
          <button onClick={screen1.enter}>
            Switch
          </button>
          <button onClick={screen2.exit}>
            Exit
          </button>
        </div>
      </FullScreen>
    </div>
  );
}

export default App;

Types

interface FullScreenHandle {
  active: boolean;
  // Specifies if attached element is currently full screen.

  enter: () => Promise<void>;
  // Requests this element to go full screen.

  exit: () => Promise<void>;
  // Requests this element to exit full screen.

  node: React.MutableRefObject<HTMLDivElement | null>;
  // The attached DOM node
}
interface FullScreenProps {
  handle: FullScreenHandle;
  // Handle that helps operate the full screen state.

  onChange?: (state: boolean, handle: FullScreenHandle) => void;
  // Optional callback that gets called when this screen changes state.
  
  className?: string;
  // Optional prop allowing you to apply a custom class name to the FullScreen container
}

CSS

Class fullscreen-enabled will be added to component when it goes fullscreen. If you want to alter child elements when this happens you can use a typical CSS statement.

.my-component {
  background: #fff;
}

.fullscreen-enabled .my-component {
  background: #000;
}

In the wild

Used with MegamanJS

react-fullscreen's People

Contributors

briandelancey avatar dedztbh avatar dependabot[bot] avatar dlindenkreuz avatar mrmarkhayward avatar pomle avatar vadzim avatar yoichiro avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

react-fullscreen's Issues

Not able to set custom class on fullscreen,

inside index.jsx

(this.node = node)} style={ this.props.enabled ? { height: "100%", width: "100%" } : undefined } > {this.props.children}

change above to

(this.node = node)} style={ this.props.enabled ? { height: "100%", width: "100%" } : undefined } > {this.props.children}

or you can introduce a new property allowScroll=true/false if true set Overflow-x=hidden and overflow-y=scroll in style.....

do this its needed.

Support for react >= 17

Hi,
will support for react 17.0.0 (or above) be considered in the future? (as a peer-dep)
Thanks ๐Ÿ˜„

ESC causing error

Same problem is happening for me. It might be because of my structure.
I want to have fullscreen button inside of fullscreen and toggling for fullscreen or exit.
But the issue is, while screen is full, press the 'ESC', getting below error;

Failed to execute 'requestFullscreen' on 'Element': API can only be initiated by a user gesture.

 <Fullscreen
          enabled={this.state.isFull}
          onChange={isFull => this.setState({ isFull })}
        >
          <Router history={history}>
            <div className="page-container">
              <div className="nav-bar">
                <NavBar history={history} onClickFullScreen={this.handleFullScreen}/>
              </div>
            </div>
          </Router>
        </Fullscreen>

Originally posted by @tolgaduzenli in #14 (comment)

Not working on mobile

When i try and use it on mobile browsers (Safari, Chrome, Firefox) it won't work. On desktop it works fine.

ios support?

Hi everyone

I did not manage to get it working on any iOS browser (neither FF or Chrome)
if i remember correctly FF and Chrome should support the new fullscreen api on iOS ... safari i remember not

am i wrong?

thanks

Exiting fullscreen via ESC causes error

Setting component state while exiting fullscreen via ESC key causes error.
This only happens when pressing ESC key, not when clicking to exit fullscreen.
Setting state via onClick doesn't cause the error, just the onChange or window resize events.

Steps to reproduce:

  1. Open fullscreen
  2. Exit fullscreen by clicking ESC key
  3. Observe the following error:
Failed to execute 'requestFullscreen' on 'Element': API can only be initiated by a user gesture.
Uncaught (in promise) TypeError: fullscreen error
    at Object.requestFullscreen (index.js?6277:28)
    at FullScreen.enterFullScreen (index.js?b44f:79)
    at FullScreen.handleProps (index.js?b44f:65)
    at FullScreen.componentDidUpdate (index.js?b44f:56)

Example code 1 (onChange):

import FullscreenFromLibrary from 'react-full-screen'
import PropTypes from 'prop-types'
import React from 'react'

export class Fullscreen extends React.Component {
  constructor(props) {
    super(props)
    this.state = {
      isFullscreen: false,
    }
  }

  render() {
    return (
      <FullscreenFromLibrary
        enabled={this.state.isFullscreen}
        //Comment out the line below to make it not show error
        onChange={() => this.setState({ doesnt: 'matter' })}
      >
        <div onClick={() => this.setState({isFullscreen: !this.state.isFullscreen})}>
          Open/Close fullscreen
        </div>
      </FullscreenFromLibrary>
    )
  }
}

Example code 2 (resize):

import FullscreenFromLibrary from 'react-full-screen'
import PropTypes from 'prop-types'
import React from 'react'

export class Fullscreen extends React.Component {
  constructor(props) {
    super(props)
    this.toggle = this.toggle.bind(this)
    this.handleResize = this.handleResize.bind(this)
    this.state = {
      isFullscreen: false,
    }
  }

  toggle() {
    this.setState({isFullscreen: !this.state.isFullscreen})
  }

  handleResize() {
    //Comment out the line below to make it not show error
    this.setState({ doesnt: 'matter' })
  }

  componentDidMount() {
    window.addEventListener('resize', this.handleResize)
  }

  render() {
    return (
      <FullscreenFromLibrary
        enabled={this.state.isFullscreen}
      >
        <div onClick={this.toggle}>
          Open/Close fullscreen
        </div>
      </FullscreenFromLibrary>
    )
  }
}

Importing & Class Made instead of Hooks

The class made react not supported. It's not working anymore.

i can't import anymore with FullScreen.....i need to destruct now
import FullScreen from "react-full-screen";

When i hit escape it dosen't work properly

version 0.2.4 its more stable

Issue Migrating to v0.3.x

I'm on version 0.2.x and trying to upgrade to version 0.3.x, and not sure how to work with the handle.

In the README.md example, Fullscreen is inside the same component as the button used to invoke it.

import React, {useCallback} from 'react';
import { FullScreen, useFullScreenHandle } from "react-full-screen";

function App() {
  const handle = useFullScreenHandle();

  return (
    <div>
      <button onClick={handle.enter}>
        Enter fullscreen
      </button>

      <FullScreen handle={handle}>
        Any fullscreen content here
      </FullScreen>
    </div>
  );
}

export default App;

Easy peasy.

However, more complex apps like mine have the button very far away from Fullscreen in terms of the react tree... not in the same component. So how do we share the handle between Fullscreen and the button(s) used to invoke it?

crash when press Esc or click on close button

index.js:22 Failed to execute 'requestFullscreen' on 'Element': API can only be initiated by a user gesture.
requestFullscreen @ index.js:22
enterFullScreen @ index.js:122
handleProps @ index.js:108
componentDidUpdate @ index.js:98
commitLifeCycles @ react-dom.development.js:18124
commitAllLifeCycles @ react-dom.development.js:19668
callCallback @ react-dom.development.js:147
invokeGuardedCallbackDev @ react-dom.development.js:196
invokeGuardedCallback @ react-dom.development.js:250
commitRoot @ react-dom.development.js:19892
(anonymous) @ react-dom.development.js:21440
unstable_runWithPriority @ scheduler.development.js:255
completeRoot @ react-dom.development.js:21439
performWorkOnRoot @ react-dom.development.js:21362
performWork @ react-dom.development.js:21267
performSyncWork @ react-dom.development.js:21241
requestWork @ react-dom.development.js:21096
commitPassiveEffects @ react-dom.development.js:19730
wrapped @ scheduler-tracing.development.js:177
flushPassiveEffects @ react-dom.development.js:19759
dispatchAction @ react-dom.development.js:14041
onChange @ SpectrumChart.jsx:401
detectFullScreen @ index.js:115
index.js:22 Uncaught (in promise) TypeError: fullscreen error
at Object.requestFullscreen (index.js:22)
at FullScreen.enterFullScreen (index.js:122)
at FullScreen.handleProps (index.js:108)
at FullScreen.componentDidUpdate (index.js:98)
at commitLifeCycles (react-dom.development.js:18124)
at commitAllLifeCycles (react-dom.development.js:19668)
at HTMLUnknownElement.callCallback (react-dom.development.js:147)
at Object.invokeGuardedCallbackDev (react-dom.development.js:196)
at invokeGuardedCallback (react-dom.development.js:250)
at commitRoot (react-dom.development.js:19892)
at react-dom.development.js:21440
at Object.unstable_runWithPriority (scheduler.development.js:255)
at completeRoot (react-dom.development.js:21439)
at performWorkOnRoot (react-dom.development.js:21362)
at performWork (react-dom.development.js:21267)
at performSyncWork (react-dom.development.js:21241)
at requestWork (react-dom.development.js:21096)
at commitPassiveEffects (react-dom.development.js:19730)
at wrapped (scheduler-tracing.development.js:177)
at flushPassiveEffects (react-dom.development.js:19759)
at dispatchAction (react-dom.development.js:14041)
at Object.onChange (SpectrumChart.jsx:401)
at FullScreen.detectFullScreen (index.js:115)
requestFullscreen @ index.js:22
enterFullScreen @ index.js:122
handleProps @ index.js:108
componentDidUpdate @ index.js:98
commitLifeCycles @ react-dom.development.js:18124
commitAllLifeCycles @ react-dom.development.js:19668
callCallback @ react-dom.development.js:147
invokeGuardedCallbackDev @ react-dom.development.js:196
invokeGuardedCallback @ react-dom.development.js:250
commitRoot @ react-dom.development.js:19892
(anonymous) @ react-dom.development.js:21440
unstable_runWithPriority @ scheduler.development.js:255
completeRoot @ react-dom.development.js:21439
performWorkOnRoot @ react-dom.development.js:21362
performWork @ react-dom.development.js:21267
performSyncWork @ react-dom.development.js:21241
requestWork @ react-dom.development.js:21096
commitPassiveEffects @ react-dom.development.js:19730
wrapped @ scheduler-tracing.development.js:177
flushPassiveEffects @ react-dom.development.js:19759
dispatchAction @ react-dom.development.js:14041
onChange @ SpectrumChart.jsx:401
detectFullScreen @ index.js:115

When I use it with an image, the image seems to always be set on cover no matter what I set

First of all, great library. Thank you.

So I am trying to use it to display images, but no matter what I do I can get the image to be in a contain mode.
It either stretches, sticks to the top left or overflows. I just want it to be centered with its original ratio and showing fully.

Here's how I show the image:

        <Fullscreen enabled={isFull} onChange={isFull => setIsFull(isFull)}>
          <div className="image-full">
            <img src={image}  className="image-full__container"/>
          </div>
        </Fullscreen>

And that my css:

.image-full {
    display: block;
    object-fit: contain;
    margin: auto;

    &__container {
      position: relative;
      text-align: center;
      width: 100%;
      height: 100%;
    }
}

Getting Unhandled Rejection (TypeError): fullscreen error

Uncaught (in promise) TypeError: fullscreen error
at Object.requestFullscreen (fscreen.js:53)
at index.tsx:35
at HTMLUnknownElement.callCallback (react-dom.development.js:3945)
at Object.invokeGuardedCallbackDev (react-dom.development.js:3994)
at invokeGuardedCallback (react-dom.development.js:4056)
at invokeGuardedCallbackAndCatchFirstError (react-dom.development.js:4070)
at executeDispatch (react-dom.development.js:8243)
at processDispatchQueueItemsInOrder (react-dom.development.js:8275)
at processDispatchQueue (react-dom.development.js:8288)
at dispatchEventsForPlugins (react-dom.development.js:8299)
at react-dom.development.js:8508
at batchedEventUpdates$1 (react-dom.development.js:22396)
at batchedEventUpdates (react-dom.development.js:3745)
at dispatchEventForPluginEventSystem (react-dom.development.js:8507)
at attemptToDispatchEvent (react-dom.development.js:6005)
at dispatchEvent (react-dom.development.js:5924)

Unable to scroll in full screen mode

Hey, this plugin is super useful first off. Secondly, is it expected that overflow content cannot be scrolled when in full screen mode? I know that not allowing scrolling used to be part of the full screen spec but that has since changed iirc.

Shows black screen on full screen

After executing the sample code, it showed black screen in full screen with all browsers.
It works fine with clicking F11 button.

"dependencies": {
"next": "12.1.5",
"react": "18.0.0",
"react-dom": "18.0.0",
"react-full-screen": "^1.1.0"
},
"devDependencies": {
"eslint": "8.13.0",
"eslint-config-next": "12.1.5"
}

Need small clarification

Hi,

I am using reactfullscreen and it works great....

My doubt is I apply react-full-screen on a page that has large content. After I go into the fullscreen mode the content is cutoff and there is no scroll to even scroll to view the entire content in the full-screen mode.

Is this expected behavior like full screen doesn't have a scroll view and it can fit only limited content?

If I want a scroll in the full-screen is there any idea on how to achieve it?

Thank you for any help or info in advance

I'm getting an error in my console

I'm getting an error in my console.
Error:
Warning: Function components cannot be given refs. Attempts to access this ref will fail. Did you mean to use React.forwardRef()?

Typescript error: Type '{children: Element[]; handle: FullScreenHandle; onChange: (state: boolean) => void;}' is not assignable to type 'IntrinsicAttributes & FullScreenProps'

I believe this can be fixed by adding a simple children: React.ReactNode; to export interface FullScreenProps

// index.d.ts
import React from 'react';
export interface FullScreenHandle {
    active: boolean;
    enter: () => Promise<void>;
    exit: () => Promise<void>;
    node: React.MutableRefObject<HTMLDivElement | null>;
}
export interface FullScreenProps {
    handle: FullScreenHandle;
    onChange?: (state: boolean, handle: FullScreenHandle) => void;
    children: React.ReactNode;
    className?: string;
}
export declare function useFullScreenHandle(): FullScreenHandle;
export declare const FullScreen: React.FC<FullScreenProps>;

Is possible to Set full screen without pressing the button?

I tried for it by setting the default value to true in isFull variable. But it's not working. it returns **

Unhandled Rejection (TypeError): fullscreen error.

**
I tried more by changing the value after some time (setTimeout()). Has any idea? I want to run the application in full screen without user pressing F11.

Semi transparency at the top and bottom.

Hi,

when my app goes fullscreen, there is slight semi transparency at the top and bottom making tabs and other things partially visible. Is there any way to make the fullscreen fully opaque ( ie no transparencey ) ?
It is barely visible with white or black background color, but for example green or purple make it much more pronounced. The issue is very obvious with photo as background.

Thanks
Luke

Make it possible to await enter and exit

Enter fullscreen promise is let go in the facade's enter and exit methods, which mean you can not catch an error or await the event outside.

Return the promise out of the enter and exit functions.

Toast not appearing in full screen mode

I am using ANTD as my UI library and following are the issues I have encountered so far as I have just started using it

  • Toast notification are not appearing in the full screen mode.
  • Popovers too are not appearing in the full screen mode
  • Scrolling wasnt working but the workaround in #78 resolved it

Not able to set custom class on fullscreen

inside index.jsx

(this.node = node)} style={ this.props.enabled ? { height: "100%", width: "100%" } : undefined } > {this.props.children}

change above to

(this.node = node)} style={ this.props.enabled ? { height: "100%", width: "100%" } : undefined } > {this.props.children}

All onChange functions will be called for multiple Fullscreen elements when one is interacted with.

I have multiple video components on my webpage, each with a Fullscreen wrapper and an onChange event. Using the code example from the README, when one of these videos is clicked, all of the onChange events fire.

Another bug found that might be related to this is the Fullscreen component will create the fullscreen container and add the classes, however it doesn't resize the video or call the video's requestFullscreen method.

Besides that bug, when the video's minimize button is clicked all of the onClick handlers fire at once, and they all get the false isFull property, but as soon as the isFull state is updated another render cycle will call the onChange event and reset the camera to isFull=true, while the others get isFull=false.

To workaround the problem, I have to add code to check the fullscreen element via a class selector, and then determine if isFull is true and the fullscreen element is not found.

I should state that the exitFullscreen() code below just calls document.exitFullscreen();.

// This component is rendered 5 times with different camera info
export function Camera (props) {
  ...
  const [isFull, setIsFull] = useState();

  <Fullscreen 
          enabled={isFull}
          onChange={isFull => {
            // hack
            const fullscreenVideoElem = document.querySelector('.fullscreen-enabled > video');

            if (!isFull && fullscreenVideoElem && fullscreenVideoElem.id === camera.name) {
              exitFullScreen();
              setIsFull(isFull);
            } else if (isFull && !fullscreenVideoElem) {
              exitFullScreen();
              setIsFull(false);
            } else {
              setIsFull(isFull);
            }
          }}
        >

Here is a log of the maximize and minimize events for one camera click:

// CameraName isFull
Backyard false
Driveway false
Driveway 2 false
Hallway true <== maximizes hallway container, applies classes, does not make video full screen (bug)
Webcam false

This the the log for the minimize button click on the video:

Backyard false
Driveway false
Driveway 2 false
Hallway false <== minimizes hallway, calls setIsFull(false)
Webcam false
Backyard false <== re-render due to setIsFull() hook
Driveway false
Driveway 2 false
Hallway true <== this re-maximizes the hallway but doesn't apply fullscreen classes (good!)
Webcam false
Backyard false <== another render due to re-maximizing
Driveway false
Driveway 2 false
Hallway false <== my CSS selector hack forces the hallway to minimize again
Webcam false

Bug: Multiple onChange handlers are executed when one element is interacted with.

Expected results: Only the onChange event wrapping the selected element should be fired.

Actual results: All of the onChange events are fired multiple times, at least once per setState.

Two Fullscreen elements on a page do not work

If a page has two or more Fullscreen components then only the last one works.

<Fullscreen enabled={fullscreen} onChange={setFullScreen}>
    <div onClick={() => setFullScreen(!fullscreen)}>1</div>
</Fullscreen>
<Fullscreen enabled={fullscreen2} onChange={setFullScreen2}>
    <div onClick={() => setFullScreen2(!fullscreen2)}>2</div>
</Fullscreen>

Back button takes user to non-enabled state

I'm testing Fullscreen on a react app running on Android. I capture the hardware back button for navigation purposes. When Fullscreen is enabled the back button takes the user to the un-enabled state rather than to the previous screen. Is there anyway to prevent this?

componentDidMount() {
    window.onhashchange = this.onPageNavigate
  }

  onPageNavigate() {
    if (page !== this.state.page) {
       this.setState({page}) 
    }  
  }

Impossible to deploy in Class Component

-- [email protected]

Hi,

i follow your README but i've got when my React application start:
Uncaught Error: Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:

  1. You might have mismatching versions of React and the renderer (such as React DOM)
  2. You might be breaking the Rules of Hooks
  3. You might have more than one copy of React in the same app
    See https://fb.me/react-invalid-hook-call for tips about how to debug and fix this problem.

I'm really new to React.js; before posting an issue here, i checked some information to solve my problem but it seems i can't solve it.

  • it seems that there isn't react/reactdom mismatch ([email protected] / [email protected])
  • i only have one copy of react in the same app
  • i didn't really understood what React documentation said on Rules of Hooks but maybe this issue is related with the fact i use Class Component instead of function. Here's a partial copy of the class where i would like to use react-full-screen. Any help would be appeciatedd
import React, {useCallback}  from 'react';
import { FullScreen, useFullScreenHandle } from 'react-full-screen';


export default class Investigation extends React.Component {
	render(){
		const fsHandle = useFullScreenHandle();

		return (
			<div>
				<FullScreen handle={fsHandle}>
					<div id="investigation-fullscreen">
						<ul className="list-inline pull-right">
							<li className="list-inline-item"><a onClick={ this.arrangeItems.bind(this) } className="btn btn-default"><i className="fa fa-certificate"></i></a></li>
							<li className="list-inline-item"><a onClick={ this.centerView.bind(this) } className="btn btn-default"><i className="fa fa-street-view"></i></a></li>
							<li className="list-inline-item"><a onClick={fsHandle.enter} className="btn btn-default"><i className="fa fa-expand"></i></a></li>
						</ul>	
					</div>
					<div id="search-box">
					<input type="text" className="form-control search-control" placeholder="Search any element (Report, Indicator, Signature...)"/>				
					</div>
					<div id="investigation-content">
						<CytoscapeComponent cy={(cy) => { this.cy = cy }} layout={layout} minZoom={0.5} maxZoom={3} elements={elements} style={ { height:'80vh', width: '90vw', padding: '10px' } } />
					</div>
				</FullScreen>
			</div>
		);
	}
}

.enter and .exit resets a variable's state

When I call .enter or .exit the state of one of my variables is reset to its default state. Any idea how to stop this?

Update: I fixed this issue using a useRef and a. useEffect to watch the previous state of the variable and use that to update my variable accordingly.

I think the reason for the state resetting might be since I'm using React's createPortal for a modal image carousel on which I use this fullscreen package so it might not have been the package at all. When I console logged the variable upon entering the fullscreen api, its state was reset so I just added an if statement to signal out this condition and give me the expected result while also adding a state update after calling .enter() to update the variable based on the useRef's previous value that I needed to stay consistent and not reset.

fix: fullscreen mode is reset, when new API request has been sent within the fullscreen

Hi all ๐Ÿ‘‹ I have encountered with a problem, while injecting your package into my company project. The problem can be observed in the first attached video. Actually, if there is no state update in my component, your package's interface works perfectly well as can be seen in the second attached video, i.e., either using exit-full-screen button or pressing Esc key when in full screen mode do the job. However, changing date for example forces full screen mode to be exited, which is undesirable for my application. I want the full screen mode to be kept in active even if state update occurs. Below, you can see the code snippets where and how I used your package interface within my component file:

// STEP I: import required hook and wrapper component
import { FullScreen, useFullScreenHandle } from 'react-full-screen'
...

// STEP II: extract "handle" variable out of the hook
const handle = useFullScreenHandle()
...

// STEP III: make API call to the service using RTK Query
const {
    data,
    isLoading: dataLoading,
    isFetching: dataFetching,
  } = service(
    {
      assetId: Number(assetId),
      from: watchDate && watchDate[0],
      to: watchDate && watchDate[1],
      clientId,
    },
    { skip: shouldSkip },
  )
...

// STEP IV: define handler function which will be triggered, when pressing either `full-screen` or `exit-full-screen` button
const handleToggleChartViewState = useCallback(() => {
    if (!handle.active) {
      handle.enter()
    } else {
      handle.exit()
    }
  }, [handle.active])
...

// STEP V: wrap required slice of UI component with `FullScreen` component and pass `handle` to it as `handle={handle}`
<FullScreenStyled handle={handle} $isFullScreenActive={handle.active}>
    {children}
</FullScreenStyled>
// where `FullScreenStyled` is a styled component which is styled based on `FullScreen` component that your package provides
...

// STEP VI: pass above handler function to Button component to control exiting and/or entering from/to full screen mode
<Button
    icon={{
        icon: handle.active ? 'exit-full-screen' : 'full-screen',
        size: 14,
        color: 'darkblue900',
    }}
    onClick={handleToggleChartViewState}
    variant="text"
 />

I am using react-hook-form to control my form inputs' behavior and in this component, my DateRangeSelector component is wrapped with Controller component, which is provided by react-hook-form package. DateRangeSelector in this context is the component that you can select Start and End dates for displaying the graph content. When changing Start and/or End date(s), API call in STEP III will be resent to the service.

I hope I can state my problem as much as possible and it will be clear for you guys. Still, in case of need for more detail, please contact me via my GitHub account.

React must be a peerDependency

@snakesilk

github seems down... and could not fork an make a P/R

But since you support v16.x you should add react as a peerDependency in your package.json

As an example:

  "peerDependencies": {
    "react": "^15.6 || ^16",
    "react-dom": "^15.6 || ^16"
  }

This will prevent issues when bundling (duplicates...)

Thanks

toggle fullscreen

Is there a way to toggle to enter/exit fullscreen on click?

I tried handle.enter ? handle.exit : handle.enter onClick for an image but it didn't work.

Maybe provide a method for this. Thank you.

Unable to use Fullscreen when on other component

I have the following code:

function Home() {
  const handleFullscreen = useFullScreenHandle();
  
  function RenderFullscreen() {
      return (
        <FullScreen handle={handleFullscreen} onChange={reportChange}>
          <iframe src={current} />
          <CloseButton />
        </FullScreen>
      );
    }

  return   (
        <>
            <RenderFullscreen />
             <Button onClick={handleFullscreen.enter}>
                  Fullscreen
            </Button>
        </>
   );
}

When i click at the 'fullscreen' button, the page just blinks at fullscreen and turns back to non fullscreen page.
Any idea how to solve this?

Not working in IPhone

hi guys
const handle = useFullScreenHandle();
handle.enter() is working with fullscreen
but If I call handle.exit(), page refershed
Could you have solution?

Support for desktop and iPad Safari

I really like the simplicity and cleanliness of this library over using Screenfull. Is there any chance of expanding this package to support Safari on desktop?

Using full screen in Material UI components

HI, I am using material ui. There seems to be some issue with material ui select options such that the options do not show on full screen maybe because the options are rendered outside the container element in the dom. I know this is something related to material ui and not this library but I was wondering if anyone faced this issue and was able to resolve it?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.