Skip to content
This repository has been archived by the owner on Jan 13, 2025. It is now read-only.

fix(ripple): Expose focus/blur handlers #2905

Merged
merged 7 commits into from
Jun 8, 2018
18 changes: 12 additions & 6 deletions packages/mdc-ripple/foundation.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,14 +132,10 @@ class MDCRippleFoundation extends MDCFoundation {
this.deactivateHandler_ = (e) => this.deactivate_(e);

/** @private {function(?Event=)} */
this.focusHandler_ = () => requestAnimationFrame(
() => this.adapter_.addClass(MDCRippleFoundation.cssClasses.BG_FOCUSED)
);
this.focusHandler_ = () => this.handleFocus();

/** @private {function(?Event=)} */
this.blurHandler_ = () => requestAnimationFrame(
() => this.adapter_.removeClass(MDCRippleFoundation.cssClasses.BG_FOCUSED)
);
this.blurHandler_ = () => this.handleBlur();

/** @private {!Function} */
this.resizeHandler_ = () => this.layout();
Expand Down Expand Up @@ -587,6 +583,16 @@ class MDCRippleFoundation extends MDCFoundation {
this.adapter_.removeClass(UNBOUNDED);
}
}

handleFocus() {
requestAnimationFrame(() =>
this.adapter_.addClass(MDCRippleFoundation.cssClasses.BG_FOCUSED));
}

handleBlur() {
requestAnimationFrame(() =>
this.adapter_.removeClass(MDCRippleFoundation.cssClasses.BG_FOCUSED));
}
}

export default MDCRippleFoundation;