OLD | NEW |
(Empty) | |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 Polymer('viewer-page-indicator', { |
| 6 text: '1', |
| 7 timerId: undefined, |
| 8 ready: function() { |
| 9 var callback = this.fadeIn.bind(this, 2000); |
| 10 window.addEventListener('scroll', function() { |
| 11 requestAnimationFrame(callback); |
| 12 }); |
| 13 }, |
| 14 initialFadeIn: function() { |
| 15 this.fadeIn(6000); |
| 16 }, |
| 17 fadeIn: function(displayTime) { |
| 18 var percent = window.scrollY / |
| 19 (document.body.scrollHeight - |
| 20 document.documentElement.clientHeight); |
| 21 this.style.top = percent * |
| 22 (document.documentElement.clientHeight - this.offsetHeight) + 'px'; |
| 23 this.style.opacity = 1; |
| 24 clearTimeout(this.timerId); |
| 25 |
| 26 this.timerId = setTimeout(function() { |
| 27 this.style.opacity = 0; |
| 28 this.timerId = undefined; |
| 29 }.bind(this), displayTime); |
| 30 } |
| 31 }); |
OLD | NEW |