Skip to content

Commit

Permalink
Removed double rerender of tooltip
Browse files Browse the repository at this point in the history
  • Loading branch information
Duncan Graham Walker committed May 15, 2016
1 parent ea5762a commit cf3ab3b
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 12 deletions.
29 changes: 17 additions & 12 deletions addon/components/tooltip-on-element.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ export default EmberTetherComponent.extend({

/* Methods */

close() {
hide() {
this.set('tooltipIsVisible', false);
},

Expand Down Expand Up @@ -204,13 +204,13 @@ export default EmberTetherComponent.extend({

if (_showOn !== 'none') {
$target.on(_showOn, () => {
this.open();
this.show();
});
}

if (_hideOn !== 'none') {
$target.on(_hideOn, () => {
this.close();
this.hide();
});
}
}
Expand All @@ -220,24 +220,28 @@ export default EmberTetherComponent.extend({

if (event !== 'focus') {
$target.focusin(() => {
this.open();
this.show();
});

$target.focusout(() => {
this.close();
this.hide();
});
}

$target.keydown((keyEvent) => {
if (keyEvent.which === 27) {
this.close();
this.hide();
keyEvent.preventDefault();

return false;
}
});
}

/* When this component has rendered we need
to check if Tether moved its position to keep the
element in bounds */

let renderedSide;

['top', 'right', 'bottom', 'left'].forEach(function(side) {
Expand All @@ -246,6 +250,10 @@ export default EmberTetherComponent.extend({
}
});

/* We then use the side the tooltip was *actually*
rendered on to set the correct offset from
the target element */

const spacing = this.get('spacing');

let offset;
Expand All @@ -265,10 +273,7 @@ export default EmberTetherComponent.extend({
break;
}

console.log(offset);

this.set('offset', offset);
this.tetherDidChange();
},

setTimer: Ember.observer('tooltipIsVisible', function() {
Expand All @@ -290,7 +295,7 @@ export default EmberTetherComponent.extend({
/* Hide tooltip after specified duration */

const hideTimer = run.later(() => {
this.close();
this.hide();
}, _duration);

/* Save timer ID for cancelling should an event
Expand All @@ -301,7 +306,7 @@ export default EmberTetherComponent.extend({
}
}),

open() {
show() {
this.set('tooltipIsVisible', true);
},

Expand All @@ -313,7 +318,7 @@ export default EmberTetherComponent.extend({
const $target = $(this.get('target'));

this.set('effect', null);
this.close();
this.hide();

$target.removeAttr('aria-describedby');
$target.off();
Expand Down
4 changes: 4 additions & 0 deletions tests/dummy/app/styles/app.scss
Original file line number Diff line number Diff line change
Expand Up @@ -75,3 +75,7 @@ a {
md-toolbar.md-default-theme {
background-color: #D39120;
}

.tooltip {
z-index: 61; // Over md-sidenav
}

0 comments on commit cf3ab3b

Please sign in to comment.