代码拉取完成,页面将自动刷新
/**
* MTitle.js v1.0
* Created by lifanko on 2019/7/28.
* https://gitee.com/lifanko/MTitle
*/
class MTitle {
constructor(title = 'MTitle', space = 1) {
this.mtitle = title;
this.space = space;
this.timer = null;
this.addSpace();
}
newTitle(title = 'MTitle') {
this.mtitle = title;
this.addSpace();
}
newSpace(space = 1) {
this.space = space;
this.addSpace();
}
addSpace() {
let buffer = '';
for (let i = 0; i < this.space; i++) {
buffer += ' ';
}
this.title = this.mtitle + buffer + this.mtitle;
this.length = this.mtitle.length + this.space;
this.index = 0;
}
stop(reset = false) {
if (this.timer !== null) {
clearInterval(this.timer);
this.timer = null;
}
if (reset) {
this.index = 0;
this.move();
}
}
move() {
if (this.index >= this.length) {
this.index = 0;
}
document.title = this.title.substr(this.index++, this.length);
}
start(interval = 1000) {
if (this.timer === null) {
let t = this;
this.timer = setInterval(function () {
t.move();
}, interval);
}
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。