Success! Looks like we've fixed this one. According to our records the fix was applied for TOUCH-948 in a recent build.
  1. #1
    Sencha User SunboX's Avatar
    Join Date
    Mar 2010
    Posts
    238
    Vote Rating
    28
    SunboX has a spectacular aura about SunboX has a spectacular aura about

      0  

    Exclamation [PR1] Ext.Carousel.getActiveIndex() returns wrong indexes

    [PR1] Ext.Carousel.getActiveIndex() returns wrong indexes


    Ext version tested:
    • Sencha Touch 2.0PR1
    Browser versions tested against:
    • Safari 5.1 (7534.50) on Windows
    Description:

    I have an Ext.Carousel instance with dynamically added cards. I added 4 different(!) cards. If i listen to the "activeitemchange" event and console.log() the Ext.Carousel.getActiveIndex() value, I get this:

    Code:
    1
    0
    1
    2
    That´s wrong! This is what I expected:

    Code:
    0
    1
    2
    3

    Test Case:
    Code:
    Ext.setup({
        onReady: function() {
            
            var self = this;
    
            var carousel = Ext.create('Ext.Carousel', {
                fullscreen: true,
            
                defaults: {
                    styleHtmlContent: true
                },
            
                items: [
                    {
                        html : 'Item 1',
                        style: 'background-color: #5E99CC'
                    },
                    {
                        html : 'Item 2',
                        style: 'background-color: #759E60'
                    },
                    {
                        html : 'Item 3'
                    },
                    {
                        html : 'Item 4',
                        style: 'background-color: #759E60'
                    },
                ]
            });
            
            carousel.on({
                activeitemchange: function(carousel){
                    var activeIndex = carousel.getActiveIndex();
                        
                    console.log(activeIndex);    
                }
            });
             
            var first = carousel.getInnerItems()[0];
            if(first)
                carousel.setActiveItem(first);
        }
    });
    HELPFUL INFORMATION

    See this URL for live test case:
    http://jsfiddle.net/QYJpc/16/ (open with Safari!)

    greetings Sunny
    Last edited by SunboX; 28 Oct 2011 at 7:15 AM. Reason: bug tracker formating

  2. #2
    Sencha User SunboX's Avatar
    Join Date
    Mar 2010
    Posts
    238
    Vote Rating
    28
    SunboX has a spectacular aura about SunboX has a spectacular aura about

      0  

    Default


    One more, if I slide back and foreward, same cards return different indexes every time.

  3. #3
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    36,824
    Vote Rating
    836
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    Can you edit your first post so that our bug tracker can correctly parse the thread?

    http://www.sencha.com/forum/showthre...o-report-a-bug
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    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. #4
    Sencha User SunboX's Avatar
    Join Date
    Mar 2010
    Posts
    238
    Vote Rating
    28
    SunboX has a spectacular aura about SunboX has a spectacular aura about

      0  

    Default


    Thx, done!

    greetings Sunny

  5. #5
    Sencha User
    Join Date
    Nov 2011
    Posts
    3
    Vote Rating
    0
    tfjjones is on a distinguished road

      0  

    Lightbulb Is this a bug?

    Is this a bug?


    I have just run into this situation but I do not believe it is a bug, more a missing feature.

    The documentation for the activeitemchange specifically says

    "Note that this event is fired before the value of activeItem has been updated, and that you can return false from any listener to the activeitemchange event to cancel the change."

    (Important bit: BEFORE the value is updated)

    Therefore it is reasonable to assume that the active index has not yet been updated either since it can be cancelled by this event.

    So by calling getActiveItem from within the listener you are always getting the previous item's index, not the new one.

    Having said that there is currently no way that I can see to get the index of the new activeItem from inside the listener; this is something that should be added I think.

  6. #6
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    36,824
    Vote Rating
    836
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    We don't have a 'Missing Feature' forum... A missing feature is a subset of a bug
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    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.

  7. #7
    Sencha User Jacky Nguyen's Avatar
    Join Date
    Jul 2009
    Location
    Palo Alto, California
    Posts
    469
    Vote Rating
    14
    Jacky Nguyen has a spectacular aura about Jacky Nguyen has a spectacular aura about

      0  

    Default


    This has been fixed for the next release.

    The default order of event listeners is now 'after' instead of 'before', which means all listener callbacks by default will now be invoked after the actions have been taken. Therefore, in the case of 'activeitemchange' event, the listeners will now be called at the end of animation.
    Sencha Touch Lead Architect