Skip to content

Commit

Permalink
chore(Animate): rename file to ts suffix
Browse files Browse the repository at this point in the history
  • Loading branch information
eternalsky committed Jan 13, 2024
1 parent 71f9004 commit 9fbc0aa
Show file tree
Hide file tree
Showing 9 changed files with 50 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ describe('Animate', () => {
}

it('should play appear animation', () => {
return co(function*() {
return co(function* () {
ReactDOM.render(<Demo visible />, mountNode);
const demo = document.querySelector('.basic-demo');
assert(hasClass(demo, 'my-zoom-appear'));
Expand All @@ -95,7 +95,7 @@ describe('Animate', () => {
});

it('should not play appear animation if set animationAppear to false', () => {
return co(function*() {
return co(function* () {
ReactDOM.render(<Demo visible animationAppear={false} />, mountNode);
const demo = document.querySelector('.basic-demo');
assert(!hasClass(demo, 'my-zoom-appear'));
Expand All @@ -105,7 +105,7 @@ describe('Animate', () => {
});

it('should play enter animation', () => {
return co(function*() {
return co(function* () {
ReactDOM.render(<Demo />, mountNode);
const btn = document.querySelector('button');
btn.click();
Expand All @@ -120,7 +120,7 @@ describe('Animate', () => {
});

it('should play leave animation', () => {
return co(function*() {
return co(function* () {
ReactDOM.render(<Demo visible animationAppear={false} />, mountNode);
const btn = document.querySelector('button');
btn.click();
Expand All @@ -134,7 +134,7 @@ describe('Animate', () => {
});

it('should support passing object to animation property', () => {
return co(function*() {
return co(function* () {
ReactDOM.render(
<Demo
animation={{
Expand Down Expand Up @@ -164,7 +164,7 @@ describe('Animate', () => {
});

it('should play expand animation', () => {
return co(function*() {
return co(function* () {
ReactDOM.render(<Demo visible={false} expand animation="expand" />, mountNode);
const btn = document.querySelector('button');
btn.click();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,11 @@ class Animate extends Component {
});

return (
<TransitionGroup appear={animationAppear} component={singleMode ? FirstChild : component} {...others}>
<TransitionGroup
appear={animationAppear}
component={singleMode ? FirstChild : component}
{...others}
>
{animateChildren}
</TransitionGroup>
);
Expand Down
38 changes: 29 additions & 9 deletions components/animate/child.jsx → components/animate/child.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -100,26 +100,44 @@ export default class AnimateChild extends Component {

this.node = node;
if (support.transition) {
const transitionEndListener = this.generateEndListener(node, done, 'transitionend', id);
const transitionEndListener = this.generateEndListener(
node,
done,
'transitionend',
id
);
on(node, 'transitionend', transitionEndListener);
this.endListeners.transitionend.push(transitionEndListener);
}
if (support.animation) {
const animationEndListener = this.generateEndListener(node, done, 'animationend', id);
const animationEndListener = this.generateEndListener(
node,
done,
'animationend',
id
);
on(node, 'animationend', animationEndListener);
this.endListeners.animationend.push(animationEndListener);
}

setTimeout(() => {
const transitionDelay = parseFloat(getStyleProperty(node, 'transition-delay')) || 0;
const transitionDuration = parseFloat(getStyleProperty(node, 'transition-duration')) || 0;
const transitionDuration =
parseFloat(getStyleProperty(node, 'transition-duration')) || 0;
const animationDelay = parseFloat(getStyleProperty(node, 'animation-delay')) || 0;
const animationDuration = parseFloat(getStyleProperty(node, 'animation-duration')) || 0;
const time = Math.max(transitionDuration + transitionDelay, animationDuration + animationDelay);
const animationDuration =
parseFloat(getStyleProperty(node, 'animation-duration')) || 0;
const time = Math.max(
transitionDuration + transitionDelay,
animationDuration + animationDelay
);
if (time) {
this.timeoutMap[id] = setTimeout(() => {
done();
}, time * 1000 + 200);
this.timeoutMap[id] = setTimeout(
() => {
done();
},
time * 1000 + 200
);
}
}, 15);
} else {
Expand Down Expand Up @@ -166,7 +184,9 @@ export default class AnimateChild extends Component {
handleEntered(node, isAppearing) {
const { names } = this.props;
if (names) {
const classNames = isAppearing ? [names.appear, names.appearActive] : [names.enter, names.enterActive];
const classNames = isAppearing
? [names.appear, names.appearActive]
: [names.enter, names.enterActive];
classNames.forEach(className => {
removeClass(node, className);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,14 @@ export default class Expand extends Component {

constructor(props) {
super(props);
func.bindCtx(this, ['beforeEnter', 'onEnter', 'afterEnter', 'beforeLeave', 'onLeave', 'afterLeave']);
func.bindCtx(this, [
'beforeEnter',
'onEnter',
'afterEnter',
'beforeLeave',
'onLeave',
'afterLeave',
]);
}

beforeEnter(node) {
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ const OverlayAnimate = props => {
}
});

const animationMap = typeof animation === 'string' ? { in: animation, out: animation } : animation;
const animationMap =
typeof animation === 'string' ? { in: animation, out: animation } : animation;

const animateClsMap = animation
? {
Expand Down
File renamed without changes.
File renamed without changes.

0 comments on commit 9fbc0aa

Please sign in to comment.