Index: elements/viewer-page-indicator/viewer-page-indicator.html |
diff --git a/elements/viewer-page-indicator/viewer-page-indicator.html b/elements/viewer-page-indicator/viewer-page-indicator.html |
index 80fb4045ed67f9da75abae4d3b372cda0ac94f87..fb247a2f0890f283f13db6c168653c40559c9427 100644 |
--- a/elements/viewer-page-indicator/viewer-page-indicator.html |
+++ b/elements/viewer-page-indicator/viewer-page-indicator.html |
@@ -9,26 +9,28 @@ |
text: '1', |
timerId: undefined, |
ready: function() { |
- var scrollCallback = function() { |
- 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), 2000); |
- }.bind(this); |
+ var callback = this.fadeIn.bind(this, 2000); |
window.addEventListener('scroll', function() { |
- requestAnimationFrame(scrollCallback); |
+ requestAnimationFrame(callback); |
}); |
- |
- scrollCallback(); |
}, |
+ 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); |
+ } |
}); |
</script> |
</polymer-element> |