Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/87.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何阻止浏览器从marquee3K崩溃?_Javascript_Html_Css - Fatal编程技术网

Javascript 如何阻止浏览器从marquee3K崩溃?

Javascript 如何阻止浏览器从marquee3K崩溃?,javascript,html,css,Javascript,Html,Css,我正在使用marquee3000插件。如果有任何静态数据,它工作得很好。但当我尝试使其动态化时,如果在加载时没有数据,那么CPU使用率将达到100%,并且由于当前页面使用率较高,整个系统将挂起 插件链接: 请检查此示例,您可以在其中检查此错误: /** *字幕3000字幕3000字幕3000字幕3000字幕3000字幕3000字幕3000字幕3000 * http://github.com/ezekielaquino/marquee3000 *新千年1.0版的大屏幕 *麻省理工学院执照 */

我正在使用marquee3000插件。如果有任何静态数据,它工作得很好。但当我尝试使其动态化时,如果在加载时没有数据,那么CPU使用率将达到100%,并且由于当前页面使用率较高,整个系统将挂起

插件链接:

请检查此示例,您可以在其中检查此错误:

/**
*字幕3000字幕3000字幕3000字幕3000字幕3000字幕3000字幕3000字幕3000
* http://github.com/ezekielaquino/marquee3000
*新千年1.0版的大屏幕
*麻省理工学院执照
*/
;(函数(根,工厂){
if(typeof define=='function'&&define.amd){
定义([],工厂);
}else if(导出的类型==='object'){
module.exports=工厂();
}否则{
root.Marquee3k=工厂();
}
}(这个,函数(){
"严格使用",;
第3K类{
构造函数(元素、选项){
this.element=元素;
this.selector=options.selector;
this.speed=element.dataset.speed | | 0.25;
this.pausable=element.dataset.pausable;
this.reverse=element.dataset.reverse;
this.pause=false;
this.parent=element.parentElement;
this.parentProps=this.parent.getBoundingClientRect();
this.content=element.children[0];
this.innerContent=this.content.innerHTML;
this.wrapStyles='';
这个偏移量=0;
这个;
这个;
这个;
this.wrapper.appendChild(this.content);
this.element.appendChild(this.wrapper);
}
_setupWrapper(){
this.wrapper=document.createElement('div');
this.wrapper.classList.add('marquee3k\uu wrapper');
this.wrapper.style.whiteSpace='nowrap';
}
_设置内容(){
this.content.classList.add(`this.selector}\uuu copy`);
this.content.style.display='inline block';
this.contentWidth=this.content.offsetWidth;
this.requiredReps=this.contentWidth>this.parentProps.width?2:Math.ceil((this.parentProps.width-this.contentWidth)/this.contentWidth)+1;
for(设i=0;i{
如果(this.pausable)this.paused=true;
});
this.element.addEventListener('mouseleave',()=>{
如果(this.pausable)this.paused=false;
});
}
_createClone(){
const clone=this.content.cloneNode(true);
clone.style.display='inline block';
clone.classList.add(`this.selector}\uuu copy`);
this.wrapper.appendChild(克隆);
}
制作动画(){
如果(!this.paused){
const isscrowled=this.reverse?this.offset<0:this.offset>this.contentWidth*-1;
常量方向=此。反向?-1:1;
const reset=this.reverse?this.contentWidth*-1:0;
如果(IScrowled)this.offset-=this.speed*方向;
否则,此偏移=重置;
this.wrapper.style.whiteSpace='nowrap';
this.wrapper.style.transform=`translate(${this.offset}px,0)translateZ(0)`;
}
}
_刷新(){
this.contentWidth=this.content.offsetWidth;
}
重新填充(差异,更大){
this.contentWidth=this.content.offsetWidth;
如果(isLarger){
const amount=Math.ceil(差/this.contentWidth)+1;
for(设i=0;i{
清除超时(计时器);
计时器=设置超时(()=>{
const isLarger=上一个宽度

一些字幕内容