Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions examples/dialog-style.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
placeholder
54 changes: 54 additions & 0 deletions examples/dialog-style.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import QueueAnim from 'rc-queue-anim';
import React from 'react';
import ReactDom from 'react-dom';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ReactDOM


import Dialog from 'rc-dialog';
import 'rc-dialog/assets/index.css';

const App = React.createClass({
getInitialState() {
return {
show: false
};
},
onClick() {
this.setState({
show: true,
});
},
onClose() {
this.setState({
show: false
});
},
render() {
let dialog;
if (this.state.show) {
dialog = <Dialog visible={this.state.show}
animation="zoom"
maskAnimation="fade"
onClose={this.onClose}
style={{width: 600}}
title={<div> 第二个弹框</div>}>
<QueueAnim>
<div key="1">依次进入</div>
<div key="2">依次进入</div>
<div key="3">依次进入</div>
<div key="4">依次进入</div>
</QueueAnim>
</Dialog>
}
return <div>
<QueueAnim type={['right', 'left']} interval={[100, 200]} delay={[0, 1000]} duration={[500, 2000]} ease={['easeOutBack', 'easeInOutCirc']} leaveReverse={true}>
<div key="1">依次进入</div>
<div key="2">依次进入</div>
<div key="3">依次进入</div>
<div key="4">依次进入</div>
{dialog}
</QueueAnim>
<button onClick={this.onClick}>弹出框口</button>
</div>;
}
});

ReactDom.render(<App />, document.getElementById('__react-content'));
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
"precommit-hook": "1.x",
"rc-server": "3.x",
"rc-tools": "4.x",
"rc-dialog":"~5.2.1",
"react": "~0.14.0",
"react-addons-test-utils": "~0.14.0",
"react-dom": "~0.14.0",
Expand Down
6 changes: 6 additions & 0 deletions src/QueueAnim.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ class QueueAnim extends React.Component {
});

nextChildren.forEach((c)=> {
if (!c) {
return;
}
const key = c.key;
const hasPrev = findChildInChildrenByKey(currentChildren, key);
if (!hasPrev && key) {
Expand All @@ -78,6 +81,9 @@ class QueueAnim extends React.Component {
});

currentChildren.forEach((c)=> {
if (!c) {
return;
}
const key = c.key;
const hasNext = findChildInChildrenByKey(nextChildren, key);
if (!hasNext && key) {
Expand Down
10 changes: 8 additions & 2 deletions src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export function findChildInChildrenByKey(children, key) {
let ret = null;
if (children) {
children.forEach((c) => {
if (ret) {
if (ret || !c) {
return;
}
if (c.key === key) {
Expand All @@ -30,17 +30,23 @@ export function mergeChildren(prev, next) {
const nextChildrenPending = {};
let pendingChildren = [];
prev.forEach((c) => {
if (!c) {
return;
}
if (findChildInChildrenByKey(next, c.key)) {
if (pendingChildren.length) {
nextChildrenPending[c.key] = pendingChildren;
pendingChildren = [];
}
} else {
} else if (c.key) {
pendingChildren.push(c);
}
});

next.forEach((c) => {
if (!c) {
return;
}
if (nextChildrenPending.hasOwnProperty(c.key)) {
ret = ret.concat(nextChildrenPending[c.key]);
}
Expand Down