| Index: lib/src/paper-tooltip/paper-tooltip.html
|
| diff --git a/lib/src/paper-tooltip/paper-tooltip.html b/lib/src/paper-tooltip/paper-tooltip.html
|
| index 950177b3c41e6b2fce308773d217ed8115628f26..6a4829924429dc46df4f90476a4976a79cb58243 100644
|
| --- a/lib/src/paper-tooltip/paper-tooltip.html
|
| +++ b/lib/src/paper-tooltip/paper-tooltip.html
|
| @@ -12,7 +12,9 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
| <link rel="import" href="../neon-animation/neon-animation-runner-behavior.html">
|
| <link rel="import" href="../neon-animation/animations/fade-in-animation.html">
|
| <link rel="import" href="../neon-animation/animations/fade-out-animation.html">
|
| +
|
| <!--
|
| +Material design: [Tooltips](https://www.google.com/design/spec/components/tooltips.html)
|
|
|
| `<paper-tooltip>` is a label that appears on hover and focus when the user
|
| hovers over an element with the cursor or with the keyboard. It will be centered
|
| @@ -61,6 +63,11 @@ Custom property | Description | Default
|
| position: absolute;
|
| outline: none;
|
| z-index: 1002;
|
| + -moz-user-select: none;
|
| + -ms-user-select: none;
|
| + -webkit-user-select: none;
|
| + user-select: none;
|
| + cursor: default;
|
| }
|
|
|
| #tooltip {
|
| @@ -68,6 +75,7 @@ Custom property | Description | Default
|
| outline: none;
|
| @apply(--paper-font-common-base);
|
| font-size: 10px;
|
| + line-height: 1;
|
|
|
| background-color: var(--paper-tooltip-background, #616161);
|
| opacity: var(--paper-tooltip-opacity, 0.9);
|
| @@ -149,6 +157,20 @@ Custom property | Description | Default
|
| value: 14
|
| },
|
|
|
| + /**
|
| + * The delay that will be applied before the `entry` animation is
|
| + * played when showing the tooltip.
|
| + */
|
| + animationDelay: {
|
| + type: Number,
|
| + value: 500
|
| + },
|
| +
|
| + /**
|
| + * The entry and exit animations that will be played when showing and
|
| + * hiding the tooltip. If you want to override this, you must ensure
|
| + * that your animationConfig has the exact format below.
|
| + */
|
| animationConfig: {
|
| type: Object,
|
| value: function() {
|
| @@ -156,7 +178,7 @@ Custom property | Description | Default
|
| 'entry': [{
|
| name: 'fade-in-animation',
|
| node: this,
|
| - timing: {delay: 500}
|
| + timing: {delay: 0}
|
| }],
|
| 'exit': [{
|
| name: 'fade-out-animation',
|
| @@ -173,7 +195,8 @@ Custom property | Description | Default
|
| },
|
|
|
| listeners: {
|
| - 'neon-animation-finish': '_onAnimationFinish'
|
| + 'neon-animation-finish': '_onAnimationFinish',
|
| + 'mouseenter': 'hide'
|
| },
|
|
|
| /**
|
| @@ -204,6 +227,7 @@ Custom property | Description | Default
|
| this.listen(this._target, 'focus', 'show');
|
| this.listen(this._target, 'mouseleave', 'hide');
|
| this.listen(this._target, 'blur', 'hide');
|
| + this.listen(this._target, 'tap', 'hide');
|
| },
|
|
|
| detached: function() {
|
| @@ -212,30 +236,46 @@ Custom property | Description | Default
|
| this.unlisten(this._target, 'focus', 'show');
|
| this.unlisten(this._target, 'mouseleave', 'hide');
|
| this.unlisten(this._target, 'blur', 'hide');
|
| + this.unlisten(this._target, 'tap', 'hide');
|
| }
|
| },
|
|
|
| show: function() {
|
| + // If the tooltip is already showing, there's nothing to do.
|
| if (this._showing)
|
| return;
|
|
|
| if (Polymer.dom(this).textContent.trim() === '')
|
| return;
|
|
|
| - this.cancelAnimation();
|
|
|
| + this.cancelAnimation();
|
| + this._showing = true;
|
| this.toggleClass('hidden', false, this.$.tooltip);
|
| this.updatePosition();
|
| - this._showing = true;
|
|
|
| + this.animationConfig.entry[0].timing.delay = this.animationDelay;
|
| + this._animationPlaying = true;
|
| this.playAnimation('entry');
|
| },
|
|
|
| hide: function() {
|
| - if (!this._showing)
|
| + // If the tooltip is already hidden, there's nothing to do.
|
| + if (!this._showing) {
|
| return;
|
| + }
|
| +
|
| + // If the entry animation is still playing, don't try to play the exit
|
| + // animation since this will reset the opacity to 1. Just end the animation.
|
| + if (this._animationPlaying) {
|
| + this.cancelAnimation();
|
| + this._showing = false;
|
| + this._onAnimationFinish();
|
| + return;
|
| + }
|
|
|
| this._showing = false;
|
| + this._animationPlaying = true;
|
| this.playAnimation('exit');
|
| },
|
|
|
| @@ -310,6 +350,7 @@ Custom property | Description | Default
|
| },
|
|
|
| _onAnimationFinish: function() {
|
| + this._animationPlaying = false;
|
| if (!this._showing) {
|
| this.toggleClass('hidden', true, this.$.tooltip);
|
| }
|
|
|