1.0.11 • Published 1 year ago

react-video-zoom v1.0.11

Weekly downloads
-
License
ISC
Repository
github
Last release
1 year ago

react-video-zoom

Overview

React component for magnifying glass circle on a video when hovering.

Demo

Demo

Install

npm install react-video-zoom --save

Usage

import {
  ReactVideoZoom,
  pauseReactVideoZoom,
  playReactVideoZoom,
} from "react-video-zoom";
import { useRef } from "react";
import VideoPath from "./test_video.mp4";

function App() {
    const mainVideoRef = useRef<HTMLVideoElement>(null);
    const zoomVideoRef = useRef<HTMLVideoElement>(null);

    const refs = { mainVideoRef, zoomVideoRef };

    return (
        <>
            <ReactVideoZoom
                src={VideoPath}
                zoom={zoom}
                refs={refs}
                width={1000}
                loop
                muted
            />
            <div onClick={() => playReactVideoZoom(refs)}>Play</div>
            <div onClick={() => pauseReactVideoZoom(refs)}>Pause</div>
        </>
    )
}

Properties of <ReactVideoZoom /> component

PropertyTypeIs requiredDescription
srcstringRequredSource of the video
zoomnumberRequredMagnification value
refsReactVideoZoomRefsRequredObject of React ref objects
widthnumberOptionalWidth of the video in pixels
loopbooleanOptionalWhen true, video will play on loop
mutedbooleanOptionalWhen true, video will be muted

playReactVideoZoom(refs) and pauseReactVideoZoom(refs) playback control functions

The package also exports 2 playback control functions for playing and pausing the videos in sync. Object refs of type ReactVideoZoomRefs must be passed as an argument to both of them.

ReactVideoZoomRefs type

The refs object that is passed to <ReactVideoZoom /> component and playback control functions must be of the following type:

type ReactVideoZoomRefs = {
  mainVideoRef: React.RefObject<HTMLVideoElement>;
  zoomVideoRef: React.RefObject<HTMLVideoElement>;
};
1.0.11

1 year ago

1.0.10

1 year ago

1.0.9

1 year ago

1.0.8

1 year ago

1.0.7

1 year ago

1.0.6

1 year ago

1.0.5

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago