Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: blurry ripples for slide-toggle, radio, checkbox in MS edge. #8514

Merged
merged 1 commit into from
Nov 29, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/lib/checkbox/checkbox.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@
<div matRipple class="mat-checkbox-ripple"
[matRippleTrigger]="label"
[matRippleDisabled]="_isRippleDisabled()"
[matRippleCentered]="true"></div>
[matRippleRadius]="_rippleConfig.radius"
[matRippleSpeedFactor]="_rippleConfig.speedFactor"
[matRippleCentered]="_rippleConfig.centered">
</div>
<div class="mat-checkbox-frame"></div>
<div class="mat-checkbox-background">
<svg version="1.1"
Expand Down
11 changes: 5 additions & 6 deletions src/lib/checkbox/checkbox.scss
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ $_mat-checkbox-mark-path-length: 22.910259;
$_mat-checkbox-indeterminate-checked-easing-function: cubic-bezier(0.14, 0, 0, 1);

// The ripple size of the checkbox
$_mat-checkbox-ripple-size: 15px;
$_mat-checkbox-ripple-radius: 25px;

// The amount of spacing between the checkbox and its label.
$_mat-checkbox-item-spacing: $mat-toggle-padding;
Expand Down Expand Up @@ -413,11 +413,10 @@ $_mat-checkbox-mark-stroke-size: 2 / 15 * $mat-checkbox-size !default;

.mat-checkbox-ripple {
position: absolute;
left: -$_mat-checkbox-ripple-size;
top: -$_mat-checkbox-ripple-size;
right: -$_mat-checkbox-ripple-size;
bottom: -$_mat-checkbox-ripple-size;
border-radius: 50%;
left: $mat-checkbox-size / 2 - $_mat-checkbox-ripple-radius;
top: $mat-checkbox-size / 2 - $_mat-checkbox-ripple-radius;
height: $_mat-checkbox-ripple-radius * 2;
width: $_mat_checkbox-ripple-radius * 2;
z-index: 1;
pointer-events: none;
}
6 changes: 5 additions & 1 deletion src/lib/checkbox/checkbox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import {
mixinDisabled,
mixinDisableRipple,
mixinTabIndex,
RippleConfig,
RippleRef,
} from '@angular/material/core';

Expand Down Expand Up @@ -178,6 +179,9 @@ export class MatCheckbox extends _MatCheckboxMixinBase implements ControlValueAc
/** Called when the checkbox is blurred. Needed to properly implement ControlValueAccessor. */
@ViewChild(MatRipple) _ripple: MatRipple;

/** Ripple configuration for the mouse ripples and focus indicators. */
_rippleConfig: RippleConfig = {centered: true, radius: 25, speedFactor: 1.5};

