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

Unified Diff: elements/viewer-toolbar/viewer-toolbar.html

Issue 169163004: Allow click events to pass through the toolbar padding. (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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « elements/viewer-toolbar/viewer-toolbar.css ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: elements/viewer-toolbar/viewer-toolbar.html
diff --git a/elements/viewer-toolbar/viewer-toolbar.html b/elements/viewer-toolbar/viewer-toolbar.html
index 70c66eb51afc60eff4231fe4c7afc31fd1551100..fcb2341916c4726df791c582a68bc15ae7dc1b3c 100644
--- a/elements/viewer-toolbar/viewer-toolbar.html
+++ b/elements/viewer-toolbar/viewer-toolbar.html
@@ -1,6 +1,4 @@
-<polymer-element name="viewer-toolbar" attributes="fadingIn"
- on-mouseover="{{fadeIn}}" on-mousemove="{{fadeIn}}"
- on-mouseout="{{fadeOut}}">
+<polymer-element name="viewer-toolbar" attributes="fadingIn">
<template>
<link rel="stylesheet" href="viewer-toolbar.css">
<div id="toolbar">
@@ -10,30 +8,55 @@
<script>
Polymer('viewer-toolbar', {
fadingIn: false,
- timerId: undefined,
+ timerId_: undefined,
+ inInitialFadeIn_: false,
ready: function() {
- this.fadingInChanged();
+ this.mousemoveCallback = function(e) {
+ var rect = this.getBoundingClientRect();
+ if (e.clientX >= rect.left && e.clientX <= rect.right &&
+ e.clientY >= rect.top && e.clientY <= rect.bottom) {
+ this.fadingIn = true;
+ // If we hover over the toolbar, cancel the initial fade in.
+ if (this.inInitialFadeIn_)
+ this.inInitialFadeIn_ = false;
+ } else {
+ // Initially we want to keep the toolbar up for a longer period.
+ if (!this.inInitialFadeIn_)
+ this.fadingIn = false;
+ }
+ }.bind(this);
},
- fadeIn: function() {
- this.fadingIn = true;
+ attached: function() {
+ this.parentNode.addEventListener('mousemove', this.mousemoveCallback);
},
- fadeOut: function() {
- this.fadingIn = false;
+ detached: function() {
+ this.parentNode.removeEventListener('mousemove', this.mousemoveCallback);
+ },
+ initialFadeIn: function() {
+ this.inInitialFadeIn_ = true;
+ this.fadeIn();
+ this.fadeOutAfterDelay(6000);
},
fadingInChanged: function() {
if (this.fadingIn) {
- this.style.opacity = 1;
- clearTimeout(this.timerId);
- this.timerId = undefined;
+ this.fadeIn();
} else {
- if (this.timerId === undefined) {
- this.timerId = setTimeout(
- function() {
- this.style.opacity = 0;
- this.timerId = undefined;
- }.bind(this), 3000);
- }
+ if (this.timerId_ === undefined)
+ this.fadeOutAfterDelay(3000);
}
+ },
+ fadeIn: function() {
+ this.style.opacity = 1;
+ clearTimeout(this.timerId_);
+ this.timerId_ = undefined;
+ },
+ fadeOutAfterDelay: function(delay) {
+ this.timerId_ = setTimeout(
+ function() {
+ this.style.opacity = 0;
+ this.timerId_ = undefined;
+ this.inInitialFadeIn_ = false;
+ }.bind(this), delay);
}
});
</script>
« no previous file with comments | « elements/viewer-toolbar/viewer-toolbar.css ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698