Skip to content

Commit e694bc3

Browse files
committed
rm deep-eql,fix timeline repeat callback, update d.ts
1 parent 2ad808c commit e694bc3

File tree

5 files changed

+36
-9
lines changed

5 files changed

+36
-9
lines changed

package.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "rc-tween-one",
3-
"version": "2.2.9",
3+
"version": "2.2.10",
44
"description": "tween-one anim component for react",
55
"keywords": [
66
"react",
@@ -34,7 +34,9 @@
3434
"assets/*.css",
3535
"dist",
3636
"es",
37-
"index.d.ts"
37+
"typings/index.d.ts",
38+
"typings/AnimObject.d.ts",
39+
"typings/TweenOneGroup.d.ts"
3840
],
3941
"licenses": "MIT",
4042
"main": "./lib/index",
@@ -82,10 +84,9 @@
8284
"dependencies": {
8385
"prop-types": "^15.6.1",
8486
"babel-runtime": "6.x",
85-
"deep-eql": "~3.0.1",
8687
"raf": "~3.4.0",
8788
"style-utils": "~0.1.13",
8889
"tween-functions": "~1.2.0"
8990
},
90-
"types": "typeings/index.d.ts"
91+
"types": "typings/index.d.ts"
9192
}

src/TweenOne.jsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,7 @@ class TweenOne extends Component {
250250
...e,
251251
timelineMode: '',
252252
};
253+
253254
if (
254255
(this.moment === this.startMoment &&
255256
(!this.reverse && !e.index && e.mode === 'onStart') ||
@@ -266,10 +267,10 @@ class TweenOne extends Component {
266267
} else {
267268
cb.timelineMode = 'onTimelineUpdate';
268269
}
270+
this.timelineRepeatNum = repeatNum;
269271
this.props.onChange(cb);
270272
};
271273
this.moment = moment;
272-
this.timelineRepeatNum = repeatNum;
273274
this.tween.frame(tweenMoment);
274275
}
275276

src/util.js

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import React from 'react';
2-
import deepEql from 'deep-eql';
32

43
export const windowIsUndefined = !(
54
typeof window !== 'undefined' &&
@@ -25,6 +24,26 @@ export function dataToArray(vars) {
2524
return [vars];
2625
}
2726

27+
function deepEql(a, b) {
28+
if (!a || !b) {
29+
return false;
30+
}
31+
const $a = Object.keys(a);
32+
const $b = Object.keys(b);
33+
if ($a.length && $b.length && $a.length === $b.length) {
34+
return !$a.some((key) => {
35+
let aa = a[key];
36+
let bb = b[key];
37+
if (Array.isArray(aa) && Array.isArray(bb)) {
38+
aa = aa.join();
39+
bb = bb.join();
40+
}
41+
return aa !== bb;
42+
});
43+
}
44+
return false;
45+
}
46+
2847
export function objectEqual(obj1, obj2) {
2948
if (obj1 === obj2 || deepEql(obj1, obj2)) {
3049
return true;
@@ -51,6 +70,8 @@ export function objectEqual(obj1, obj2) {
5170
}
5271
} else {
5372
equalBool = false;
73+
}
74+
if (!equalBool) {
5475
return false;
5576
}
5677
}

typings/TweenOneGroup.d.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,17 @@ import * as React from 'react';
22

33
import { IAnimObject, IEaseCallBack } from './AnimObject';
44

5-
export interface IGroupProps {
5+
import { Omit } from './index';
6+
7+
export interface IGroupProps<T> extends Omit<React.HTMLAttributes<T>, 'onChange'> {
68
appear?: boolean;
79
enter?: IAnimObject | IAnimObject[] | ((key: string, index: number) => IAnimObject);
810
leave?: IAnimObject | IAnimObject[] | ((key: string, index: number) => IAnimObject);
9-
animatingClassName?: [string, string];
11+
animatingClassName?: string[] | [string, string];
1012
exclusive?: boolean;
1113
onEnd?: (e: { key: string, type: string }) => void;
1214
component?: string | React.ReactNode;
1315
componentProps?: {};
1416
}
1517

16-
export default class RcTweenOneGroup extends React.Component<IGroupProps>{ }
18+
export default class RcTweenOneGroup<T> extends React.Component<IGroupProps<T>>{ }

typings/index.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ export interface IProps<T> extends Omit<React.HTMLAttributes<T>, 'onChange'> {
3434
componentProps?: {};
3535
}
3636

37+
export const TweenOneGroup: typeof Group;
38+
3739
export default class RcTweenOne<T> extends React.Component<IProps<T>> {
3840
static easing: {
3941
path(path: string, parame?: { rect?: number, lengthPixel?: number }): IEaseCallBack;

0 commit comments

Comments
 (0)