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

Commit e32c1fd

Browse files
committed
feat(ripple): Implement subset of improved interaction response guidelines for ripple
Background === When the ripple was originally designed from a motion perspective, bounded and unbounded activation/deactivation used two different animation styles, distinct from one another. The UX updates to the ripple remove this distinction of bounded vs. unbounded solely with regard to how the ripple animates in and out. There is still a distinction between bounded vs. unbounded, but we no longer have to account for this when animating the ripple. Thus, there are no API changes; only UX changes. Changes === - Implement UX changes for "tap" + "tap and hold" interactions - Remove all references of "bounded" vs. "unbounded" from activation/deactivation code Resolves #190
1 parent f6dbe84 commit e32c1fd

13 files changed

+518
-606
lines changed

packages/mdc-ripple/_keyframes.scss

Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -20,46 +20,37 @@
2020

2121
@keyframes mdc-ripple-fg-radius-in {
2222
from {
23-
transform: translate(0) scale(1);
23+
// NOTE: For these keyframes, we do not need custom property fallbacks because they are only
24+
// used in conjunction with `.mdc-ripple-upgraded`. Since MDCRippleFoundation checks to ensure
25+
// that custom properties are supported within the browser before adding this class, we can
26+
// safely use them without a fallback.
2427
transform: translate(var(--mdc-ripple-fg-translate-start, 0)) scale(1);
2528
animation-timing-function: $mdc-animation-fast-out-slow-in-timing-function;
2629
}
2730

2831
to {
29-
transform: translate(0) scale(0);
30-
transform: translate(var(--mdc-ripple-fg-translate-end, 0)) scale(var(--mdc-ripple-fg-scale, 0));
32+
transform: translate(var(--mdc-ripple-fg-translate-end, 0)) scale(var(--mdc-ripple-fg-scale, 1));
3133
}
3234
}
3335

34-
@keyframes mdc-ripple-fg-opacity-out {
36+
@keyframes mdc-ripple-fg-opacity-in {
3537
from {
36-
opacity: 1;
38+
opacity: 0;
3739
animation-timing-function: linear;
3840
}
3941

4042
to {
41-
opacity: 0;
43+
opacity: 1;
4244
}
4345
}
4446

45-
@keyframes mdc-ripple-fg-unbounded-opacity-deactivate {
47+
@keyframes mdc-ripple-fg-opacity-out {
4648
from {
4749
opacity: 1;
50+
animation-timing-function: linear;
4851
}
4952

5053
to {
5154
opacity: 0;
5255
}
5356
}
54-
55-
@keyframes mdc-ripple-fg-unbounded-transform-deactivate {
56-
from {
57-
transform: 0;
58-
transform: var(--mdc-ripple-fg-approx-xf, 0);
59-
}
60-
61-
to {
62-
transform: scale(0);
63-
transform: scale(var(--mdc-ripple-fg-scale, 0));
64-
}
65-
}

packages/mdc-ripple/_mixins.scss

Lines changed: 14 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,14 @@
2828
}
2929

3030
@mixin mdc-ripple-base() {
31+
--mdc-ripple-surface-width: 0;
32+
--mdc-ripple-surface-height: 0;
33+
--mdc-ripple-fg-size: 0;
3134
--mdc-ripple-left: 0;
3235
--mdc-ripple-top: 0;
33-
--mdc-ripple-fg-size: 0;
34-
--mdc-ripple-surface-height: 0;
35-
--mdc-ripple-surface-width: 0;
36-
--mdc-ripple-fg-unbounded-transform-duration: 0ms;
37-
--mdc-ripple-xfo-x: center;
38-
--mdc-ripple-xfo-y: center;
39-
--mdc-ripple-fg-unbounded-opacity-duration: 0ms;
40-
--mdc-ripple-fg-unbounded-transform-duration: 0ms;
41-
--mdc-ripple-fg-approx-xf: 0;
36+
--mdc-ripple-fg-scale: 1;
37+
--mdc-ripple-fg-translate-end: 0;
38+
--mdc-ripple-fg-translate-start: 0;
4239

4340
will-change: transform, opacity;
4441
-webkit-tap-highlight-color: rgba(0, 0, 0, 0);
@@ -121,18 +118,11 @@
121118
transform: scale(var(--mdc-ripple-fg-scale, 0));
122119
}
123120

124-
&.mdc-ripple-upgraded--background-active#{$pseudo} {
121+
&.mdc-ripple-upgraded--background-focused#{$pseudo} {
125122
opacity: .99999;
126123
}
127124

128-
// When an element goes active, a foreground ripple will be triggered.
129-
// Therefore, we adjust the transition duration for the correct "wind-
130-
// up" animation.
131-
&.mdc-ripple-upgraded--background-active:active#{$pseudo} {
132-
transition-duration: 600ms;
133-
}
134-
135-
&.mdc-ripple-upgraded--background-bounded-active-fill#{$pseudo} {
125+
&.mdc-ripple-upgraded--background-active-fill#{$pseudo} {
136126
transition-duration: 120ms;
137127
opacity: 1;
138128
}
@@ -215,29 +205,13 @@
215205
transform-origin: center center;
216206
}
217207

218-
&.mdc-ripple-upgraded--foreground-bounded-active-fill#{$pseudo} {
219-
animation-fill-mode: forwards;
220-
animation: 300ms mdc-ripple-fg-radius-in, 400ms mdc-ripple-fg-opacity-out;
221-
}
222-
223-
&.mdc-ripple-upgraded--unbounded.mdc-ripple-upgraded--foreground-unbounded-activation#{$pseudo} {
224-
transform: scale(0);
225-
transform: scale(var(--mdc-ripple-fg-scale, 0));
226-
transition:
227-
opacity 110ms linear,
228-
transform 0 linear 80ms;
229-
transition:
230-
opacity 110ms linear,
231-
transform var(--mdc-ripple-fg-unbounded-transform-duration, 0) linear 80ms;
232-
opacity: 1;
208+
&.mdc-ripple-upgraded--foreground-activation#{$pseudo} {
209+
animation: 300ms mdc-ripple-fg-radius-in forwards, 83ms mdc-ripple-fg-opacity-in forwards;
233210
}
234211

