-
29 Sep 2012 4:28 AM #1
Answered: Painted event in Navigation View
Answered: Painted event in Navigation View
I am trying to use the painted event of a Container that is pushed into a Navigation View, because I need to get an element position inside the Container:
ex:
'main' is the navigation view
However, because of the animation of the navigation view I have to add a delay to the painted event (as shown above) otherwise the position retrieved by the getBox function is not correct.Code:main.push({ xtype: 'container', listeners: [ { fn: 'onContainerPainted', delay: 500, event: 'painted' } ] onContainerPainted: function(component, options) { var box = component.down('#myId').element.getBox(); // do something with box } });
Is there any way to fire an event only after the push/pop animation ends ? I've also tryed the push/pop event, but that did not work either since these events are fired before the painted event.
Thank you.
-
Best Answer Posted by pvmagacho
For any Panel that uses card layout the following code works pretty well.
Code:Ext.Viewport.getLayout().setAnimation({ type: 'slide', duration: 200 }); var animation = Ext.Viewport.getLayout().getAnimation(); animation.on({ animationend: function() { // do stuff }, scope: Ext.Viewport, single: true }); Ext.Viewport.setActiveItem(Ext.create('MyApp.view.NextView'));
-
1 Oct 2012 5:56 AM #2Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,599
- Vote Rating
- 435
- Answers
- 3102
Instead of painted, have you tried activated?
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.
-
1 Oct 2012 9:59 AM #3
I will try that out.
What is the difference between both events ?
After the acvitate event, will the DOM will already be all in place in the same way as the painted event ?
Thank you.
-
1 Oct 2012 10:04 AM #4Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,599
- Vote Rating
- 435
- Answers
- 3102
painted fires right before the elements are inserted into the DOM. The activate event fires when that component is made active by the container (in this case the nagivation view).
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.
-
1 Oct 2012 10:16 AM #5
I am still a bit confused.
From the documentation I have the following statements:
activate: "Fires whenever item within the Container is activated"
painted: "Fires whenever this Component actually becomes visible (painted) on the screen. This is useful when you need to perform 'read' operations on the DOM element, i.e: calculating natural sizes and positioning."
Since I need to know the Container position, I've used the painted event. From what you're saying is that the activate event will be fired after the painted event and with the final position of the elements, when the animation of the navigation view has ended, correct ?
Thanks,
-
8 Oct 2012 4:23 PM #6
I've tested with both activated and painted. However, both of them did not work. I need to attach to the animationend event, but this is fired privately.
Any help on how to attach to end of the animation of the push event on a navigation view ?
Thanks
-
7 Nov 2012 7:11 AM #7
For any Panel that uses card layout the following code works pretty well.
Code:Ext.Viewport.getLayout().setAnimation({ type: 'slide', duration: 200 }); var animation = Ext.Viewport.getLayout().getAnimation(); animation.on({ animationend: function() { // do stuff }, scope: Ext.Viewport, single: true }); Ext.Viewport.setActiveItem(Ext.create('MyApp.view.NextView'));


Reply With Quote