Git Product home page Git Product 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.

import Fullscreen from "react-full-screen";

* Setup and render.

import React, { Component } from "react";
import Fullscreen from "react-full-screen";

class App extends Component {
  constructor(props) {
    super();

    this.state = {
      isFull: false,
    };
  }

  goFull = () => {
    this.setState({ isFull: true });
  }

  render() {
    return (
      <div className="App">
        <button onClick={this.goFull}>
          Go Fullscreen
        </button>

        <Fullscreen
          enabled={this.state.isFull}
          onChange={isFull => this.setState({isFull})}
        >
          <div className="full-screenable-node">
            Hi! This may cover the entire monitor.
          </div>
        </Fullscreen>
      </div>
    );
  }
}

export default App;

It is not possible to start in Fullscreen. Fullscreen must be enabled from a user action such as onClick.

The reason for keeping track of the current state outside of the component is that the user can choose to leave full screen mode without the action of your application. This is a safety feature of the Fullscreen API.

Props

enabled boolean

Set to true when component should go fullscreen.

onChange function

Optional callback that gets called when state changes.

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

pomle avatar dlindenkreuz avatar

Watchers

Sébastien Vanvelthem avatar James Cloos avatar  avatar

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.