Skip to content

fix(material-experimental/mdc-radio): use consistent ripple timings #18590

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

Merged
merged 1 commit into from
Feb 26, 2020
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
11 changes: 7 additions & 4 deletions src/material-experimental/mdc-button/button-base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ export const MAT_BUTTON_HOST = {
'class': 'mat-mdc-focus-indicator',
};

/** Configuration for the ripple animation. */
const RIPPLE_ANIMATION_CONFIG: RippleAnimationConfig = {
enterDuration: numbers.DEACTIVATION_TIMEOUT_MS,
exitDuration: numbers.FG_DEACTIVATION_MS
};

/** List of classes to add to buttons instances based on host attribute selector. */
const HOST_SELECTOR_MDC_CLASS_PAIR: {selector: string, mdcClasses: string[]}[] = [
{
Expand Down Expand Up @@ -84,10 +90,7 @@ export const _MatButtonBaseMixin: CanDisableRippleCtor&CanDisableCtor&CanColorCt
export class MatButtonBase extends _MatButtonBaseMixin implements CanDisable, CanColor,
CanDisableRipple {
/** The ripple animation configuration to use for the buttons. */
_rippleAnimation: RippleAnimationConfig = {
enterDuration: numbers.DEACTIVATION_TIMEOUT_MS,
exitDuration: numbers.FG_DEACTIVATION_MS
};
_rippleAnimation: RippleAnimationConfig = RIPPLE_ANIMATION_CONFIG;

/** Whether the ripple is centered on the button. */
_isRippleCentered = false;
Expand Down
13 changes: 8 additions & 5 deletions src/material-experimental/mdc-checkbox/checkbox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import {
MAT_CHECKBOX_DEFAULT_OPTIONS,
MatCheckboxClickAction, MatCheckboxDefaultOptions
} from '@angular/material/checkbox';
import {ThemePalette} from '@angular/material/core';
import {ThemePalette, RippleAnimationConfig} from '@angular/material/core';
import {ANIMATION_MODULE_TYPE} from '@angular/platform-browser/animations';
import {MDCCheckboxAdapter, MDCCheckboxFoundation} from '@material/checkbox';
import {numbers} from '@material/ripple';
Expand All @@ -52,6 +52,12 @@ export class MatCheckboxChange {
checked: boolean;
}

/** Configuration for the ripple animation. */
const RIPPLE_ANIMATION_CONFIG: RippleAnimationConfig = {
enterDuration: numbers.DEACTIVATION_TIMEOUT_MS,
exitDuration: numbers.FG_DEACTIVATION_MS,
};

@Component({
selector: 'mat-checkbox',
templateUrl: 'checkbox.html',
Expand Down Expand Up @@ -185,10 +191,7 @@ export class MatCheckbox implements AfterViewInit, OnDestroy, ControlValueAccess
_classes: {[key: string]: boolean} = {'mdc-checkbox__native-control': true};

/** Animation config for the ripple. */
_rippleAnimation = {
enterDuration: numbers.DEACTIVATION_TIMEOUT_MS,
exitDuration: numbers.FG_DEACTIVATION_MS,
};
_rippleAnimation = RIPPLE_ANIMATION_CONFIG;

/** ControlValueAccessor onChange */
private _cvaOnChange = (_: boolean) => {};
Expand Down
11 changes: 7 additions & 4 deletions src/material-experimental/mdc-chips/chip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,12 @@ export interface MatChipEvent {
chip: MatChip;
}

/** Configuration for the ripple animation. */
const RIPPLE_ANIMATION_CONFIG: RippleAnimationConfig = {
enterDuration: numbers.DEACTIVATION_TIMEOUT_MS,
exitDuration: numbers.FG_DEACTIVATION_MS
};

/**
* Directive to add MDC CSS to non-basic chips.
* @docs-private
Expand Down Expand Up @@ -114,10 +120,7 @@ const _MatChipMixinBase:
export class MatChip extends _MatChipMixinBase implements AfterContentInit, AfterViewInit,
CanColor, CanDisableRipple, HasTabIndex, OnDestroy {
/** The ripple animation configuration to use for the chip. */
readonly _rippleAnimation: RippleAnimationConfig = {
enterDuration: numbers.DEACTIVATION_TIMEOUT_MS,
exitDuration: numbers.FG_DEACTIVATION_MS
};
readonly _rippleAnimation: RippleAnimationConfig = RIPPLE_ANIMATION_CONFIG;

/** Whether the ripple is centered on the chip. */
readonly _isRippleCentered = false;
Expand Down
2 changes: 2 additions & 0 deletions src/material-experimental/mdc-radio/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ ng_module(
"//src/material/radio",
"@npm//@angular/forms",
"@npm//@material/radio",
"@npm//@material/ripple",
],
)

Expand Down Expand Up @@ -71,6 +72,7 @@ ng_test_library(
ng_web_test_suite(
name = "unit_tests",
static_files = [
"@npm//:node_modules/@material/ripple/dist/mdc.ripple.js",
"@npm//:node_modules/@material/radio/dist/mdc.radio.js",
],
deps = [
Expand Down
2 changes: 1 addition & 1 deletion src/material-experimental/mdc-radio/radio.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
[matRippleDisabled]="_isRippleDisabled()"
[matRippleCentered]="true"
[matRippleRadius]="20"
[matRippleAnimation]="{enterDuration: 150}">
[matRippleAnimation]="_rippleAnimation">
<div class="mat-ripple-element mat-radio-persistent-ripple"></div>
</div>
</div>
Expand Down
10 changes: 10 additions & 0 deletions src/material-experimental/mdc-radio/radio.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ import {FocusMonitor} from '@angular/cdk/a11y';
import {UniqueSelectionDispatcher} from '@angular/cdk/collections';
import {ANIMATION_MODULE_TYPE} from '@angular/platform-browser/animations';
import {NG_VALUE_ACCESSOR} from '@angular/forms';
import {RippleAnimationConfig} from '@angular/material/core';
import {numbers} from '@material/ripple';

// Re-export symbols used by the base Material radio component so that users do not need to depend
// on both packages.
Expand All @@ -48,6 +50,11 @@ export const MAT_RADIO_GROUP_CONTROL_VALUE_ACCESSOR: any = {
multi: true
};

/** Configuration for the ripple animation. */
const RIPPLE_ANIMATION_CONFIG: RippleAnimationConfig = {
enterDuration: numbers.DEACTIVATION_TIMEOUT_MS,
exitDuration: numbers.FG_DEACTIVATION_MS
};

/**
* A group of radio buttons. May contain one or more `<mat-radio-button>` elements.
Expand Down Expand Up @@ -108,6 +115,9 @@ export class MatRadioButton extends BaseMatRadioButton implements AfterViewInit,
},
};

/** Configuration for the underlying ripple. */
_rippleAnimation: RippleAnimationConfig = RIPPLE_ANIMATION_CONFIG;

_radioFoundation = new MDCRadioFoundation(this._radioAdapter);
_classes: {[key: string]: boolean} = {};

Expand Down
11 changes: 7 additions & 4 deletions src/material-experimental/mdc-slide-toggle/slide-toggle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@ import {
// Increasing integer for generating unique ids for slide-toggle components.
let nextUniqueId = 0;

/** Configuration for the ripple animation. */
const RIPPLE_ANIMATION_CONFIG: RippleAnimationConfig = {
enterDuration: numbers.DEACTIVATION_TIMEOUT_MS,
exitDuration: numbers.FG_DEACTIVATION_MS,
};

/** @docs-private */
export const MAT_SLIDE_TOGGLE_VALUE_ACCESSOR: any = {
provide: NG_VALUE_ACCESSOR,
Expand Down Expand Up @@ -104,10 +110,7 @@ export class MatSlideToggle implements ControlValueAccessor, AfterViewInit, OnDe
_focused: boolean;

/** Configuration for the underlying ripple. */
_rippleAnimation: RippleAnimationConfig = {
enterDuration: numbers.DEACTIVATION_TIMEOUT_MS,
exitDuration: numbers.FG_DEACTIVATION_MS,
};
_rippleAnimation: RippleAnimationConfig = RIPPLE_ANIMATION_CONFIG;

/** The color palette for this slide toggle. */
@Input() color: ThemePalette = 'accent';
Expand Down