Skip to content

Commit 7ce836a

Browse files
committed
add currentRef
1 parent 4c3cc68 commit 7ce836a

File tree

4 files changed

+13
-4
lines changed

4 files changed

+13
-4
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,8 @@ React.render(<TweenOneGroup>
9292

9393
### props
9494

95+
> 2.5.x add currentRef, `<TweenOne component={Row} ref={(c) => { c.currentRef === <Row /> }} />`
96+
9597
| name | type | default | description |
9698
|------------|----------------|---------|----------------|
9799
| animation | object / array | null | animate configure parameters |

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "rc-tween-one",
3-
"version": "2.4.1",
3+
"version": "2.5.0",
44
"description": "tween-one anim component for react",
55
"keywords": [
66
"react",

src/TweenOne.jsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ class TweenOne extends Component {
4747
this.updateAnim = false;
4848
this.repeatNum = 0;
4949
this.forced = {};
50+
this.currentRef = null;
5051
this.setForcedJudg(props);
5152
}
5253

@@ -337,7 +338,13 @@ class TweenOne extends Component {
337338
const newClassName = props.className ? `${props.className} ${className}` : className;
338339
return React.cloneElement(this.props.children, { style: newStyle, className: newClassName });
339340
}
340-
return React.createElement(this.props.component, { ...props, ...this.props.componentProps });
341+
return React.createElement(this.props.component, {
342+
ref: (c) => {
343+
this.currentRef = c;
344+
},
345+
...props,
346+
...this.props.componentProps
347+
});
341348
}
342349
}
343350
TweenOne.isTweenOne = true;

src/util.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -294,8 +294,8 @@ export function getTransformValue(t) {
294294
const rX = rotateX ? `rotateX(${rotateX}deg)` : '';
295295
const rY = rotateY ? `rotateY(${rotateY}deg)` : '';
296296
const per = perspective ? `perspective(${perspective}px)` : '';
297-
const defautlTranslate = (ss || an || rX || rY || sk) ? '' : 'translate(0px, 0px)';
297+
const defaultTranslate = (ss || an || rX || rY || sk) ? '' : 'translate(0px, 0px)';
298298
const translate = t.translateZ ? `translate3d(${translateX},${translateY},${translateZ})` :
299-
(t.translateX || t.translateY) && `translate(${translateX},${translateY})` || defautlTranslate;
299+
(t.translateX || t.translateY) && `translate(${translateX},${translateY})` || defaultTranslate;
300300
return `${per} ${translate} ${ss} ${an} ${rX} ${rY} ${sk}`.trim();
301301
}

0 commit comments

Comments
 (0)