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.
5 Polymer('viewer-toolbar', {
8 inInitialFadeIn_: false,
10 this.mousemoveCallback = function(e) {
11 var rect = this.getBoundingClientRect();
12 if (e.clientX >= rect.left && e.clientX <= rect.right &&
13 e.clientY >= rect.top && e.clientY <= rect.bottom) {
15 // If we hover over the toolbar, cancel the initial fade in.
16 if (this.inInitialFadeIn_)
17 this.inInitialFadeIn_ = false;
19 // Initially we want to keep the toolbar up for a longer period.
20 if (!this.inInitialFadeIn_)
21 this.fadingIn = false;
25 attached: function() {
26 this.parentNode.addEventListener('mousemove', this.mousemoveCallback);
28 detached: function() {
29 this.parentNode.removeEventListener('mousemove', this.mousemoveCallback);
31 initialFadeIn: function() {
32 this.inInitialFadeIn_ = true;
34 this.fadeOutAfterDelay(6000);
36 fadingInChanged: function() {
40 if (this.timerId_ === undefined)
41 this.fadeOutAfterDelay(3000);
45 this.style.opacity = 1;
46 clearTimeout(this.timerId_);
47 this.timerId_ = undefined;
49 fadeOutAfterDelay: function(delay) {
50 this.timerId_ = setTimeout(
52 this.style.opacity = 0;
53 this.timerId_ = undefined;
54 this.inInitialFadeIn_ = false;