OLD | NEW |
---|---|
1 <polymer-element name="viewer-page-indicator" attributes="text"> | 1 <polymer-element name="viewer-page-indicator" attributes="text"> |
2 <template> | 2 <template> |
3 <link rel="stylesheet" href="viewer-page-indicator.css"> | 3 <link rel="stylesheet" href="viewer-page-indicator.css"> |
4 <div id="text">{{text}}</div> | 4 <div id="text">{{text}}</div> |
5 <div id="triangle-right"></div> | 5 <div id="triangle-right"></div> |
6 </template> | 6 </template> |
7 <script> | 7 <script> |
8 Polymer('viewer-page-indicator', { | 8 Polymer('viewer-page-indicator', { |
9 text: '1', | 9 text: '1', |
10 timerId: undefined, | 10 timerId: undefined, |
11 ready: function() { | 11 ready: function() { |
12 var scrollCallback = function() { | 12 var callback = this.fadeIn.bind(this, 2000); |
13 var percent = window.scrollY / | 13 window.addEventListener('scroll', function() { |
14 (document.body.scrollHeight - | 14 requestAnimationFrame(callback); |
15 document.documentElement.clientHeight); | 15 }); |
16 this.style.top = percent * | 16 }, |
17 (document.documentElement.clientHeight - this.offsetHeight) + 'px'; | 17 initialFadeIn: function() { |
18 this.style.opacity = 1; | 18 this.fadeIn(6000); |
19 clearTimeout(this.timerId); | 19 }, |
20 fadeIn: function(displayTime) { | |
21 var percent = window.scrollY / | |
22 (document.body.scrollHeight - | |
23 document.documentElement.clientHeight); | |
24 this.style.top = percent * | |
25 (document.documentElement.clientHeight - this.offsetHeight) + 'px'; | |
26 this.style.opacity = 1; | |
27 clearTimeout(this.timerId); | |
20 | 28 |
21 this.timerId = setTimeout(function() { | 29 this.timerId = setTimeout(function() { |
22 this.style.opacity = 0; | 30 this.style.opacity = 0; |
23 this.timerId = undefined; | 31 this.timerId = undefined; |
24 }.bind(this), 2000); | 32 }.bind(this), displayTime); |
25 }.bind(this); | 33 } |
ganetsky1
2014/02/20 20:22:29
Where is the call to initialFadeIn?
raymes
2014/02/21 03:03:42
It will be called from the owner of this element.
| |
26 window.addEventListener('scroll', function() { | |
27 requestAnimationFrame(scrollCallback); | |
28 }); | |
29 | |
30 scrollCallback(); | |
31 }, | |
32 }); | 34 }); |
33 </script> | 35 </script> |
34 </polymer-element> | 36 </polymer-element> |
OLD | NEW |