增加apache.js中progressbar的加载时间 [英] increase progressbar loading time in pace.js

查看:97
本文介绍了增加apache.js中progressbar的加载时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用pace.js插件,它可以正常工作,但是我希望进度条显示更长的时间,这意味着增加了加载时间,因此用户会看到加载屏幕很长一段时间,默认情况下运行速度很快. 我还将查看这些选项,但不知道在哪里添加代码以增加加载时间.

I am using pace.js plugin, it works fine but I want that the progress bar will show for longer time, mean to increase the loading time, so user will see the loading screen for long time, by default it run fast. I will also look at these options but can't understand where to add the code for increasing the loading time.

我尝试这段代码,

window.paceOptions={
    initialRate:0.7,
    minTime:1750,
    maxProgressPerFrame:1,
    ghostTime: 120000
} 

但是它不起作用.

推荐答案

您可以使用speed.js为脚本标记描述选项或在data-pace-options属性中

You can describe options or in data-pace-options attribute for script tag with pace.js

或更佳-在简单的标记脚本(纯js)中,在包含progress.js之前(在库启动之前设置值),如下所示:

Or better - in simple tag script ( plain js ) BEFORE including pace.js ( to set value before library start ) like this:

<!DOCTYPE html>
<html>
<head>
  <script>
    paceOptions = {
    initialRate:0.7,
    minTime:1750,
    maxProgressPerFrame:1,
    ghostTime: 120000
}
  </script>
<script src="https://rawgit.com/HubSpot/pace/master/pace.js"></script>
   <link href="https://rawgit.com/HubSpot/pace/master/themes/green/pace-theme-barber-shop.css" rel="stylesheet" />
  <meta charset="utf-8">
  <title>Pace</title>
</head>
<body>

</body>
</html>

在这里尝试: http://jsbin.com/pumarikixa/1/

要更改速度,请参阅eventLag选项-

To change speed see eventLag options -

  eventLag : {
    minSamples: 10,
    sampleCount: 300,
    lagThreshold: 1
  }

类似于 http://jsbin.com/pequdepaga/1/

这篇关于增加apache.js中progressbar的加载时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