GithubHelp home page GithubHelp logo

biu.js's Introduction

biu.js

一个弹幕js.🔫

How to use

In a browser:

<script src="biu.min.js"></script>
var anime = new Biu.anime();
var biu = new Biu({
  name: 'biubiu',
  socket: location.protocol + '//' + location.hostname + (location.port ? ':'+location.port : '') ,
  onMessage:(data)=>{
    anime.run(data)
  }
});

Using npm:

npm i --save biujs
import Biu from 'biujs';

var anime = new Biu.anime();
var biu = new Biu({
  name: 'biubiu',
  socket: location.protocol + '//' + location.hostname + (location.port ? ':'+location.port : '') ,
  onMessage:(data)=>{
    anime.run(data)
  }
});

Biu 用来接收服务端消息,Biu.anime 是一个动画扩展,你可以直接使用,如果不满足你的需求,也可以在 onMessage 里自己写。

Biu

配置项

name:在服务端申请的项目名称,实际对应 socket.io 中的一个 namespace

socket:服务端地址

onConnect:连接成功时的回调

onMessage:接收消息时的回调

方法

open:连接ws,实例化时自动调用

stop:关闭

send:发送消息,接收 string 或者 object 的参数,object时一定要有text字段(弹幕内容)

Biu.anime

colors:弹幕颜色,接收一个数组,默认值:['#f55b15', '#764ba5', '#00a762', '#0193e6', '#e0463c']

maxDuration:弹幕最大时间

minDuration:弹幕最小时间(每个弹幕会在最大最小时间中取一个随机值)

方法

run:显示弹幕

show:显示

hide:隐藏

biu.js's People

Contributors

zhengqingxin avatar

Stargazers

wuyan avatar

Watchers

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.