235-
&.mdc-ripple-upgraded--unbounded.mdc-ripple-upgraded--foreground-unbounded-deactivation#{$pseudo} {
236-
animation:
237-
mdc-ripple-fg-unbounded-opacity-deactivate 0 linear,
238-
mdc-ripple-fg-unbounded-transform-deactivate 0 $mdc-animation-fast-out-slow-in-timing-function;
239-
animation:
240-
mdc-ripple-fg-unbounded-opacity-deactivate var(--mdc-ripple-fg-unbounded-opacity-duration, 0) linear,
241-
mdc-ripple-fg-unbounded-transform-deactivate var(--mdc-ripple-fg-unbounded-transform-duration, 0) $mdc-animation-fast-out-slow-in-timing-function;
212+
&.mdc-ripple-upgraded--foreground-deactivation#{$pseudo} {
213+
// Retain transform from mdc-ripple-fg-radius-in activation
214+
transform: translate(var(--mdc-ripple-fg-translate-end, 0)) scale(var(--mdc-ripple-fg-scale, 1));
215+
animation: 250ms mdc-ripple-fg-opacity-out;
242216
}
243217
}

packages/mdc-ripple/constants.js

Lines changed: 15 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -14,43 +14,31 @@
1414
* limitations under the License.
1515
*/
1616

17-
export const ROOT = 'mdc-ripple';
18-
export const UPGRADED = `${ROOT}-upgraded`;
19-
2017
export const cssClasses = {
2118
// Ripple is a special case where the "root" component is really a "mixin" of sorts,
2219
// given that it's an 'upgrade' to an existing component. That being said it is the root
2320
// CSS class that all other CSS classes derive from.
24-
ROOT: UPGRADED,
25-
UNBOUNDED: `${UPGRADED}--unbounded`,
26-
BG_ACTIVE: `${UPGRADED}--background-active`,
27-
BG_BOUNDED_ACTIVE_FILL: `${UPGRADED}--background-bounded-active-fill`,
28-
FG_BOUNDED_ACTIVE_FILL: `${UPGRADED}--foreground-bounded-active-fill`,
29-
FG_UNBOUNDED_ACTIVATION: `${UPGRADED}--foreground-unbounded-activation`,
30-
FG_UNBOUNDED_DEACTIVATION: `${UPGRADED}--foreground-unbounded-deactivation`,
21+
ROOT: 'mdc-ripple-upgraded',
22+
UNBOUNDED: 'mdc-ripple-upgraded--unbounded',
23+
BG_FOCUSED: 'mdc-ripple-upgraded--background-focused',
24+
BG_ACTIVE_FILL: 'mdc-ripple-upgraded--background-active-fill',
25+
FG_ACTIVATION: 'mdc-ripple-upgraded--foreground-activation',
26+
FG_DEACTIVATION: 'mdc-ripple-upgraded--foreground-deactivation',
3127
};
3228

3329
export const strings = {
34-
VAR_SURFACE_WIDTH: `--${ROOT}-surface-width`,
35-
VAR_SURFACE_HEIGHT: `--${ROOT}-surface-height`,
36-
VAR_FG_SIZE: `--${ROOT}-fg-size`,
37-
VAR_FG_UNBOUNDED_OPACITY_DURATION: `--${ROOT}-fg-unbounded-opacity-duration`,
38-
VAR_FG_UNBOUNDED_TRANSFORM_DURATION: `--${ROOT}-fg-unbounded-transform-duration`,
39-
VAR_LEFT: `--${ROOT}-left`,
40-
VAR_TOP: `--${ROOT}-top`,
41-
VAR_TRANSLATE_END: `--${ROOT}-translate-end`,
42-
VAR_FG_APPROX_XF: `--${ROOT}-fg-approx-xf`,
43-
VAR_FG_SCALE: `--${ROOT}-fg-scale`,
44-
VAR_FG_TRANSLATE_START: `--${ROOT}-fg-translate-start`,
45-
VAR_FG_TRANSLATE_END: `--${ROOT}-fg-translate-end`,
30+
VAR_SURFACE_WIDTH: '--mdc-ripple-surface-width',
31+
VAR_SURFACE_HEIGHT: '--mdc-ripple-surface-height',
32+
VAR_FG_SIZE: '--mdc-ripple-fg-size',
33+
VAR_LEFT: '--mdc-ripple-left',
34+
VAR_TOP: '--mdc-ripple-top',
35+
VAR_FG_SCALE: '--mdc-ripple-fg-scale',
36+
VAR_FG_TRANSLATE_START: '--mdc-ripple-fg-translate-start',
37+
VAR_FG_TRANSLATE_END: '--mdc-ripple-fg-translate-end',
4638
};
4739

4840
export const numbers = {
49-
FG_TRANSFORM_DELAY_MS: 80,
50-
OPACITY_DURATION_DIVISOR: 3,
51-
ACTIVE_OPACITY_DURATION_MS: 110,
52-
MIN_OPACITY_DURATION_MS: 200,
53-
UNBOUNDED_TRANSFORM_DURATION_MS: 200,
5441
PADDING: 10,
5542
INITIAL_ORIGIN_SCALE: 0.6,
43+
DEACTIVATION_TIMEOUT_MS: 300,
5644
};

0 commit comments

Comments
 (0)