All Projects → yaseng → Jquery.barrager.js

yaseng / Jquery.barrager.js

专业的网页弹幕插件

Projects that are alternatives of or similar to Jquery.barrager.js

Instagram Clone
An Instagram-clone with my own flavors and features. Own the project with 5 simple steps!! 📸💝☢️
Stars: ✭ 479 (-17.84%)
Mutual labels:  jquery
Ajax Datatables Rails
A wrapper around DataTable's ajax methods that allow synchronization with server-side pagination in a Rails app
Stars: ✭ 520 (-10.81%)
Mutual labels:  jquery
Bootstrap Fileinput
An enhanced HTML 5 file input for Bootstrap 5.x/4.x./3.x with file preview, multiple selection, and more features.
Stars: ✭ 5,097 (+774.27%)
Mutual labels:  jquery
Domjudge
DOMjudge programming contest jury system
Stars: ✭ 484 (-16.98%)
Mutual labels:  jquery
Intercooler Js
Making AJAX as easy as anchor tags
Stars: ✭ 4,662 (+699.66%)
Mutual labels:  jquery
Responsive Tabs
Responsive Tabs is a jQuery plugin that provides responsive tab functionality. The tabs transform to an accordion when it reaches a CSS breakpoint. You can use this plugin as a solution for displaying tabs elegantly on desktop, tablet and mobile.
Stars: ✭ 529 (-9.26%)
Mutual labels:  jquery
Bugcatcher
方便产品、开发、测试三方协同管理、测试、监控项目进度和质量,以持续交付。
Stars: ✭ 472 (-19.04%)
Mutual labels:  jquery
Cash
An absurdly small jQuery alternative for modern browsers.
Stars: ✭ 5,714 (+880.1%)
Mutual labels:  jquery
Jquery Cropper
A jQuery plugin wrapper for Cropper.js.
Stars: ✭ 516 (-11.49%)
Mutual labels:  jquery
Cheerio
Fast, flexible, and lean implementation of core jQuery designed specifically for the server.
Stars: ✭ 24,616 (+4122.3%)
Mutual labels:  jquery
Jquery.thailand.js
ตัวช่วยกรอกที่อยู่ที่ดีที่สุดในไทย ไม่ต้องใช้ Server Side!
Stars: ✭ 490 (-15.95%)
Mutual labels:  jquery
Fe Interview Questions
目前最全的前端开发面试题及答案
Stars: ✭ 502 (-13.89%)
Mutual labels:  jquery
Paroller.js
Parallax scrolling jQuery plugin
Stars: ✭ 535 (-8.23%)
Mutual labels:  jquery
Jtsage Datebox
A multi-mode date and time picker for Bootstrap (3&4), jQueryMobile, Foundation, Bulma, FomanticUI, and UIKit (or others)
Stars: ✭ 481 (-17.5%)
Mutual labels:  jquery
Headless Chrome Crawler
Distributed crawler powered by Headless Chrome
Stars: ✭ 5,129 (+779.76%)
Mutual labels:  jquery
Cfviz
Visualizes user data from codeforces.com using the official API
Stars: ✭ 472 (-19.04%)
Mutual labels:  jquery
Jquery.sumoselect
A jQuery Single/Multi Select plugin which can be used on almost any device
Stars: ✭ 527 (-9.61%)
Mutual labels:  jquery
Form
jQuery Form Plugin
Stars: ✭ 5,122 (+778.56%)
Mutual labels:  jquery
Gray
Make an image grayscale in all browsers
Stars: ✭ 568 (-2.57%)
Mutual labels:  jquery
Force Js
The easy way to scroll and animate your page
Stars: ✭ 536 (-8.06%)
Mutual labels:  jquery

jquery.barrager.js 专业的网页弹幕插件

基本信息

名称 jquery.barrager.js
版本 1.1
项目主页 http://yaseng.github.io/jquery.barrager.js
下载 https://github.com/yaseng/jquery.barrager.js
github https://github.com/yaseng/jquery.barrager.js

demo_1

Jquery.barrager.js 是一款优雅的网页弹幕插件,支持显示图片,文字以及超链接。支持速度、高度、颜色、数量等自定义。能轻松集成到论坛,博客等网站中。

使用

发布弹幕

弹幕文字必选,图片,链接为空则不显示,其他的可选项有默认值,弹幕具体配置如下代码。

var item={
   img:'static/heisenberg.png', //图片 
   info:'弹幕文字信息', //文字 
   href:'http://www.yaseng.org', //链接 
   close:true, //显示关闭按钮 
   speed:8, //延迟,单位秒,默认8
   bottom:70, //距离底部高度,单位px,默认随机 
   color:'#fff', //颜色,默认白色 
   old_ie_color:'#000000', //ie低版兼容色,不能与网页背景相同,默认黑色 
 }
