Answered by:
Crash while executing endAnimatedJump method in a Flip view

Question
-
Hi, I experiencing a crash while executing endAnimatedJump method in a Flip view.
I have a flip view that is running an animation and the view change the callback for endAnimatedJump is executed in a page that was already unloaded. Is there any way to avoid the execution or to advise that DOM object doesn't exists anymore?
endAnimatedJump: function (oldCurr, newCurr) { if (this._navigationAnimationRecord.oldCurrentPage) { this._navigationAnimationRecord.oldCurrentPage.setElement(oldCurr.element, true); } else { oldCurr.element.parentNode.removeChild(oldCurr.element); } this._navigationAnimationRecord.newCurrentPage.setElement(newCurr.element, true); this._navigationAnimationRecord = null; this._ensureCentered(); this._itemSettledOn();
//The parentNode element is null here.
oldCurr.element.parentNode.removeChild(oldCurr.element);
- Edited by PabloCargnelutti Monday, August 13, 2012 8:54 PM
Monday, August 13, 2012 8:52 PM
Answers
-
Hi Ces,
There is a potential fix you can apply to override this problem. You would need to override some code however.
What you would do is get a reference to your flip view (flip in the code below) and override the problem:
flip._pageManager.endAnimatedJump = function (oldCurr, newCurr) { if (this._navigationAnimationRecord.oldCurrentPage) { this._navigationAnimationRecord.oldCurrentPage.setElement(oldCurr.element, true); } else { if (oldCurr.element.parentNode) { oldCurr.element.parentNode.removeChild(oldCurr.element); } } this._navigationAnimationRecord.newCurrentPage.setElement(newCurr.element, true); this._navigationAnimationRecord = null; this._ensureCentered(); this._itemSettledOn(); };
-JeffJeff Sanders (MSFT)
- Marked as answer by Matt SmallMicrosoft employee, Moderator Friday, April 26, 2013 7:22 PM
Tuesday, September 25, 2012 2:25 PMModerator
All replies
-
How about simply testing oldCurr.element.parentNode for null?
Jeff Sanders (MSFT)
- Proposed as answer by Jeff SandersMicrosoft employee, Moderator Tuesday, August 14, 2012 12:42 PM
- Unproposed as answer by PabloCargnelutti Tuesday, August 14, 2012 12:52 PM
Tuesday, August 14, 2012 12:42 PMModerator -
I can't do that since the code is part of the WinJS library :(Tuesday, August 14, 2012 12:47 PM
-
What is the file and line number? How can I reproduce this issue (pust a simple sample perhaps)?
Jeff Sanders (MSFT)
Tuesday, August 14, 2012 12:54 PMModerator -
File: endAnimatedJump [ui.js] Line 12595
The issue is easy reproduced: You create a Filp view with a component and while it being animated you go to another page. What happens is that the call back endAnimatedJump is executed in the new page but trying to refer to the filp view component that was already unloaded.
Tuesday, August 14, 2012 1:09 PM -
This solution may not be ideal but what we have done is called FlipView.next() until it reaches the end, then we call FlipView.previous() until it reaches the start in a loop. This seems to run quick enough that it doesn't look to bad.
We were informed that no more fixes will be available before launch, which includes a fix to the FlipView.currentPage setter.
This is the code which gets executed at our set interval:
if (!FlipView.next()) { for (var i = 0; i < FlipViewItemCount; i++) { FlipView.previous(); } }
Friday, September 14, 2012 2:37 PM -
Hi Ces,
There is a potential fix you can apply to override this problem. You would need to override some code however.
What you would do is get a reference to your flip view (flip in the code below) and override the problem:
flip._pageManager.endAnimatedJump = function (oldCurr, newCurr) { if (this._navigationAnimationRecord.oldCurrentPage) { this._navigationAnimationRecord.oldCurrentPage.setElement(oldCurr.element, true); } else { if (oldCurr.element.parentNode) { oldCurr.element.parentNode.removeChild(oldCurr.element); } } this._navigationAnimationRecord.newCurrentPage.setElement(newCurr.element, true); this._navigationAnimationRecord = null; this._ensureCentered(); this._itemSettledOn(); };
-JeffJeff Sanders (MSFT)
- Marked as answer by Matt SmallMicrosoft employee, Moderator Friday, April 26, 2013 7:22 PM
Tuesday, September 25, 2012 2:25 PMModerator -
Thanks Jeff. I've gone ahead and used this workaround.Monday, October 1, 2012 11:40 AM
-
Unfortunatly, Jeff, flip._pageManager is undefined, but hopefully, flip.winControl._pageManager works. :)
- Edited by Antoine Cœur Thursday, April 18, 2013 2:41 PM
Thursday, April 18, 2013 2:39 PM -
Give it a shot. This post is almost a year old and things have changed since the preview. You can post your results here to help others!
-Jeff
Jeff Sanders (MSFT)
Thursday, April 18, 2013 2:46 PMModerator