Skip to content
This repository was archived by the owner on Sep 5, 2024. It is now read-only.

Commit 96014e0

Browse files
committed
fix(ripple): use css animations for performance
1 parent 6b99c1b commit 96014e0

20 files changed

Lines changed: 397 additions & 752 deletions

File tree

config/build.config.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,8 @@ module.exports = {
6969

7070
// Ink Components
7171
'src/components/animate/effects.js',
72-
'src/components/animate/canvas/rippler.js',
7372
'src/components/animate/noEffect.js',
74-
'src/components/animate/inkRipple.js',
73+
'src/components/animate/inkCssRipple.js',
7574

7675
// Components
7776
'src/components/buttons/buttons.js',

docs/app/index.html

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,18 +25,18 @@ <h1 class="material-toolbar-tools" style="padding-top:25px;">
2525

2626
<button class="menu-item menu-title"
2727
ng-class="{active: menu.isSectionSelected(section)}"
28-
ng-click="menu.toggleSelectSection(section)">
28+
ng-click="menu.toggleSelectSection(section)"
29+
ink-ripple>
2930
{{section.name}}
30-
<material-ripple initial-opacity="0.4" opacity-decay-velocity="1.75"></material-ripple>
3131
</button>
3232

3333
<button class="menu-item menu-sub-item"
3434
ng-show="menu.isSectionSelected(section)"
3535
ng-repeat="page in section.pages"
3636
ng-class="{active: menu.isPageSelected(section, page)}"
37-
ng-mousedown="menu.selectPage(section, page)">
37+
ng-click="menu.selectPage(section, page)"
38+
ink-ripple>
3839
<span ng-bind="page.humanName || page.name"></span>
39-
<material-ripple initial-opacity="0.4" opacity-decay-velocity="1.75"></material-ripple>
4040
</button>
4141

4242
</div>
@@ -88,7 +88,7 @@ <h3 ng-bind="menu.currentPage.humanName || menu.currentPage.name || 'Angular Mat
8888
<span hide block-sm>View on Github</span>
8989
<span hide-sm>Source</span>
9090
</material-button>
91-
<material-button ng-href="{{currentDoc.githubEditUrl}}" hide block-sm>
91+
<material-button ng-href="{{currentDoc.githubEditUrl}}" hide show-sm>
9292
<material-icon icon="/img/icons/ic_launch_24px.svg"></material-icon>
9393
<span>Improve This Doc</span>
9494
</material-button>

src/base/_layout.scss

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,10 @@
114114
display: none;
115115
}
116116

117+
[show] {
118+
display: inherit;
119+
}
120+
117121

118122
@mixin layout-presets($attr) {
119123
[#{$attr}] {
@@ -186,6 +190,10 @@
186190
display: inline-block;
187191
}
188192

193+
[show-#{$suffix}] {
194+
display: inherit;
195+
}
196+
189197
[hide-#{$suffix}] {
190198
display: none;
191199
}

src/base/_mixins.scss

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,14 @@
5151
-ms-user-select: $val;
5252
user-select: $val;
5353
}
54+
@mixin keyframes($name) {
55+
@-webkit-keyframes #{$name} {
56+
@content;
57+
}
58+
@keyframes #{$name} {
59+
@content;
60+
}
61+
}
5462

5563
@mixin margin-selectors($before:1em, $after:1em, $start:0px, $end:0px) {
5664
-webkit-margin-before: $before;

src/components/animate/_effects.scss

Lines changed: 47 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,54 @@ material-ink-bar {
55
margin-top: -2px;
66
}
77

8-
canvas.material-ink-ripple {
9-
pointer-events: none !important;
8+
// Button ripple: keep same opacity, but expand to 0.75 scale.
9+
// Then, fade out and expand to 2.0 scale.
10+
@include keyframes(inkRippleButton) {
11+
0% {
12+
@include transform(scale(0));
13+
opacity: 0.15;
14+
}
15+
50% {
16+
@include transform(scale(0.75));
17+
opacity: 0.15;
18+
}
19+
100% {
20+
@include transform(scale(2.0));
21+
opacity: 0;
22+
}
23+
}
24+
25+
// Checkbox ripple: fully expand, then fade out.
26+
@include keyframes(inkRippleCheckbox) {
27+
0% {
28+
@include transform(scale(0));
29+
opacity: 0.4;
30+
}
31+
50% {
32+
@include transform(scale(2.7));
33+
opacity: 0.4;
34+
}
35+
100% {
36+
@include transform(scale(2.7));
37+
opacity: 0;
38+
}
39+
}
40+
41+
/*
42+
* A container inside of a rippling element (eg a button),
43+
* which contains all of the individual ripples
44+
*/
45+
.material-ripple-container {
46+
pointer-events: none;
1047
position: absolute;
11-
top: 0;
48+
overflow: hidden;
1249
left: 0;
50+
top: 0;
51+
width: 100%;
52+
height: 100%;
1353
}
14-
material-tabs .material-ink-ripple {
15-
color: #f0f495;
54+
55+
.material-ripple {
56+
z-index: 0;
57+
position: absolute;
1658
}

0 commit comments

Comments
 (0)