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

@my-videojs/videojs-drag-middleware

v1.1.1

Published

videojs的拖拽控制中间件

Downloads

2

Readme

拖拽控制


videojs的拖拽控制中间件(videojs6+)

何时使用

  • 需要给videojs播放器控制其拖拽的时候

浏览器支持

IE 9+

安装

npm install @my-videojs/videojs-drag-middleware --save

运行

# 默认开启服务器,地址为 :http://local:8000/

# 能在ie9+下浏览本站,修改代码后自动重新构建,且能在ie10+运行热更新,页面会自动刷新
npm run start

# 构建生产环境静态文件,用于发布文档
npm run site

代码演示

基本

控制videojs的拖拽

import videojs from 'video.js'
import 'video.js/dist/video-js.css'
import "@my-videojs/videojs-drag-middleware/lib"

class App extends React.Component {
  componentDidMount () {
    const node = ReactDOM.findDOMNode(this.videoWrap)
    if (!node) {
      return
    }
    const videoJsOptions = {
      controls: true,
      dragMode: 'backward', // 只能快退
      sources: [{
        src: '//gcdncs.101.com/v0.1/static/fish/media/ocean.mp4',
        type: 'video/mp4'
      }],
      dragMode: 'backward' // 只能快退
    }
    // react0.14.x data-reactid问题
    const videoEl = document.createElement('video')
    videoEl.className = `video-js`

    node.appendChild(videoEl)
    this.player = videojs(videoEl, {...videoJsOptions}, () => {
      // this.player.drag()
    })
  }
  componentWillUnmount () {
    if (this.player) {
      this.player.dispose()
    }
  }
  setDragTime = () => {
    if (this.player) {
      console.log(this.input.value)
      this.player.dragTime = parseInt(this.input.value) || 0
    } else {
      alert('播放器未初始化完成!')
    }
  }
  render() {
    return (
      <div>
        <div data-vjs-player ref={node => { this.videoWrap = node }} />
        <br />
        <input ref={node => this.input = node} />
        <button onClick={this.setDragTime}>动态设置可拖拽时间</button>
      </div>
    )
  }
}

ReactDOM.render(<App />, mountNode);

API

| 参数 | 说明 | 类型 | 默认值 | | --- | --- | --- | --- | | dragTime | 拖动起始时间(秒) | number | 无 | | dragMode | 拖动模式,分为不能拖动,不能快进,不传表示无限制。可以和dragTime配合使用,具体可以见上面例子说明 | enum{'backword', 'disabled'} | 无 |