From 13b61e7f72b0fa2ab30b30e30c1e41e202a08482 Mon Sep 17 00:00:00 2001 From: Feng Liu Date: Thu, 9 Aug 2018 20:35:56 -0700 Subject: [PATCH 1/8] export --- dist/CommentCoreLibrary.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/dist/CommentCoreLibrary.js b/dist/CommentCoreLibrary.js index c9f7ffa..d19b7be 100644 --- a/dist/CommentCoreLibrary.js +++ b/dist/CommentCoreLibrary.js @@ -2443,3 +2443,7 @@ var CommonDanmakuFormat = (function () { return CommonDanmakuFormat; })(); + +export { + CommentManager +} \ No newline at end of file From 69554a77b4be8f6c5a0fb016166621beff3151dd Mon Sep 17 00:00:00 2001 From: Feng Liu Date: Sun, 7 Oct 2018 02:29:57 -0700 Subject: [PATCH 2/8] set avatar and ribbon className --- dist/CommentCoreLibrary.js | 51 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/dist/CommentCoreLibrary.js b/dist/CommentCoreLibrary.js index d19b7be..ff96fe2 100644 --- a/dist/CommentCoreLibrary.js +++ b/dist/CommentCoreLibrary.js @@ -391,6 +391,11 @@ var CoreComment = (function () { this._shadow = true; this._font = ''; this._transform = null; + /**/ + this._ribbon = '' + this._avatar = '' + /**/ + if (!parent) { throw new Error('Comment not bound to comment manager.'); } @@ -468,6 +473,16 @@ var CoreComment = (function () { if (init.hasOwnProperty('axis')) { this.axis = init['axis']; } + + /**/ + if (init.hasOwnProperty('ribbon')) { + this._ribbon = init['ribbon']; + } + if (init.hasOwnProperty('avatar')) { + this._avatar = init['avatar']; + } + /**/ + if (init.hasOwnProperty('transform')) { this._transform = new CommentUtils.Matrix3D(init['transform']); } @@ -496,6 +511,14 @@ var CoreComment = (function () { if (this._color != 0xffffff) { this.color = this._color; } + /**/ + if (this._ribbon) { + this.ribbon = this._ribbon; + } + if (this._avatar) { + this.avatar = this._avatar; + } + /**/ this.shadow = this._shadow; if (this._border) { this.border = this._border; @@ -519,6 +542,34 @@ var CoreComment = (function () { this.animate(); } }; + + /**/ + Object.defineProperty(CoreComment.prototype, "ribbon", { + get: function () { + return this._ribbon; + }, + set: function (ribbon) { + this._ribbon = ribbon; + this.dom.className = this.parent.options.global.className + ' ribbon'; + this.dom.style.backgroundImage = `${ribbon}` + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(CoreComment.prototype, "avatar", { + get: function () { + return this._avatar; + }, + set: function (avatar) { + this._avatar = avatar; + this.dom.className = this.parent.options.global.className + ' avatar'; + this.dom.style.backgroundImage = `url(${avatar})`; + }, + enumerable: true, + configurable: true + }); + /**/ + Object.defineProperty(CoreComment.prototype, "x", { get: function () { if (this._x === null || this._x === undefined) { From 08114fb54ea22ef0689ce13635337a0133acbb6c Mon Sep 17 00:00:00 2001 From: Feng Liu Date: Tue, 9 Oct 2018 17:11:49 -0700 Subject: [PATCH 3/8] some fix --- dist/CommentCoreLibrary.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dist/CommentCoreLibrary.js b/dist/CommentCoreLibrary.js index ff96fe2..b0920bd 100644 --- a/dist/CommentCoreLibrary.js +++ b/dist/CommentCoreLibrary.js @@ -551,7 +551,7 @@ var CoreComment = (function () { set: function (ribbon) { this._ribbon = ribbon; this.dom.className = this.parent.options.global.className + ' ribbon'; - this.dom.style.backgroundImage = `${ribbon}` + this.dom.style.backgroundImage = ribbon; }, enumerable: true, configurable: true @@ -563,7 +563,7 @@ var CoreComment = (function () { set: function (avatar) { this._avatar = avatar; this.dom.className = this.parent.options.global.className + ' avatar'; - this.dom.style.backgroundImage = `url(${avatar})`; + this.dom.style.backgroundImage = 'url(' + avatar + ')'; }, enumerable: true, configurable: true From 5be7e4150d2ca6841bdf37142d6dc287a90c6b73 Mon Sep 17 00:00:00 2001 From: Feng Liu Date: 2018年11月15日 16:38:38 -0800 Subject: [PATCH 4/8] fix manager setBounds, sometimes this.stage.offsetWidth could be 0 --- dist/CommentCoreLibrary.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/dist/CommentCoreLibrary.js b/dist/CommentCoreLibrary.js index b0920bd..fb1b299 100644 --- a/dist/CommentCoreLibrary.js +++ b/dist/CommentCoreLibrary.js @@ -207,9 +207,9 @@ var CommentManager = (function() { this.dispatchEvent("clear"); }; - CommentManager.prototype.setBounds = function () { - this.width = this.stage.offsetWidth; - this.height= this.stage.offsetHeight; + CommentManager.prototype.setBounds = function (width, height) { + this.width = width || this.stage.offsetWidth; + this.height = height || this.stage.offsetHeight; this.dispatchEvent("resize"); for (var comAlloc in this.csa) { this.csa[comAlloc].setBounds(this.width,this.height); From eee599b59bce24a147531d3f2dc7696c68cd06da Mon Sep 17 00:00:00 2001 From: Feng Liu Date: 2018年11月29日 16:56:19 -0800 Subject: [PATCH 5/8] add prevent collision to options, improve willCollide function --- dist/CommentCoreLibrary.js | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/dist/CommentCoreLibrary.js b/dist/CommentCoreLibrary.js index fb1b299..a888a81 100644 --- a/dist/CommentCoreLibrary.js +++ b/dist/CommentCoreLibrary.js @@ -119,6 +119,7 @@ var CommentManager = (function() { scale:1 }, limit: 0, + collision: false, seekTrigger: 2000 }; this.timeline = []; @@ -1025,7 +1026,25 @@ var CommentSpaceAllocator = (function () { this._height = height; } CommentSpaceAllocator.prototype.willCollide = function (existing, check) { - return existing.stime + existing.ttl>= check.stime + check.ttl / 2; + if(existing.ttl <= 0){ + return false; + } + if(Math.abs(existing.x) + existing.width> Math.abs(check.x)){ + return true; + } + var speed = (existing.right) / existing.dur; //计算速度 + var speed2 = (check.right) / check.dur; + var ttl = existing.x / speed; //计算剩余时间,自带的ttl测试下来并不准 + var ttl2 = check.x / speed2; + var px1 = -existing.width + speed * ttl; + var px2 = -check.width + speed2 * ttl2; + if (px1 + existing.width> px2) { + return true; + } else { + return false; + } + // 以下是源码的逻辑 + // return existing.stime + existing.ttl>= check.stime + check.ttl / 2; }; CommentSpaceAllocator.prototype.pathCheck = function (y, comment, pool) { var bottom = y + comment.height; @@ -1072,6 +1091,10 @@ var CommentSpaceAllocator = (function () { return y; } } + // if collision is true, set ttl to 0 and not show in runline + if (comment.parent.options.collision === true) { + comment.ttl = 0; + } return this.assign(comment, cindex + 1); }; CommentSpaceAllocator.prototype.add = function (comment) { From f20bc31231890948a90a73e0b186024e3c2e8ba2 Mon Sep 17 00:00:00 2001 From: Feng Liu Date: 2018年11月30日 13:09:24 -0800 Subject: [PATCH 6/8] still show user send danmu and border danmu --- dist/CommentCoreLibrary.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/dist/CommentCoreLibrary.js b/dist/CommentCoreLibrary.js index a888a81..0eccbdc 100644 --- a/dist/CommentCoreLibrary.js +++ b/dist/CommentCoreLibrary.js @@ -1093,7 +1093,10 @@ var CommentSpaceAllocator = (function () { } // if collision is true, set ttl to 0 and not show in runline if (comment.parent.options.collision === true) { - comment.ttl = 0; + // still show user send danmu and border danmu + if (!comment.border) { + comment.ttl = 0; + } } return this.assign(comment, cindex + 1); }; From d65c5e4b656c23316427eb68e6c4266d4b9db580 Mon Sep 17 00:00:00 2001 From: Feng Liu Date: 2019年2月22日 15:13:48 -0800 Subject: [PATCH 7/8] fix avatar --- dist/CommentCoreLibrary.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/dist/CommentCoreLibrary.js b/dist/CommentCoreLibrary.js index 0eccbdc..adc705a 100644 --- a/dist/CommentCoreLibrary.js +++ b/dist/CommentCoreLibrary.js @@ -551,7 +551,7 @@ var CoreComment = (function () { }, set: function (ribbon) { this._ribbon = ribbon; - this.dom.className = this.parent.options.global.className + ' ribbon'; + this.dom.className = this.dom.className + ' ribbon'; this.dom.style.backgroundImage = ribbon; }, enumerable: true, @@ -563,8 +563,10 @@ var CoreComment = (function () { }, set: function (avatar) { this._avatar = avatar; - this.dom.className = this.parent.options.global.className + ' avatar'; - this.dom.style.backgroundImage = 'url(' + avatar + ')'; + let child = document.createElement('div') + child.className = child.className + ' avatar' + child.style.backgroundImage = 'url(' + avatar + ')'; + this.dom.appendChild(child) }, enumerable: true, configurable: true From 8b9f997a4e38e41509d0935b37d1b2c5b7d92d37 Mon Sep 17 00:00:00 2001 From: Feng Liu Date: 2019年2月27日 19:41:17 -0800 Subject: [PATCH 8/8] fix danmu avatar --- dist/CommentCoreLibrary.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/dist/CommentCoreLibrary.js b/dist/CommentCoreLibrary.js index adc705a..dacb482 100644 --- a/dist/CommentCoreLibrary.js +++ b/dist/CommentCoreLibrary.js @@ -566,7 +566,8 @@ var CoreComment = (function () { let child = document.createElement('div') child.className = child.className + ' avatar' child.style.backgroundImage = 'url(' + avatar + ')'; - this.dom.appendChild(child) + this.dom.insertBefore(child, this.dom.firstChild); + }, enumerable: true, configurable: true

AltStyle によって変換されたページ (->オリジナル) /