Skip to content

Commit

Permalink
feat(limel-icon-button): add method relayout that triggers re-layou…
Browse files Browse the repository at this point in the history
…t of hover-highlight
  • Loading branch information
adrianschmidt committed Sep 10, 2019
1 parent a1fce8c commit a9fbffe
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/components/icon-button/icon-button.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { MDCRipple } from '@lime-material/ripple';
import { Component, Element, Prop } from '@stencil/core';
import { Component, Element, Method, Prop } from '@stencil/core';

@Component({
tag: 'limel-icon-button',
Expand Down Expand Up @@ -31,6 +31,21 @@ export class IconButton {

private mdcIconButtonRipple;

/**
* If the button is hidden or inside another element that is animating
* while the button is instantiated, the hover-highlight may become
* misaligned. If so, calling this method will make the button re-layout
* the highlight.
*
* @returns {void}
*/
@Method()
public relayout() {
if (this.mdcIconButtonRipple) {
this.mdcIconButtonRipple.layout();
}
}

public componentDidLoad() {
this.mdcIconButtonRipple = new MDCRipple(
this.host.shadowRoot.querySelector('.mdc-icon-button')
Expand Down

0 comments on commit a9fbffe

Please sign in to comment.