[ 
https://issues.apache.org/jira/browse/FLEX-33660?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Alexander Farber updated FLEX-33660:
------------------------------------

    Attachment: ScrollToBottom.mxml

The very simple test case, which demonstrates the failure in Flex 4.10.0
                
> ensureIndexIsVisible() does not work for spark.components.List
> --------------------------------------------------------------
>
>                 Key: FLEX-33660
>                 URL: https://issues.apache.org/jira/browse/FLEX-33660
>             Project: Apache Flex
>          Issue Type: Bug
>          Components: Spark: List
>    Affects Versions: Apache Flex 4.10.0
>         Environment: Flex 4.10.0 and Flash Builder 4.7 on Windows 7
>            Reporter: Alexander Farber
>         Attachments: ScrollToBottom.mxml
>
>
> The method ensureIndexIsVisible() does not really work when an item has been 
> added to a List and you have to use wrokarounds like the one described at the 
> http://flexponential.com/2011/02/13/scrolling-to-the-bottom-of-a-spark-list/
> I am attaching a very simple test case which demonstrates the failure (and 
> the workaround) for Flex 4.10.0:
> <?xml version="1.0" encoding="utf-8"?>
> <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"; 
>                          xmlns:s="library://ns.adobe.com/flex/spark" 
>                          xmlns:mx="library://ns.adobe.com/flex/mx">
>       
>       <fx:Script>
>               <![CDATA[
>                       import spark.core.NavigationUnit;
>                       
>                       private function addMessage():void {
>                               // add the message
>                               
> chatList.dataProvider.addItem({label:message.text});
>                               
>                               // clear the text input
>                               message.text = "";
>                               
>                               // scroll to the bottom of the List to show 
> this item
>                               scrollToBottomBuggy();
>                       }
>                       
>                       private function scrollToBottomBuggy():void {
>                               
> chatList.ensureIndexIsVisible(chatList.dataProvider.length - 1);
>                       }
>                       
>                       private function scrollToBottomWorkaround():void {
>                               // update the verticalScrollPosition to the end 
> of the List
>                               // virtual layout may require us to validate a 
> few times
>                               var delta:Number = 0;
>                               var count:int = 0;
>                               while (count++ < 10){
>                                       chatList.validateNow();
>                                       delta = 
> chatList.layout.getVerticalScrollPositionDelta(NavigationUnit.END);
>                                       chatList.layout.verticalScrollPosition 
> += delta;
>                                       
>                                       if (delta == 0)
>                                               break;
>                               }
>                       }
>               ]]>
>       </fx:Script>
>       
>       <s:Panel title="Chat" defaultButton="{btn}" horizontalCenter="0" 
> verticalCenter="0" width="300">
>               <s:List id="chatList" alternatingItemColors="[#EEEEEE,#DDDDDD]" 
> height="120" width="100%">
>                       <s:layout>
>                               <s:VerticalLayout horizontalAlign="justify" 
> gap="0" />
>                       </s:layout>
>                       <s:dataProvider>
>                               <s:ArrayCollection id="dp" />
>                       </s:dataProvider>
>               </s:List>
>               
>               <s:controlBarContent>
>                       <s:TextInput id="message" width="100%" />
>                       <s:Button id="btn" label="Send" click="addMessage()" />
>               </s:controlBarContent>
>       </s:Panel>
> </s:Application>

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Reply via email to