You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@royale.apache.org by ca...@apache.org on 2020/04/16 23:34:31 UTC

[royale-asjs] branch develop updated: jewel-scrollToIndex: improve function for better positioning of the scrollarea and avoid unneeded loop iterations

This is an automated email from the ASF dual-hosted git repository.

carlosrovira pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/royale-asjs.git


The following commit(s) were added to refs/heads/develop by this push:
     new b4796ff  jewel-scrollToIndex: improve function for better positioning of the scrollarea and avoid unneeded loop iterations
b4796ff is described below

commit b4796ff25f248d9861dfc8cfe842e06b857a06e7
Author: Carlos Rovira <ca...@apache.org>
AuthorDate: Fri Apr 17 01:34:25 2020 +0200

    jewel-scrollToIndex: improve function for better positioning of the scrollarea and avoid unneeded loop iterations
---
 .../org/apache/royale/jewel/beads/controls/list/scrollToIndex.as    | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/controls/list/scrollToIndex.as b/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/controls/list/scrollToIndex.as
index 52db14e..3440b53 100644
--- a/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/controls/list/scrollToIndex.as
+++ b/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/controls/list/scrollToIndex.as
@@ -69,14 +69,14 @@ package org.apache.royale.jewel.beads.controls.list
             //each item render can have its own height
             var n:int = list.dataProvider.length;
             var irHeights:Array = [];
-            for (var i:int = 0; i < n; i++)
+            for (var i:int = 0; i <= index; i++)
             {
                 var ir:IItemRenderer = dataGroup.getItemRendererForIndex(i) as IItemRenderer;
-                irHeights.push(totalHeight + ir.element.clientHeight);
                 totalHeight += ir.element.clientHeight;
+                irHeights.push(totalHeight + ir.element.clientHeight - scrollArea.clientHeight);
             }
 
-            scrollArea.scrollTop = irHeights[index-1];
+            scrollArea.scrollTop = Math.min(irHeights[index], totalHeight);
 
         } else 
         {