$('body').barrager(item);

清除所有弹幕

 $.fn.barrager.removeAll();

兼容低版本ie

ie 浏览器小于9不兼容css 圆角,采用兼容样式,可单独设置弹幕的颜色,属性为old_ie_color,建议不要与网页主背景色相同。 兼容模式效果图

ie

集成

通用后端

读取服务端有两种模式,适应于不同的场景

  1. 实时读取,隔x秒请求一次接口,获取一条弹幕,发送。
  2. 一次读取完毕,隔x秒发送一条弹幕。

注意:json数据需要HTML 实体化以防止xss攻击。

第一种模式示范代码 server 端(php)

<?php 
//数组里面可以自定义弹幕的所有属性。
$barrages=
array(
	array(
		'info'   => '第一条弹幕',
		'img'    => 'static/img/heisenberg.png',
		'href'   => 'http://www.yaseng.org',

		),
	array(
		'info'   => '第二条弹幕',
		'img'    => 'static/img/yaseng.png',
		'href'   => 'http://www.yaseng.org',
		'color'  =>  '#ff6600'

		),
	array(
		'info'   => '第三条弹幕',
		'img'    => 'static/img/mj.gif',
		'href'   => 'http://www.yaseng.org',
		'bottom' => 70 ,

		),
	array(
		'info'   => '第四条弹幕',
		'href'   => 'http://www.yaseng.org',
		'close'  =>false,

		),

	);
	
//随机输出一个 
echo  json_encode($barrages[array_rand($barrages)]);

浏览器端获取json 弹幕数据,setInterval 调用,如有弹幕,就显示。 代码如下

//每条弹幕发送间隔
var looper_time=3*1000;
//是否首次执行
var run_once=true;
do_barrager();

function do_barrager(){
  if(run_once){
      //如果是首次执行,则设置一个定时器,并且把首次执行置为false
      looper=setInterval(do_barrager,looper_time);                
      run_once=false;
  }
  //获取
  $.getJSON('server.php?mode=1',function(data){
      //是否有数据
      if(data.info){

           $('body').barrager(data);
      }

  });
}

效果如图 demo_3

第二种模式示范代码。 server 端 (php)

	//数组里面可以自定义弹幕的所有属性。
$barrages=
array(
	array(
		'info'   => '第一条弹幕',
		'img'    => 'static/img/heisenberg.png',
		'href'   => 'http://www.yaseng.org',

		),
	array(
		'info'   => '第二条弹幕',
		'img'    => 'static/img/yaseng.png',
		'href'   => 'http://www.yaseng.org',
		'color'  =>  '#ff6600'

		),
	array(
		'info'   => '第三条弹幕',
		'img'    => 'static/img/mj.gif',
		'href'   => 'http://www.yaseng.org',
		'bottom' => 70 ,

		),
	array(
		'info'   => '第四条弹幕',
		'href'   => 'http://www.yaseng.org',
		'close'  =>false,

		),

	);


echo   json_encode($barrages);

浏览器端

$.ajaxSettings.async = false;
$.getJSON('server.php?mode=2',function(data){

//每条弹幕发送间隔
var looper_time=3*1000;
var items=data;
//弹幕总数
var total=data.length;
//是否首次执行
var run_once=true;
//弹幕索引
var index=0;
//先执行一次
barrager();
function  barrager(){

 
  if(run_once){
      //如果是首次执行,则设置一个定时器,并且把首次执行置为false
      looper=setInterval(barrager,looper_time);                
      run_once=false;
  }
  //发布一个弹幕
  $('body').barrager(items[index]);
  //索引自增
  index++;
  //所有弹幕发布完毕,清除计时器。
  if(index == total){

      clearInterval(looper);
      return false;
  }

  


}


});

效果如图 demo_2

Discuz

discuz 弹幕插件是一款基于discuz 论坛专业的弹幕插件,使用弹幕显示帖子,回复,指定内容等,为论坛带来更多的趣味和互动性。支持速度、高度、颜色、数量等自定义,兼容各种主流浏览器 。 插件地址: http://addon.discuz.com/[email protected]_barrager.plugin

WordPress

jquery.barrager.js WordPress集成 http://yaseng.org/jquery-barrager-js-for-wordpress.html

hexo

jquery.barrager.js hexo 集成 http://yaseng.org/jquery-barrager-js-for-hexo.html

版本更新

1.0

实现弹幕功能

1.1

1.更改弹幕动画方案,再多弹幕也不会卡了。

2.修正弹幕运行范围。

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].