1.0.3 • Published 5 years ago

react-video-pop v1.0.3

Weekly downloads
391
License
MIT
Repository
github
Last release
5 years ago

react-video-pop

Build Status

Table Of Contents

Introduction

Floating video component made in react , which is draggable across any coordinate of the screen and resizable too. The working is inspired from the MacOS picture to picture feature.

Installation

npm install --save react-video-pop

Usage

Inside HTML file

<!DOCTYPE html>
<html>
    <head>
    </head>
    <body>
        <!-- the div where your react DOM renders everything -->
        <div id="root"></div>
        <!-- the div which will render floating video -->
        <div id='video-root'></div>
    </body>
</html>

Inside your js

import React, { Component } from 'react';
import Scene from '../assets/devstories.webm';
import VideoPop from 'react-video-pop';

export default class App extends Component {
    render() {
        return (
            <VideoPop Src={Scene} mute={true} autoplay={true}   root="video-root" ratio={{w:16,h:9}} />
        );
    }
}

API

PropDescriptionTypeDefault Value
SrcRequired. A unique string to identify the component.stringnull
PosterApply the thumbnail image over video before playingstringnull
autoplayautoplay the video on render.booleantrue
mutemute the video before render.booleanfalse
durationVideo duration (in seconds).int0
rootRequired. Portal div element id attributestringnull
ratioRequired. Aspect ratio of the video src.object{w:16,h:9}

Demo

Basic Demo

How does it work

The floating video element is made using the react portal api. Where when the user scrolls down to cenrtain limit the portal element gets rendered, following the ongoing video stream. The rest drag and drop animation on the floating video element is done with requestAnimationFrame API using the spring constant formula.

Development

In source folder:

npm run start
npm link

In project:

npm link react-video-pop

License

MIT

1.0.3

5 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago