-
4 Jul 2012 1:14 AM #1
Answered: Destroy view on deactivate + animateActiveItem on Viewport
Answered: Destroy view on deactivate + animateActiveItem on Viewport
Hello,
I am new with Sencha Touch, so it may be a silly question. I am dynamically creating the views to insert in the Viewport, but I'd like to destroy them when they are not active anymore. They problem is that I am switching views with the function animateActiveItem(), and when I add on the listener "deactivate" to destroy the view, the animation doesnt happen, because the view is destroyed before the animation finish. I tried many things to solve it, but nothing really worked, one of the things I tried was basically this:
It didn't work because it made the app run slower, so sometimes the the app locks up for a second and it causes a bunch of problems. Anyway I think I shouldn't need to do it, there might be a better option. I also tried setting a timeout to destroy the view, but it does not work if the user switches screens too fast.HTML Code:Ext.Viewport.animateActiveItem(newView, { type: 'slide', direction: 'right', listeners: { animationend: function() { var items = Ext.Viewport.getItems().items; for (var i in items) { if (items[i].isHidden() === true) { items[i].destroy(); } } } } });
Anyone of you guys have an idea of how can I destroy the views after they're deactivated, but keeping the animation?
Thanks!
-
Best Answer Posted by mitchellsimoens
What happens when you add an activeitemchange event to the Ext.Viewport?
Code:Ext.Viewport.onAfter('activeitemchange', function() {...});
-
5 Jul 2012 12:17 PM #2Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,656
- Vote Rating
- 436
- Answers
- 3108
What happens when you add an activeitemchange event to the Ext.Viewport?
Code:Ext.Viewport.onAfter('activeitemchange', function() {...});Mitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
https://github.com/mitchellsimoens
Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/
Need more help with your app? Hire Sencha Services services@sencha.com
Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!
When posting code, please use BBCode's CODE tags.
-
5 Jul 2012 12:29 PM #3
I've gotten around this issue by using Ext.defer. My animations are set at about 250ms and i defer my destroy call by 300ms to let the animations finish before destroying the page.
-
11 Sep 2012 12:27 AM #4
Greetings -Ralf Kraus-
-
11 Sep 2012 4:50 AM #5Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,656
- Vote Rating
- 436
- Answers
- 3108
Mitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
https://github.com/mitchellsimoens
Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/
Need more help with your app? Hire Sencha Services services@sencha.com
Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!
When posting code, please use BBCode's CODE tags.
-
12 Sep 2012 4:46 AM #6
-
12 Sep 2012 4:47 AM #7
Is there a transition end event in Sencha ?
Greetings -Ralf Kraus-
-
12 Sep 2012 4:54 AM #8Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,656
- Vote Rating
- 436
- Answers
- 3108
What you need to do is change the order of things...
I usually use this on the container that has card layout on it:Code:cmp.onAfter('deactivate', function() {});
Code:container.onAfter('activeitemchange', function() {});Mitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
https://github.com/mitchellsimoens
Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/
Need more help with your app? Hire Sencha Services services@sencha.com
Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!
When posting code, please use BBCode's CODE tags.


Reply With Quote

