Skip to content

Commit

Permalink
fix(button): square ripple in compatibility mode (#3167)
Browse files Browse the repository at this point in the history
* Fixes the ripple not being clipped in compatibility mode. The issue was due to the check not including the `mat-` selectors.
* Reduces the amount of DOM manipulation done by the button.

Fixes #3164.
  • Loading branch information
crisbeto authored and mmalerba committed Feb 21, 2017
1 parent 1f19ef0 commit ceb472b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/lib/button/button.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<span class="mat-button-wrapper"><ng-content></ng-content></span>
<div md-ripple *ngIf="!_isRippleDisabled()" class="mat-button-ripple"
[class.mat-button-ripple-round]="_isRoundButton()"
[class.mat-button-ripple-round]="_isRoundButton"
[mdRippleTrigger]="_getHostElement()"></div>
<!-- the touchstart handler prevents the overlay from capturing the initial tap on touch devices -->
<div class="mat-button-focus-overlay" (touchstart)="$event.preventDefault()"></div>
13 changes: 6 additions & 7 deletions src/lib/button/button.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,12 @@ export class MdButton {
/** Whether a mousedown has occurred on this element in the last 100ms. */
_isMouseDown: boolean = false;

/** Whether the button is round. */
_isRoundButton: boolean = ['icon-button', 'fab', 'mini-fab'].some(suffix => {
let el = this._getHostElement();
return el.hasAttribute('md-' + suffix) || el.hasAttribute('mat-' + suffix);
});

/** Whether the ripple effect on click should be disabled. */
private _disableRipple: boolean = false;
private _disabled: boolean = null;
Expand Down Expand Up @@ -165,13 +171,6 @@ export class MdButton {
return this._elementRef.nativeElement;
}

_isRoundButton() {
const el = this._getHostElement();
return el.hasAttribute('md-icon-button') ||
el.hasAttribute('md-fab') ||
el.hasAttribute('md-mini-fab');
}

_isRippleDisabled() {
return this.disableRipple || this.disabled;
}
Expand Down

0 comments on commit ceb472b

Please sign in to comment.