From ef99024a0c5711bdce4509bab185e91c17fbb50d Mon Sep 17 00:00:00 2001 From: Travis Kaufman Date: Thu, 8 Jun 2017 10:34:55 -0400 Subject: [PATCH] feat(ripple): Add layout() method to component --- packages/mdc-ripple/README.md | 4 ++++ packages/mdc-ripple/index.js | 4 ++++ test/unit/mdc-ripple/mdc-ripple.test.js | 7 +++++++ 3 files changed, 15 insertions(+) diff --git a/packages/mdc-ripple/README.md b/packages/mdc-ripple/README.md index bde9643e1e3..2a9fee5f4f0 100644 --- a/packages/mdc-ripple/README.md +++ b/packages/mdc-ripple/README.md @@ -181,6 +181,10 @@ such as a `mousedown` or a `pointerdown` event). It expands from the center. Triggers a deactivation of the ripple (the second stage, which happens when the ripple surface is engaged via interaction, such as a `mouseup` or a `pointerup` event). It expands from the center. +#### MDCRipple.layout() + +Recomputes all dimensions and positions for the ripple element. Useful if a ripple surface's +position or dimension is changed programmatically. ### Unbounded Ripples diff --git a/packages/mdc-ripple/index.js b/packages/mdc-ripple/index.js index 1e6e7acc6ac..ada56fc38ce 100644 --- a/packages/mdc-ripple/index.js +++ b/packages/mdc-ripple/index.js @@ -74,6 +74,10 @@ export class MDCRipple extends MDCComponent { this.foundation_.deactivate(); } + layout() { + this.foundation_.layout(); + } + getDefaultFoundation() { return new MDCRippleFoundation(MDCRipple.createAdapter(this)); } diff --git a/test/unit/mdc-ripple/mdc-ripple.test.js b/test/unit/mdc-ripple/mdc-ripple.test.js index 10ec77398fa..5b33c678c20 100644 --- a/test/unit/mdc-ripple/mdc-ripple.test.js +++ b/test/unit/mdc-ripple/mdc-ripple.test.js @@ -88,6 +88,13 @@ test('deactivate() delegates to the foundation', () => { td.verify(component.foundation_.deactivate()); }); +test('layout() delegates to the foundation', () => { + const {component} = setupTest(); + component.foundation_.layout = td.function(); + component.layout(); + td.verify(component.foundation_.layout()); +}); + test('adapter#browserSupportsCssVars delegates to util', () => { const {component} = setupTest(); assert.equal(