Skip to content

Commit

Permalink
Fix ripple
Browse files Browse the repository at this point in the history
  • Loading branch information
javivelasco committed Aug 21, 2016
1 parent 0dcec60 commit 006559e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
12 changes: 4 additions & 8 deletions components/ripple/Ripple.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { themr } from 'react-css-themr';
import { RIPPLE } from '../identifiers.js';
import events from '../utils/events';
import prefixer from '../utils/prefixer';
import utils from '../utils/utils';

const defaults = {
centered: false,
Expand Down Expand Up @@ -84,12 +85,7 @@ const rippleFactory = (options = {}) => {
if (e.propertyName === 'opacity') {
if (self.props.onRippleEnded) self.props.onRippleEnded(e);
events.removeEventListenerOnTransitionEnded(self.refs[rippleKey], onOpacityEnd);
self.setState({ ripples: update(self.state.ripples, {
[rippleKey]: { $apply: ripplesState => {
delete ripplesState[rippleKey];
return ripplesState;
} }
}) });
self.setState({ ripples: utils.removeObjectKey(rippleKey, self.state.ripples) });
}
});
}
Expand Down Expand Up @@ -160,7 +156,7 @@ const rippleFactory = (options = {}) => {
*/
getNextKey () {
this.currentCount = this.currentCount ? this.currentCount + 1 : 1;
return this.currentCount.toString();
return `ripple${this.currentCount}`;
}

/**
Expand All @@ -170,7 +166,7 @@ const rippleFactory = (options = {}) => {
* @return {String} The last generated ripple key.
*/
getLastKey () {
return this.currentCount.toString();
return `ripple${this.currentCount}`;
}

/**
Expand Down
8 changes: 8 additions & 0 deletions components/utils/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,5 +56,13 @@ export default {
return value ? 'on' : '';
}
return value;
},

removeObjectKey (key, object) {
const newObject = {};
Object.keys(object)
.filter(k => k !== key)
.forEach(k => { newObject[k] = object[k]; });
return newObject;
}
};

0 comments on commit 006559e

Please sign in to comment.