Skip to content

Commit 2680f47

Browse files
committed
add progress indicator
1 parent 887da41 commit 2680f47

File tree

4 files changed

+28
-1
lines changed

4 files changed

+28
-1
lines changed

css/app.css

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,14 @@ body {
354354
}
355355
}
356356

357+
.progress-indicator-2 {
358+
position: fixed;
359+
top: 0;
360+
left: 0;
361+
height: 3px;
362+
background-color: #0A74DA;
363+
}
364+
357365
/**
358366
* okaidia theme for JavaScript, CSS and HTML
359367
* Loosely based on Monokai textmate theme by http://www.monokai.nl/

docs/function.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ var p = new Point();
1818

1919
任何带有默认值的参数,被视为可选参数。不带默认值的参数,则被视为必需参数。
2020

21-
利用参数默认值,可以指定一个参数不得省略,如果省略就抛出一个错误。
21+
利用参数默认值,可以指定某一个参数不得省略,如果省略就抛出一个错误。
2222

2323
```javascript
2424

index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
<div id="loading">Loading ...</div>
2727
<div id="error">Opps! ... File not found!</div>
2828
<div id="flip"><div id="pageup">上一章</div><div id="pagedown">下一章</div></div>
29+
<div class="progress-indicator-2"></div>
2930

3031
<script>
3132
// essential settings

js/ditto.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,24 @@ function router() {
258258
$('#pagedown').css('display','inline-block');
259259
}
260260

261+
(function(){
262+
var $w = $(window);
263+
var $prog2 = $('.progress-indicator-2');
264+
var wh = $w.height();
265+
var h = $('body').height();
266+
var sHeight = h - wh;
267+
$w.off('scroll');
268+
$w.on('scroll', function(){
269+
var perc = Math.max(0, Math.min(1, $w.scrollTop()/sHeight));
270+
updateProgress(perc);
271+
});
272+
273+
function updateProgress(perc){
274+
$prog2.css({width : perc*100 + '%'});
275+
}
276+
277+
}());
278+
261279
}).fail(function() {
262280
show_error();
263281

0 commit comments

Comments
 (0)