npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

react-drive-in2

v1.8.1

Published

React component supporting background videos and playlists.

Downloads

45

Readme

React Drive-In

npm release

A wicked awesome replacement for BigVideo.js that is lighter with fewer dependencies. It does not use jQuery, video.js, or any other large libraries. Only 5k minified and gzipped. This React component is a wrapper over the core Drive-In lib.

Demo and some example functionality here: github.io

Created by Ronik Design.

Install

So easy. React is the only required peer dependency: React.

  • Using NPM
  $ npm install --save-dev react-drive-in

Usage

  • The easiest example
  const React = require("react");
  const ReactDOM = require("react-dom");
  const ReactDriveIn = require("react-drive-in");

  ReactDOM.render(
    <ReactDriveIn
      show="http://raw.githubusercontent.com/ronik-design/react-drive-in/master/example/glacier.mp4"
      poster="http://raw.githubusercontent.com/ronik-design/react-drive-in/master/example/glacier.jpg"
    />,
    $mountNode
  );
  • More complex
  const React = require("react");
  const ReactDOM = require("react-dom");
  const ReactDriveIn = require("react-drive-in");

  const PLAYLIST = [
    [
      "https://github.com/ronik-design/react-drive-in/blob/master/example/pelo.mp4?raw=true",
      "https://github.com/ronik-design/react-drive-in/blob/master/example/pelo.ogv?raw=true",
      "https://github.com/ronik-design/react-drive-in/blob/master/example/pelo.jpg?raw=true"
    ],
    [
      "https://github.com/ronik-design/react-drive-in/blob/master/example/kaledo.mp4?raw=true",
      "https://github.com/ronik-design/react-drive-in/blob/master/example/kaledo.ogv?raw=true",
      "https://github.com/ronik-design/react-drive-in/blob/master/example/kaledo.jpg?raw=true"
    ],
    [
      "http://raw.githubusercontent.com/ronik-design/react-drive-in/master/example/glacier.mp4",
      "http://raw.githubusercontent.com/ronik-design/react-drive-in/master/example/glacier.ogv",
      "http://raw.githubusercontent.com/ronik-design/react-drive-in/master/example/glacier.jpg"
    ]
  ];

  const onPlaying = function(itemNum) {};
  const onPause = function() {};

  ReactDOM.render(
    <ReactDriveIn
      showPlaylist={playlist}
      onPlaying={onPlaying}
      onPause={onPause}
      loop
      mute
    />,
    $mountNode
  );
  • Sample bundling script for the browser using rollup.js:
import babel from "rollup-plugin-babel";
import npm from "rollup-plugin-npm";
import commonjs from "rollup-plugin-commonjs";
import replace from "rollup-plugin-replace";

export default {
  entry: "lib/main.jsx",
  plugins: [
    replace({ "process.env.NODE_ENV": JSON.stringify("production") }),
    npm({ jsnext: true, main: true }),
    commonjs(),
    babel()
  ],
  dest: "dist/bundle.js",
  moduleName: "MyBundle",
  format: "iife"
};

What to show

The show and showPlaylist properties have many options. See example/index.html for an fairly complex set up.

  • show is for SINGLE ITEMS. You can provide either a string, or a fallback array (e.g., [ "video.mp4", "video.ogv", "video.jpg" ]).
  • showPlaylist is for MULTIPLE ITEMS. You can provide either an array or strings (e.g., [ "video1.mp4", "video2.mp4" ]) or an array of fallback arrays (e.g., [ [ "video1.mp4", "video1.ogv" ], [ "video2.mp4", "video2.ogv" ])

Details

The HTML structure of this element looks like:

  <div id="drive-in-wrap">
    <div class="drive-in-media">
      <video> OR <img>
    </div>
  </div>

The included CSS sets up some required styles for it to function correctly.

The component falls back to using an image on touch devices, since many will not play video inline. Thus, you might want to specify fallback images either through the poster property or in the fallback arrays.

Formats

The component currently understands and supports, mp4, ogv, webm, jpg, gif, png.

Component API

<Video> component:

Property | Type | Default | Required | Description -------- | ---- | ------- | -------- |----------- show | String,Array | none | no | The video or video fallback array to show. showPlaylist | Array | none | no | An array of video URL strings, or of video fallback arrays. play | Number | none | no | Similar to show but used to play a video at a given index in the showPlaylist array. paused | Boolean | false | no | Set the playlist to a paused state on initial load. poster | String | none | no | A fallback image to use, when all else fails. mute | Boolean | true | no | Should the videos be played muted? loop | Boolean | true | no | Should videos / playlists loop or begin again when finished? loopPlaylistItems | Boolean | false | no | Individual playlist videos will loop, rather than the whole list itself. slideshow | Boolean | false | no | Force the component to display fallback images / poster rather than videos. onPlaying | Function | null | no | Register a callback for when the video / slideshow starts playing. onPause | Function | null | no | Register a callback for when the video / slideshow is paused. onTime | Function | null | no | Emits regular time-tracking events from Drive-In lib with current media item play position. onTimeFrequency | Number | 500 | no | Frequency at which to emit time-tracking events. onCanPlay | Function | null | no | Callback for when a loaded media item can play. playbackRate | Number | 1.0 | no | Adjust the playback rate of videos. Per the HTML5 video method. isTouch | Function | null | no | Provide a custom function for touch detection

Developing

You can clone this repo and then:

$ npm install
$ npm run develop

This will install all dev dependencies, let you watch sources and run a dev server.

License

See the License file.

Credit