Results 1 to 7 of 7

Thread: Painted event in Navigation View

  1. #1
    Sencha User
    Join Date
    Jul 2011
    Posts
    31
    Answers
    1
    Vote Rating
    0
      0  

    Default 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

    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
            }
    });
    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.

    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.

  2. 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'));

  3. #2
    Sencha - Sr Software Engineer mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    39,326
    Answers
    3884
    Vote Rating
    1297
      0  

    Default

    Instead of painted, have you tried activated?
    Mitchell Simoens @LikelyMitch
    Sencha Inc, Senior Software Engineer
    ________________
    Learn BBCode and use it!

    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 in print!

    When posting code, please use BBCode's CODE tags.

  4. #3
    Sencha User
    Join Date
    Jul 2011
    Posts
    31
    Answers
    1
    Vote Rating
    0
      0  

    Default

    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.

  5. #4
    Sencha - Sr Software Engineer mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    39,326
    Answers
    3884
    Vote Rating
    1297
      0  

    Default

    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 @LikelyMitch
    Sencha Inc, Senior Software Engineer
    ________________
    Learn BBCode and use it!

    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 in print!

    When posting code, please use BBCode's CODE tags.

  6. #5
    Sencha User
    Join Date
    Jul 2011
    Posts
    31
    Answers
    1
    Vote Rating
    0
      0  

    Default

    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,

  7. #6
    Sencha User
    Join Date
    Jul 2011
    Posts
    31
    Answers
    1
    Vote Rating
    0
      0  

    Default

    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

  8. #7
    Sencha User
    Join Date
    Jul 2011
    Posts
    31
    Answers
    1
    Vote Rating
    0
      0  

    Default

    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'));

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •