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

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

Issue 1521913002: PDF: Delete non-material viewer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years 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 // 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({
6 is: 'viewer-toolbar',
7
8 properties: {
9 fadingIn: {
10 type: Boolean,
11 value: false,
12 observer: 'fadingInChanged'
13 }
14 },
15
16 timerId_: undefined,
17
18 inInitialFadeIn_: false,
19
20 ready: function() {
21 this.mousemoveCallback = function(e) {
22 var rect = this.getBoundingClientRect();
23 if (e.clientX >= rect.left && e.clientX <= rect.right &&
24 e.clientY >= rect.top && e.clientY <= rect.bottom) {
25 this.fadingIn = true;
26 // If we hover over the toolbar, cancel the initial fade in.
27 if (this.inInitialFadeIn_)
28 this.inInitialFadeIn_ = false;
29 } else {
30 // Initially we want to keep the toolbar up for a longer period.
31 if (!this.inInitialFadeIn_)
32 this.fadingIn = false;
33 }
34 }.bind(this);
35 },
36
37 attached: function() {
38 this.parentNode.addEventListener('mousemove', this.mousemoveCallback);
39 },
40
41 detached: function() {
42 this.parentNode.removeEventListener('mousemove', this.mousemoveCallback);
43 },
44
45 initialFadeIn: function() {
46 this.inInitialFadeIn_ = true;
47 this.fadeIn();
48 this.fadeOutAfterDelay(6000);
49 },
50
51 fadingInChanged: function() {
52 if (this.fadingIn) {
53 this.fadeIn();
54 } else {
55 if (this.timerId_ === undefined)
56 this.fadeOutAfterDelay(3000);
57 }
58 },
59
60 fadeIn: function() {
61 this.style.opacity = 1;
62 clearTimeout(this.timerId_);
63 this.timerId_ = undefined;
64 },
65
66 fadeOutAfterDelay: function(delay) {
67 this.timerId_ = setTimeout(
68 function() {
69 this.style.opacity = 0;
70 this.timerId_ = undefined;
71 this.inInitialFadeIn_ = false;
72 }.bind(this), delay);
73 }
74 });
OLDNEW
« no previous file with comments | « chrome/browser/resources/pdf/elements/viewer-toolbar/viewer-toolbar.html ('k') | chrome/browser/resources/pdf/index.css » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698