/**
* Called when the checkbox is blurred. Needed to properly implement ControlValueAccessor.
* @docs-private
Expand Down Expand Up @@ -336,7 +340,7 @@ export class MatCheckbox extends _MatCheckboxMixinBase implements ControlValueAc
/** Function is called whenever the focus changes for the input element. */
private _onInputFocusChange(focusOrigin: FocusOrigin) {
if (!this._focusRipple && focusOrigin === 'keyboard') {
this._focusRipple = this._ripple.launch(0, 0, {persistent: true, centered: true});
this._focusRipple = this._ripple.launch(0, 0, {persistent: true, ...this._rippleConfig});
} else if (!focusOrigin) {
this._removeFocusRipple();
this.onTouched();
Expand Down
5 changes: 4 additions & 1 deletion src/lib/radio/radio.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@
<div mat-ripple class="mat-radio-ripple"
[matRippleTrigger]="label"
[matRippleDisabled]="_isRippleDisabled()"
[matRippleCentered]="true"></div>
[matRippleCentered]="_rippleConfig.centered"
[matRippleRadius]="_rippleConfig.radius"
[matRippleSpeedFactor]="_rippleConfig.speedFactor">
</div>
</div>

<input #input class="mat-radio-input cdk-visually-hidden" type="radio"
Expand Down
11 changes: 5 additions & 6 deletions src/lib/radio/radio.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@


$mat-radio-size: $mat-toggle-size !default;
$mat-radio-ripple-size: $mat-radio-size * 0.75;
$mat-radio-ripple-radius: 25px;

// Top-level host container.
.mat-radio-button {
Expand Down Expand Up @@ -101,11 +101,10 @@ $mat-radio-ripple-size: $mat-radio-size * 0.75;

.mat-radio-ripple {
position: absolute;
left: -$mat-radio-ripple-size;
top: -$mat-radio-ripple-size;
right: -$mat-radio-ripple-size;
bottom: -$mat-radio-ripple-size;
border-radius: 50%;
left: $mat-radio-size / 2 - $mat-radio-ripple-radius;
top: $mat-radio-size / 2 - $mat-radio-ripple-radius;
height: $mat-radio-ripple-radius * 2;
width: $mat-radio-ripple-radius * 2;
z-index: 1;
pointer-events: none;
}
6 changes: 5 additions & 1 deletion src/lib/radio/radio.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import {
mixinColor,
mixinDisabled,
mixinDisableRipple,
RippleConfig,
RippleRef,
} from '@angular/material/core';

Expand Down Expand Up @@ -483,6 +484,9 @@ export class MatRadioButton extends _MatRadioButtonMixinBase
/** The child ripple instance. */
@ViewChild(MatRipple) _ripple: MatRipple;

/** Ripple configuration for the mouse ripples and focus indicators. */
_rippleConfig: RippleConfig = {centered: true, radius: 23, speedFactor: 1.5};

/** Reference to the current focus ripple. */
private _focusRipple: RippleRef | null;

Expand Down Expand Up @@ -596,7 +600,7 @@ export class MatRadioButton extends _MatRadioButtonMixinBase
/** Function is called whenever the focus changes for the input element. */
private _onInputFocusChange(focusOrigin: FocusOrigin) {
if (!this._focusRipple && focusOrigin === 'keyboard') {
this._focusRipple = this._ripple.launch(0, 0, {persistent: true, centered: true});
this._focusRipple = this._ripple.launch(0, 0, {persistent: true, ...this._rippleConfig});
} else if (!focusOrigin) {
if (this.radioGroup) {
this.radioGroup._touch();
Expand Down
6 changes: 4 additions & 2 deletions src/lib/slide-toggle/slide-toggle.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,10 @@

<div class="mat-slide-toggle-ripple" mat-ripple
[matRippleTrigger]="label"
[matRippleCentered]="true"
[matRippleDisabled]="disableRipple || disabled">
[matRippleDisabled]="disableRipple || disabled"
[matRippleCentered]="_rippleConfig.centered"
[matRippleRadius]="_rippleConfig.radius"
[matRippleSpeedFactor]="_rippleConfig.speedFactor">
</div>

</div>
Expand Down
1 change: 0 additions & 1 deletion src/lib/slide-toggle/slide-toggle.scss
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,6 @@ $mat-slide-toggle-bar-track-width: $mat-slide-toggle-bar-width - $mat-slide-togg
left: $mat-slide-toggle-thumb-size / 2 - $mat-slide-toggle-ripple-radius;
height: $mat-slide-toggle-ripple-radius * 2;
width: $mat-slide-toggle-ripple-radius * 2;
border-radius: 50%;
z-index: 1;
pointer-events: none;
}
6 changes: 5 additions & 1 deletion src/lib/slide-toggle/slide-toggle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import {
mixinDisabled,
mixinDisableRipple,
mixinTabIndex,
RippleConfig,
RippleRef,
} from '@angular/material/core';

Expand Down Expand Up @@ -139,6 +140,9 @@ export class MatSlideToggle extends _MatSlideToggleMixinBase implements OnDestro
/** Reference to the ripple directive on the thumb container. */
@ViewChild(MatRipple) _ripple: MatRipple;

/** Ripple configuration for the mouse ripples and focus indicators. */
_rippleConfig: RippleConfig = {centered: true, radius: 23, speedFactor: 1.5};

constructor(elementRef: ElementRef,
renderer: Renderer2,
private _platform: Platform,
Expand Down Expand Up @@ -232,7 +236,7 @@ export class MatSlideToggle extends _MatSlideToggleMixinBase implements OnDestro
private _onInputFocusChange(focusOrigin: FocusOrigin) {
if (!this._focusRipple && focusOrigin === 'keyboard') {
// For keyboard focus show a persistent ripple as focus indicator.
this._focusRipple = this._ripple.launch(0, 0, {persistent: true, centered: true});
this._focusRipple = this._ripple.launch(0, 0, {persistent: true, ...this._rippleConfig});
} else if (!focusOrigin) {
this.onTouched();

Expand Down