Skip to content

Commit 0b230b6

Browse files
committed
Update from master
2 parents e3b167f + 35dd341 commit 0b230b6

10 files changed

Lines changed: 170 additions & 51 deletions

File tree

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
language: node_js
2+
sudo: false
23
node_js:
34
- "0.10"
45
before_install:

build/CommentCoreLibrary.js

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1168,7 +1168,7 @@ function CommentFilter(){
11681168
* Comment Core Library CommentManager
11691169
* @license MIT
11701170
* @author Jim Chen
1171-
*
1171+
*
11721172
* Copyright (c) 2014 Jim Chen
11731173
*/
11741174
var CommentManager = (function() {
@@ -1193,7 +1193,7 @@ var CommentManager = (function() {
11931193
}
11941194
return "matrix3d(" + matrix.join(",") + ")";
11951195
};
1196-
1196+
11971197
function CommentManager(stageObject){
11981198
var __timer = 0;
11991199
this._listeners = {};
@@ -1330,30 +1330,35 @@ var CommentManager = (function() {
13301330
};
13311331
CommentManager.prototype.init = function(){
13321332
this.setBounds();
1333-
if(this.filter == null)
1333+
if(this.filter == null) {
13341334
this.filter = new CommentFilter(); //Only create a filter if none exist
1335+
}
13351336
};
13361337
CommentManager.prototype.time = function(time){
13371338
time = time - 1;
13381339
if(this.position >= this.timeline.length || Math.abs(this.lastPos - time) >= 2000){
13391340
this.seek(time);
13401341
this.lastPos = time;
1341-
if(this.timeline.length <= this.position)
1342+
if(this.timeline.length <= this.position) {
13421343
return;
1344+
}
13431345
}else{
13441346
this.lastPos = time;
13451347
}
13461348
for(;this.position < this.timeline.length;this.position++){
1347-
if(this.options.limit > 0 && this.runline.length > this.limiter) break;
1348-
if(this.validate(this.timeline[this.position]) && this.timeline[this.position]['stime']<=time){
1349-
this.send(this.timeline[this.position]);
1349+
if(this.timeline[this.position]['stime']<=time){
1350+
if(this.options.limit > 0 && this.runline.length > this.limiter) {
1351+
continue; // Skip comments but still move the position pointer
1352+
} else if(this.validate(this.timeline[this.position])){
1353+
this.send(this.timeline[this.position]);
1354+
}
13501355
}else{
13511356
break;
13521357
}
13531358
}
13541359
};
13551360
CommentManager.prototype.rescale = function(){
1356-
1361+
13571362
};
13581363
CommentManager.prototype.send = function(data){
13591364
if(data.mode === 8){

build/CommentCoreLibrary.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build/scripting/Host.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -900,9 +900,9 @@ var CCLScripting = function(workerUrl){
900900
cG = Math.floor((filter.params.color % 65536)/256),
901901
cB = filter.params.color % 256;
902902
var cMatrix = [
903-
0,0,0,cR,0,
904-
0,0,0,cG,0,
905-
0,0,0,cB,0,
903+
0,0,0,cR/256,0,
904+
0,0,0,cG/256,0,
905+
0,0,0,cB/256,0,
906906
0,0,0,1,0,
907907
];
908908
dFilter.appendChild(__("feColorMatrix",{

build/style.css

Lines changed: 30 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,55 @@
1-
.abp{
2-
position:relative;
1+
.abp {
2+
position: relative;
33
}
4-
.abp .container{
5-
-webkit-transform: matrix3d(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);
6-
transform: matrix3d(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);
7-
position: absolute;
8-
display: block;
9-
overflow: hidden;
10-
margin: 0;
4+
5+
.abp .container {
116
border: 0;
12-
top: 0;
13-
left: 0;
147
bottom: 0;
8+
display: block;
9+
left: 0;
10+
margin: 0;
11+
overflow: hidden;
12+
position: absolute;
1513
right: 0;
16-
z-index: 9999;
14+
top: 0;
1715
touch-callout: none;
16+
-webkit-transform: matrix3d(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1);
17+
transform: matrix3d(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1);
1818
-webkit-user-select: none;
1919
-moz-user-select: none;
2020
-ms-user-select: none;
2121
user-select: none;
22+
z-index: 9999;
2223
}
23-
.abp .container .cmt{
24-
-webkit-transform: matrix3d(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);
25-
transform: matrix3d(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);
26-
-webkit-transform-origin: 0% 0%;
27-
-ms-transform-origin: 0% 0%;
28-
transform-origin: 0% 0%;
29-
position: absolute;
30-
padding: 3px 0 0 0;
31-
margin: 0;
24+
25+
.abp .container .cmt {
3226
color: #fff;
3327
font-family: SimHei, SimSun, Heiti, "MS Mincho", "Meiryo", "Microsoft YaHei", monospace;
3428
font-size: 25px;
29+
letter-spacing: 0;
30+
line-height: 100%;
31+
margin: 0;
32+
padding: 3px 0 0 0;
33+
position: absolute;
3534
text-decoration: none;
3635
text-shadow: -1px 0 black, 0 1px black, 1px 0 black, 0 -1px black;
3736
-webkit-text-size-adjust: none;
3837
-ms-text-size-adjust: none;
3938
text-size-adjust: none;
40-
line-height: 100%;
41-
letter-spacing: 0;
42-
word-break: keep-all;
39+
-webkit-transform: matrix3d(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1);
40+
transform: matrix3d(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1);
41+
-webkit-transform-origin: 0% 0%;
42+
-ms-transform-origin: 0% 0%;
43+
transform-origin: 0% 0%;
4344
white-space: pre;
44-
45+
word-break: keep-all;
4546
}
46-
.abp .container .cmt.noshadow{
47+
48+
.abp .container .cmt.noshadow {
4749
text-shadow: none;
4850
}
49-
.abp .container .cmt.rshadow{
51+
52+
.abp .container .cmt.rshadow {
5053
text-shadow: -1px 0 white, 0 1px white, 1px 0 white, 0 -1px white;
5154
}
5255

build/style.min.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/CommentManager.md

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,95 @@
55

66
### options &lt;Object&gt;
77
此处用于放置弹幕默认参数等.
8+
9+
* global
10+
* `opacity` 透明度
11+
* `scale` 生命时间加成(TTL Scale)
12+
* `className` CSS类名(非CSS呈现模式下也可能会参考此项进行呈现)
13+
* scroll
14+
* `opacity` 透明度
15+
* `scale` 生命时间加成(TTL Scale)
16+
* `limit` 最大显示弹幕数量,0或以下表示不限制同屏弹幕数量
17+
18+
### isRunning &lt;Bool&gt;
19+
管理器的弹幕是否在运行。`false`表示没有在运行,`true`表示在运行。可以通过 start/stop 控制。这
20+
个参数只反映运行列表里面弹幕的运行状态,而不是视频的。
21+
22+
### width &lt;Number&gt;
23+
舞台的长度像素值,用于计算弹幕位置。此数只有在 init 之后才有效。
24+
25+
### height &lt;Number&gt;
26+
舞台的高度像素值,用于计算弹幕位置。此数只有在 init 之后才有效。
27+
28+
## Methods 方法
29+
30+
### init()
31+
初始化弹幕管理器并初次绑定舞台大小。注意:`init`调用时请确保弹幕舞台对象可以访问,并且已经实例化和
32+
可测大小。如果在动态的构成组件,只要保证在调用 `init()` 时舞台返回的大小数据正确即可。
33+
34+
初始化管理器默认播放状态是未播放,需要单独通过 `start()` 启用
35+
36+
### start()
37+
启动弹幕老化进程。调用后 `send()` 发送到运行列表(runline)的弹幕会开始移动。用于在刚刚
38+
`init()` 之后进入播放状态,或者在暂停弹幕后重新开始移动弹幕。播放时调用无作用。
39+
40+
注意:在播放状态未非播放时,调用 `send()`发送的弹幕会加入 runline,在start之后一并开始移动。
41+
有时这种表现是你不希望的,可以通过 `clear()` 清除运行列表。
42+
43+
### stop()
44+
暂停弹幕。运行中的弹幕将会暂停,不回被清除。暂停时调用无作用。
45+
46+
注意:stop不会停止 `time` 方法的调用,所以在实现暂停时应配合停止 time 调用,否则下次启动时停止
47+
期间的弹幕会一并开始移动。
48+
49+
### clear()
50+
清除舞台。清除正在运行的管理器管辖内的所有弹幕(runline里的)。
51+
不清除 timeline。不保证能清除代码弹幕(因为是另一个独立的系统)。
52+
53+
### time(currentTime:Number)
54+
通报目前的时间轴时间。管理器会自动处理时间前进和后退的情况,包括在需要时清除屏幕上正再运行的弹幕。
55+
这里的currentTime是绝对时间,对应弹幕的 stime。时间单位是毫秒(ms)。time只会把相关的弹幕放到
56+
runline(运行列表)里,至于这些弹幕是否在移动,则要根据目前管理器的 isRunning 状态。
57+
58+
### load(timeline:Array&lt;ICommentData&gt;)
59+
载入一些抽象弹幕对象作为时间轴。这些弹幕对象不必排序,管理器会自动根据 stime 进行排序。`load`
60+
清空之前的时间轴。请不要在播放的时候重新 load 因为那样会导致位置指针不连续而产生奇怪的bug。可以事先
61+
进行 `time(0)` 或者 `seek(0)` 操作来把播放位置复原到0。
62+
63+
动态更改弹幕列表可以采取更加安全的 `insert``remove`函数
64+
65+
### insert(data:ICommentData)
66+
67+
### remove(data:ICommentData)
68+
从弹幕列表中删除弹幕。注意参数data必须是同一个实例引用,否则即使参数都一样也不会导致弹幕被删除。
69+
删除只会从时间轴中删除,如果被删除的弹幕正再播放,不会导致正在播放的弹幕消失。
70+
71+
### remove(filterFunction:Function)
72+
从弹幕列表中删除弹幕。filterFunction会在每个弹幕对象上被调用。当filterFunction返回 true
73+
时(严格),删除相应弹幕。
74+
75+
### send(data:ICommentData)
76+
把一个抽象弹幕数据对象变成一个 IComment 并放入运行列表中。当 data 对象不符合 filter 规则或者
77+
时发送不会实现。代码弹幕也要通过send发送,只不过它们会进一步被派发到代码弹幕引擎。同一个
78+
ICommentData 实例如果多次用于调用这个方法会产生多个不同的弹幕实例 IComment。
79+
80+
注意:send可以发送不在时间轴里的弹幕。这个功能尤其利于实时弹幕的实现,因为对于直播实时弹幕,基本不
81+
需要使用时间轴。直接把收到的弹幕 send 出去效率会高很多。
82+
83+
### finish(comment:IComment)
84+
完成弹幕,从舞台删除,从空间管理器里删除。更好的方法是调用 IComment的 `finish()` 方法。一般来说
85+
IComment的finish方法会在销毁相关的对象后调用这个方法来释放管理器内占用的资源。
86+
87+
## Events 事件
88+
有几个常见的方法来管理事件。
89+
90+
### addEventListener(event:String, listener:Function)
91+
添加监听器。
92+
93+
### removeEventListener(event:String, listener:Function)
94+
删除监听器。
95+
96+
### dispatchEvent(event:String, data:Object)
97+
派发事件。注意:派发事件可以派发自己创造的事件,比如 `dispatchEvent('myevent',null)` 在先前
98+
`addEventListener('myevent', function foo(){/** Foo **/})` 则会执行 foo 函数。
99+
有一些事件会被管理器自己派发,请参考相关文档。

src/CommentCoreLibrary.js

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* Comment Core Library CommentManager
33
* @license MIT
44
* @author Jim Chen
5-
*
5+
*
66
* Copyright (c) 2014 Jim Chen
77
*/
88
var CommentManager = (function() {
@@ -27,7 +27,7 @@ var CommentManager = (function() {
2727
}
2828
return "matrix3d(" + matrix.join(",") + ")";
2929
};
30-
30+
3131
function CommentManager(stageObject){
3232
var __timer = 0;
3333
this._listeners = {};
@@ -164,30 +164,35 @@ var CommentManager = (function() {
164164
};
165165
CommentManager.prototype.init = function(){
166166
this.setBounds();
167-
if(this.filter == null)
167+
if(this.filter == null) {
168168
this.filter = new CommentFilter(); //Only create a filter if none exist
169+
}
169170
};
170171
CommentManager.prototype.time = function(time){
171172
time = time - 1;
172173
if(this.position >= this.timeline.length || Math.abs(this.lastPos - time) >= 2000){
173174
this.seek(time);
174175
this.lastPos = time;
175-
if(this.timeline.length <= this.position)
176+
if(this.timeline.length <= this.position) {
176177
return;
178+
}
177179
}else{
178180
this.lastPos = time;
179181
}
180182
for(;this.position < this.timeline.length;this.position++){
181-
if(this.options.limit > 0 && this.runline.length > this.limiter) break;
182-
if(this.validate(this.timeline[this.position]) && this.timeline[this.position]['stime']<=time){
183-
this.send(this.timeline[this.position]);
183+
if(this.timeline[this.position]['stime']<=time){
184+
if(this.options.limit > 0 && this.runline.length > this.limiter) {
185+
continue; // Skip comments but still move the position pointer
186+
} else if(this.validate(this.timeline[this.position])){
187+
this.send(this.timeline[this.position]);
188+
}
184189
}else{
185190
break;
186191
}
187192
}
188193
};
189194
CommentManager.prototype.rescale = function(){
190-
195+
191196
};
192197
CommentManager.prototype.send = function(data){
193198
if(data.mode === 8){

src/css/animations.css

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/** CSS3 keyframe animations. From @WhiteBlue with modifications */
2+
3+
@keyframes cmt-move {
4+
100% {
5+
right: 100%;
6+
}
7+
}
8+
9+
@keyframes cmt-move-reverse {
10+
100% {
11+
left: 100%;
12+
}
13+
}

src/scripting/Unpacker.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -599,9 +599,9 @@
599599
cG = Math.floor((filter.params.color % 65536)/256),
600600
cB = filter.params.color % 256;
601601
var cMatrix = [
602-
0,0,0,cR,0,
603-
0,0,0,cG,0,
604-
0,0,0,cB,0,
602+
0,0,0,cR/256,0,
603+
0,0,0,cG/256,0,
604+
0,0,0,cB/256,0,
605605
0,0,0,1,0,
606606
];
607607
dFilter.appendChild(__("feColorMatrix",{

0 commit comments

Comments
 (0)