Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(89)

Side by Side Diff: elements/viewer-page-indicator/viewer-page-indicator.html

Issue 152913003: Add page indicator and progress bar polymer elements (Closed) Base URL: https://chromium.googlesource.com/chromium/html-office-public.git@master
Patch Set: Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 <polymer-element name="viewer-page-indicator" attributes="text">
2 <template>
3 <link rel="stylesheet" href="viewer-page-indicator.css">
4 <div id="text">1</div>
ganetsky1 2014/02/04 17:27:29 You can use data binding http://www.polymer-proje
raymes 2014/02/05 05:04:37 Oops. Done.
5 <div id="triangle-right"></div>
6 </template>
7 <script>
8 Polymer('viewer-page-indicator', {
9 text: '1',
10 timerId: undefined,
11 ready: function() {
12 var scrollCallback = function() {
13 if (document.documentElement.clientWidth == window.innerWidth)
14 this.style.visibility = 'hidden';
15 else
16 this.style.visibility = 'visible';
ganetsky1 2014/02/04 17:27:29 Ternary operator? this.style.visibility = (docume
raymes 2014/02/05 05:04:37 Done.
17
18 var percent = window.scrollY /
19 (document.body.scrollHeight -
20 document.documentElement.clientHeight);
ganetsky1 2014/02/04 17:27:29 Fix indentation
raymes 2014/02/05 05:04:37 Done.
21 this.style.top = percent * (document.documentElement.clientHeight -
22 this.offsetHeight) + 'px';
ganetsky1 2014/02/04 17:27:29 I'd rather the entire parenthesized subexpression
raymes 2014/02/05 05:04:37 Done.
23 this.style.opacity = 1;
24 if (this.timerId !== undefined)
25 clearTimeout(this.timerId);
ganetsky1 2014/02/04 17:27:29 nitpick: you drop the if statement and just say cl
raymes 2014/02/05 05:04:37 Done.
26
27 this.timerId = setTimeout(function() {
28 this.style.opacity = 0;
29 }.bind(this), 2000);
30 }.bind(this);
31 window.addEventListener('scroll', function() {
ganetsky1 2014/02/04 17:27:29 Can you use declarative event mapping? http://www.
raymes 2014/02/05 05:04:37 It doesn't seem so. I guess because the scroll eve
32 webkitRequestAnimationFrame(scrollCallback);
ganetsky1 2014/02/04 17:27:29 I don't know what the status of "webkit" prefixed
raymes 2014/02/05 05:04:37 Done. - the prefix isn't needed anymore.
33 });
34
35 scrollCallback();
36 },
37 textChanged: function() {
38 this.$.text.innerHTML = this.text;
ganetsky1 2014/02/04 17:27:29 Use data binding instead
raymes 2014/02/05 05:04:37 Done.
39 },
40 });
41 </script>
42 </polymer-element>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698