Skip to content

Commit 6f2e830

Browse files
authored
Optimize lodash import in spark.js
1 parent cd44475 commit 6f2e830

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

src/spark.js

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
1-
var assign = require('object-assign');
2-
var _ = require('lodash');
3-
var AnimationFrame = require('animation-frame');
4-
var EventEmitter = require('events').EventEmitter;
1+
const assign = require('object-assign');
2+
const AnimationFrame = require('animation-frame');
3+
const EventEmitter = require('events').EventEmitter;
4+
5+
const _clone = require('lodash/clone');
6+
const _extend = require('lodash/extend');
7+
const _isArray = require('lodash/isArray');
8+
const _isObject = require('lodash/isObject');
59

610
function sparkFactory({animator, formulas, actionProps, setup, invalidateAutomatically}) {
711

@@ -168,7 +172,7 @@ function sparkFactory({animator, formulas, actionProps, setup, invalidateAutomat
168172
if (!data) {
169173
return;
170174
}
171-
data = _.clone(data);
175+
data = _clone(data);
172176

173177
if (allowAnimation) {
174178
actor.removeAllKeyframes();
@@ -184,7 +188,7 @@ function sparkFactory({animator, formulas, actionProps, setup, invalidateAutomat
184188
const containerRect = container.getBoundingClientRect();
185189
for (scrY in data) {
186190
let keyFrame = data[scrY] || {};
187-
keyFrame = _.clone(keyFrame);
191+
keyFrame = _clone(keyFrame);
188192
let actionCount = 0;
189193
c = scrY.charCodeAt(0);
190194

@@ -208,7 +212,7 @@ function sparkFactory({animator, formulas, actionProps, setup, invalidateAutomat
208212
ease = {};
209213
let kfEase = elmEase;
210214
if (keyFrame.ease != null) {
211-
if (_.isObject(keyFrame.ease)) {
215+
if (_isObject(keyFrame.ease)) {
212216
ease = keyFrame.ease;
213217
} else {
214218
kfEase = keyFrame.ease;
@@ -230,12 +234,12 @@ function sparkFactory({animator, formulas, actionProps, setup, invalidateAutomat
230234
actionCount++;
231235
} else {
232236
keyFrame.anims || (keyFrame.anims = {});
233-
if (!_.isArray(v)) {
237+
if (!_isArray(v)) {
234238
v = [v, kfEase];
235239
}
236240
o = {};
237241
o[k] = v[1];
238-
_.extend(ease, o);
242+
_extend(ease, o);
239243
keyFrame.anims[k] = v[0];
240244
delete keyFrame[k];
241245
}

0 commit comments

Comments
 (0)