Fix ripple

old
Javi Velasco 2016-08-21 18:44:04 +02:00
parent 0dcec60d31
commit 006559e7cc
2 changed files with 12 additions and 8 deletions

View File

@ -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,
@ -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) });
}
});
}
@ -160,7 +156,7 @@ const rippleFactory = (options = {}) => {
*/
getNextKey () {
this.currentCount = this.currentCount ? this.currentCount + 1 : 1;
return this.currentCount.toString();
return `ripple${this.currentCount}`;
}
/**
@ -170,7 +166,7 @@ const rippleFactory = (options = {}) => {
* @return {String} The last generated ripple key.
*/
getLastKey () {
return this.currentCount.toString();
return `ripple${this.currentCount}`;
}
/**

View File

@ -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;
}
};