Skip to content

Commit 85c2533

Browse files
committed
fix server render
1 parent 41b342f commit 85c2533

File tree

2 files changed

+36
-33
lines changed

2 files changed

+36
-33
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "rc-queue-anim",
3-
"version": "0.11.8",
3+
"version": "0.11.9",
44
"description": "Queue animation component for react",
55
"keywords": [
66
"react",

src/QueueAnim.jsx

Lines changed: 35 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,6 @@
11
import React, { createElement, cloneElement } from 'react';
22
import { findDOMNode } from 'react-dom';
33

4-
let velocity;
5-
if (typeof document !== 'undefined' && typeof window !== 'undefined') {
6-
// only load velocity on the client
7-
velocity = require('velocity-animate');
8-
} else {
9-
// provide a velocity stub for the server
10-
velocity = function velocityServerDummy() {
11-
const callback = arguments[arguments.length - 1];
12-
// call after stack flushes
13-
// in case you app depends on the asyncron nature of this function
14-
setImmediate(function() {
15-
callback();
16-
});
17-
};
18-
}
19-
20-
import {
21-
toArrayChildren,
22-
findChildInChildrenByKey,
23-
mergeChildren,
24-
transformArguments,
25-
getChildrenFromProps,
26-
} from './utils';
27-
import AnimTypes from './animTypes';
28-
const BackEase = {
29-
easeInBack: [0.6, -0.28, 0.735, 0.045],
30-
easeOutBack: [0.175, 0.885, 0.32, 1.275],
31-
easeInOutBack: [0.68, -0.55, 0.265, 1.55],
32-
};
334
const _ease = {
345
easeInElastic: function(_p, o, t) {
356
let p = _p;
@@ -96,9 +67,41 @@ const _ease = {
9667
},
9768
};
9869

99-
Object.keys(_ease).forEach(key => {
100-
velocity.Easings[key] = _ease[key];
101-
});
70+
let velocity;
71+
if (typeof document !== 'undefined' && typeof window !== 'undefined') {
72+
// only load velocity on the client
73+
velocity = require('velocity-animate');
74+
Object.keys(_ease).forEach(key => {
75+
if (velocity.Easings) {
76+
velocity.Easings[key] = _ease[key];
77+
}
78+
});
79+
} else {
80+
// provide a velocity stub for the server
81+
velocity = function velocityServerDummy() {
82+
const callback = arguments[arguments.length - 1];
83+
// call after stack flushes
84+
// in case you app depends on the asyncron nature of this function
85+
setImmediate(function() {
86+
callback();
87+
});
88+
};
89+
}
90+
91+
import {
92+
toArrayChildren,
93+
findChildInChildrenByKey,
94+
mergeChildren,
95+
transformArguments,
96+
getChildrenFromProps,
97+
} from './utils';
98+
import AnimTypes from './animTypes';
99+
const BackEase = {
100+
easeInBack: [0.6, -0.28, 0.735, 0.045],
101+
easeOutBack: [0.175, 0.885, 0.32, 1.275],
102+
easeInOutBack: [0.68, -0.55, 0.265, 1.55],
103+
};
104+
102105
const placeholderKeyPrefix = 'ant-queue-anim-placeholder-';
103106

104107
class QueueAnim extends React.Component {

0 commit comments

Comments
 (0)