@qier-player/danmaku
Version:
Powerful danmaku, support many features.
40 lines • 1.2 kB
JavaScript
import { isRollingDanmu } from './utils/is';
var Track = /** @class */ (function () {
function Track() {
this.danmus = [];
this.offset = 0;
}
Track.prototype.each = function (handler) {
for (var i = 0; i < this.danmus.length; ++i) {
handler(this.danmus[i], i, this.danmus);
}
};
Track.prototype.push = function () {
var _a;
var items = [];
for (var _i = 0; _i < arguments.length; _i++) {
items[_i] = arguments[_i];
}
(_a = this.danmus).push.apply(_a, items);
};
Track.prototype.remove = function (index) {
if (index < 0 || index >= this.danmus.length) {
return;
}
this.danmus.splice(index, 1);
};
Track.prototype.updateOffset = function () {
var lastDanmu = this.danmus[this.danmus.length - 1];
if (lastDanmu && isRollingDanmu(lastDanmu)) {
var speed = lastDanmu.speed;
this.offset -= speed;
}
};
Track.prototype.reset = function () {
this.danmus = [];
this.offset = 0;
};
return Track;
}());
export default Track;
//# sourceMappingURL=track.js.map