Skip to content

Commit

Permalink
Added missing componentWillUpdate in last commit
Browse files Browse the repository at this point in the history
  • Loading branch information
ConneXNL committed Feb 11, 2017
1 parent 5a208e0 commit 92832eb
Showing 1 changed file with 32 additions and 6 deletions.
38 changes: 32 additions & 6 deletions src/FlipMove.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,34 @@ class FlipMove extends Component {
this.runAnimation = this.runAnimation.bind(this);
}

componentWillUpdate(nextProps, nextState){

// We are clearing the previous styleBeforeRender as that is now history..
this.styleBeforeRender = {};

// We are going to save the current position of items that were already entering and leaving
// in order to be able to refresh their transition...

nextState.children.forEach((child) => {

// We are only saving the current position if the children have shuffled or its a leaving transition...
if (this.childrenHaveShuffled && (this.tracker.isEntering(child) || this.tracker.isLeaving(child))){

const childKey = child.key;
const { domNode } = this.childrenData[childKey];

if (domNode){
const {transform, opacity} = getComputedStyle(domNode);

this.styleBeforeRender[childKey] = {
transform,
opacity
};
}
}
});
}

componentWillReceiveProps(nextProps) {
// When the component is handed new props, we need to figure out the
// "resting" position of all currently-rendered DOM nodes.
Expand Down Expand Up @@ -210,7 +238,7 @@ class FlipMove extends Component {

calculateNextSetOfChildren(nextChildren) {

/*console.log("Old State...");
/*console.log("Old State...");
console.log(JSON.stringify(this.state.children.map((child) => ({
key: child.key,
status: this.tracker.getStatus(child.key)
Expand Down Expand Up @@ -276,7 +304,7 @@ class FlipMove extends Component {
// keep incrementing.
let numOfChildrenLeaving = 0;

/*console.log("Before:");
/*console.log("Before:");
console.log(this.state.children.map((child) => child.key));
console.log("New children order:");
Expand Down Expand Up @@ -347,7 +375,7 @@ class FlipMove extends Component {
});


/*console.log("After:");
/*console.log("After:");
console.log(updatedChildren.map((child) => child.key));
console.log(JSON.stringify(updatedChildren.map((child) => ({
key: child.key,
Expand All @@ -364,7 +392,7 @@ class FlipMove extends Component {
);

/*console.log("Shuffled:");
console.log(this.childrenHaveShuffled);*/
console.log(this.childrenHaveShuffled);*/


return updatedChildren;
Expand Down Expand Up @@ -645,8 +673,6 @@ class FlipMove extends Component {
triggerFinishHooks(child, domNode) {
if (this.props.onFinish) this.props.onFinish(child, domNode);

//console.log(Object.keys(this.transitionEndHandlerMap).length);

// We check if all transitionEndHandlers have finished...
if (Object.keys(this.transitionEndHandlerMap).length === 0) {

Expand Down

0 comments on commit 92832eb

Please sign in to comment.