Skip to content
This repository has been archived by the owner on Aug 29, 2023. It is now read-only.

feat(ripple): smooths out ripple animations #1750

Closed
wants to merge 1 commit into from
Closed
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
21 changes: 11 additions & 10 deletions src/core/services/ripple/ripple.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ function InkRippleService($window, $timeout) {

function attachButtonBehavior(scope, element, options) {
return attach(scope, element, angular.extend({
isFAB: element.hasClass('md-fab'),
fullRipple: true,
isMenuItem: element.hasClass('md-menu-item'),
center: false,
dimBackground: true
Expand All @@ -51,7 +51,8 @@ function InkRippleService($window, $timeout) {
return attach(scope, element, angular.extend({
center: false,
dimBackground: true,
outline: true
outline: false,
rippleSize: 'full'
}, options));
}

Expand All @@ -67,7 +68,7 @@ function InkRippleService($window, $timeout) {
mousedownPauseTime: 150,
dimBackground: false,
outline: false,
isFAB: false,
fullRipple: true,
isMenuItem: false,
fitRipple: false
}, options);
Expand All @@ -86,10 +87,10 @@ function InkRippleService($window, $timeout) {

switch (rippleSizeSetting) {
case 'full':
options.isFAB = true;
options.fullRipple = true;
break;
case 'partial':
options.isFAB = false;
options.fullRipple = false;
break;
}

Expand Down Expand Up @@ -283,7 +284,7 @@ function InkRippleService($window, $timeout) {
height = Math.max(top, height - top);
size = 2 * Math.sqrt(Math.pow(width, 2) + Math.pow(height, 2));
} else {
multiplier = options.isFAB ? 1.1 : 0.8;
multiplier = options.fullRipple ? 1.1 : 0.8;
size = Math.sqrt(Math.pow(width, 2) + Math.pow(height, 2)) * multiplier;
if (options.fitRipple) {
size = Math.min(height, width, size);
Expand All @@ -299,7 +300,7 @@ function InkRippleService($window, $timeout) {
* @param {number} the left cursor offset
* @param {number} the top cursor offset
*
* @returns {{backgroundColor: *, width: string, height: string, marginLeft: string, marginTop: string}}
* @returns {{backgroundColor: string, borderColor: string, width: string, height: string}}
*/
function getRippleCss(size, left, top) {
var rect,
Expand Down Expand Up @@ -335,7 +336,7 @@ function InkRippleService($window, $timeout) {
* @returns {string} rgb color
*/
function rgbaToRGB(color) {
return color.replace('rgba', 'rgb').replace(/,[^\)\,]+\)/, ')');
return color.replace('rgba', 'rgb').replace(/,[^\),]+\)/, ')');
}
}
}
Expand All @@ -347,10 +348,10 @@ function InkRippleService($window, $timeout) {
function onPressDown(ev) {
if (!isRippleAllowed()) return;

var ripple = createRipple(ev.pointer.x, ev.pointer.y);
createRipple(ev.pointer.x, ev.pointer.y);
isHeld = true;
}
function onPressUp(ev) {
function onPressUp() {
isHeld = false;
var ripple = ripples[ ripples.length - 1 ];
$timeout(function () { updateElement(ripple); }, 0, false);
Expand Down
20 changes: 12 additions & 8 deletions src/core/style/structure.scss
Original file line number Diff line number Diff line change
Expand Up @@ -203,14 +203,16 @@ input {
opacity: 0;
border-radius: 50%;
&.md-ripple-placed {
transition: left 0.9s $swift-ease-out-timing-function,
top 0.9s $swift-ease-out-timing-function,
margin 0.65s $swift-ease-out-timing-function,
border 0.65s $swift-ease-out-timing-function,
width 0.65s $swift-ease-out-timing-function,
height 0.65s $swift-ease-out-timing-function,
opacity 0.65s $swift-ease-out-timing-function,
transform 0.65s $swift-ease-out-timing-function;
$positionDuration: 0.9s * 2;
$sizeDuration: 0.65s * 2;
transition: left $positionDuration $swift-ease-out-timing-function,
top $positionDuration $swift-ease-out-timing-function,
margin $sizeDuration $swift-ease-out-timing-function,
border $sizeDuration $swift-ease-out-timing-function,
width $sizeDuration $swift-ease-out-timing-function,
height $sizeDuration $swift-ease-out-timing-function,
opacity $sizeDuration $swift-ease-out-timing-function,
transform $sizeDuration $swift-ease-out-timing-function;
}
&.md-ripple-scaled {
transform: scale(1);
Expand All @@ -220,6 +222,7 @@ input {
}
}

/*
md-tab {
> .md-ripple-container {
.md-ripple {
Expand All @@ -237,6 +240,7 @@ md-tab {
}
}
}
*/

@function map-to-string($map) {
$map-str: '{';
Expand Down