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

Side by Side Diff: chrome/browser/resources/pdf/elements/viewer-page-indicator/viewer-page-indicator.js

Issue 2617663002: WIP: run clang-format-js on lots of things (Closed)
Patch Set: merge Created 3 years, 11 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
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 Polymer({ 5 Polymer({
6 is: 'viewer-page-indicator', 6 is: 'viewer-page-indicator',
7 7
8 properties: { 8 properties: {
9 label: { 9 label: {type: String, value: '1'},
10 type: String,
11 value: '1'
12 },
13 10
14 index: { 11 index: {type: Number, observer: 'indexChanged'},
15 type: Number,
16 observer: 'indexChanged'
17 },
18 12
19 pageLabels: { 13 pageLabels: {type: Array, value: null, observer: 'pageLabelsChanged'}
20 type: Array,
21 value: null,
22 observer: 'pageLabelsChanged'
23 }
24 }, 14 },
25 15
26 timerId: undefined, 16 timerId: undefined,
27 17
28 ready: function() { 18 ready: function() {
29 var callback = this.fadeIn.bind(this, 2000); 19 var callback = this.fadeIn.bind(this, 2000);
30 window.addEventListener('scroll', function() { 20 window.addEventListener('scroll', function() {
31 requestAnimationFrame(callback); 21 requestAnimationFrame(callback);
32 }); 22 });
33 }, 23 },
34 24
35 initialFadeIn: function() { 25 initialFadeIn: function() {
36 this.fadeIn(6000); 26 this.fadeIn(6000);
37 }, 27 },
38 28
39 fadeIn: function(displayTime) { 29 fadeIn: function(displayTime) {
40 var percent = window.scrollY / 30 var percent = window.scrollY /
41 (document.body.scrollHeight - 31 (document.body.scrollHeight - document.documentElement.clientHeight);
42 document.documentElement.clientHeight); 32 this.style.top =
43 this.style.top = percent * 33 percent * (document.documentElement.clientHeight - this.offsetHeight) +
44 (document.documentElement.clientHeight - this.offsetHeight) + 'px'; 34 'px';
45 <if expr="is_macosx"> 35 /* <if expr="is_macosx"> */
46 // On the Mac, if overlay scrollbars are enabled, prevent them from 36 // On the Mac, if overlay scrollbars are enabled, prevent them from
47 // overlapping the triangle. 37 // overlapping the triangle.
48 if (window.innerWidth == document.body.scrollWidth) 38 if (window.innerWidth == document.body.scrollWidth)
49 this.style.right = '16px'; 39 this.style.right = '16px';
50 else 40 else
51 this.style.right = '0px'; 41 this.style.right = '0px';
52 </if> 42 /* </if> */
53 this.style.opacity = 1; 43 this.style.opacity = 1;
54 clearTimeout(this.timerId); 44 clearTimeout(this.timerId);
55 45
56 this.timerId = setTimeout(function() { 46 this.timerId = setTimeout(function() {
57 this.style.opacity = 0; 47 this.style.opacity = 0;
58 this.timerId = undefined; 48 this.timerId = undefined;
59 }.bind(this), displayTime); 49 }.bind(this), displayTime);
60 }, 50 },
61 51
62 pageLabelsChanged: function() { 52 pageLabelsChanged: function() {
63 this.indexChanged(); 53 this.indexChanged();
64 }, 54 },
65 55
66 indexChanged: function() { 56 indexChanged: function() {
67 if (this.pageLabels) 57 if (this.pageLabels)
68 this.label = this.pageLabels[this.index]; 58 this.label = this.pageLabels[this.index];
69 else 59 else
70 this.label = String(this.index + 1); 60 this.label = String(this.index + 1);
71 } 61 }
72 }); 62 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698