UNPKG

@qier-player/danmaku

Version:

Powerful danmaku, support many features.

55 lines 2.17 kB
var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; return extendStatics(d, b); }; return function (d, b) { if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); import { TIME_PER_FRAME } from '../constants'; import BaseFixed from './base-fixed'; var FixedTopCommander = /** @class */ (function (_super) { __extends(FixedTopCommander, _super); function FixedTopCommander(danmaku, el, config, options) { var _this = _super.call(this, danmaku, el, config, options) || this; _this.danmaku = danmaku; return _this; } FixedTopCommander.prototype.render = function () { var _this = this; this.extractDanmu(); var objToElm = this.objToElm; var trackHeight = this.trackHeight; this.each(function (track, trackIdx) { var danmu = track.danmus[0]; if (!danmu) { return; } var danmuDom = objToElm.get(danmu); if (!danmuDom) { return; } if (danmu.static) { return; } var offset = danmu.offset; var y = trackIdx * trackHeight; danmuDom.style.transform = "translate(" + offset + "px, " + y + "px)"; danmu.duration -= TIME_PER_FRAME; if (danmu.duration <= 0) { _this.removeElementFromTrack(track, 0); track.remove(0); } }); }; return FixedTopCommander; }(BaseFixed)); export default FixedTopCommander; //# sourceMappingURL=fixed-top.js.map