blob: 8612e170348f1894f46296e0dc5e2be93c984c33 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
Polymer('viewer-page-indicator', {
label: '1',
index: 0,
timerId: undefined,
pageLabels: null,
ready: function() {
var callback = this.fadeIn.bind(this, 2000);
window.addEventListener('scroll', function() {
requestAnimationFrame(callback);
});
},
initialFadeIn: function() {
this.fadeIn(6000);
},
fadeIn: function(displayTime) {
var percent = window.scrollY /
(document.body.scrollHeight -
document.documentElement.clientHeight);
this.style.top = percent *
(document.documentElement.clientHeight - this.offsetHeight) + 'px';
this.style.opacity = 1;
clearTimeout(this.timerId);
this.timerId = setTimeout(function() {
this.style.opacity = 0;
this.timerId = undefined;
}.bind(this), displayTime);
},
pageLabelsChanged: function() {
this.indexChanged();
},
indexChanged: function() {
if (this.pageLabels)
this.label = this.pageLabels[this.index];
else
this.label = String(this.index + 1);
}
});
|