1

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

我试试这段代码,

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

但它不会工作。

4

1 回答 1

5

您可以使用pace.js 描述脚本标签的选项或data-pace-options 属性

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

<!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 选项 -

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

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

于 2015-02-19T02:21:00.820 回答