Skip to content

Commit 9974831

Browse files
committed
Fixed error with reverse danmaku in CSS mode
1 parent e3ab70b commit 9974831

9 files changed

Lines changed: 557 additions & 527 deletions

File tree

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Copyright (c) 2014 Jim Chen
1+
Copyright (c) 2017 Jim Chen
22

33
Permission is hereby granted, free of charge, to any person obtaining a copy of this software
44
and associated documentation files (the "Software"), to deal in the Software without restriction,

dist/CommentCoreLibrary.js

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -655,21 +655,24 @@ var CssScrollComment = (function (_super) {
655655
return (this.ttl / this.dur) * (this.parent.width + this.width) - this.width;
656656
},
657657
set: function (x) {
658-
if (typeof this._x === "number") {
658+
if (this._x !== null && typeof this._x === "number") {
659659
var dx = x - this._x;
660660
this._x = x;
661-
CssCompatLayer.transform(this.dom, "translateX(" + dx + "px)");
661+
CssCompatLayer.transform(this.dom, "translateX(" +
662+
(this.axis % 2 === 0 ? dx : -dx) + "px)");
662663
}
663664
else {
664665
this._x = x;
665666
if (!this.absolute) {
666667
this._x *= this.parent.width;
667668
}
668-
if (this.align % 2 === 0) {
669-
this.dom.style.left = this._x + "px";
669+
if (this.axis % 2 === 0) {
670+
this.dom.style.left =
671+
(this._x + (this.align % 2 === 0 ? 0 : -this.width)) + 'px';
670672
}
671673
else {
672-
this.dom.style.right = this._x + "px";
674+
this.dom.style.right =
675+
(this._x + (this.align % 2 === 0 ? -this.width : 0)) + 'px';
673676
}
674677
}
675678
},
@@ -688,10 +691,11 @@ var CssScrollComment = (function (_super) {
688691
this._dirtyCSS = true;
689692
};
690693
CssScrollComment.prototype.stop = function () {
691-
this.dom.style.transition = "";
694+
_super.prototype.stop.call(this);
695+
this.dom.style.transition = '';
692696
this.x = this._x;
693697
this._x = null;
694-
this.x = (this.ttl / this.dur) * (this.parent.width + this.width) - this.width;
698+
this.x = this.x;
695699
this._dirtyCSS = true;
696700
};
697701
return CssScrollComment;

dist/CommentCoreLibrary.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/CommentObject.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ Alignment: 对齐锚点(方形四角)。此数的高位表示上下,低位
8383
设定后x,y坐标的锚点将变成对应的方形角。不过,在右和下的对齐时,读取 x,y 坐标不一定准确,而且因为
8484
效率低所以不推荐。比如 top right 模式下,读 x 坐标效率比较低,但是读 y 就要好很多。
8585

86-
注意:`>4`的模式未必在所有状态下都支持!
86+
注意:`>=4`的模式未必在所有状态下都支持!
8787

8888
### absolute <Bool> = true
8989
Absolute Coordinates: 是否使用绝对坐标。当 `absolute === false` 时,x,y坐标将会表示相对

0 commit comments

Comments
 (0)