flex-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Alexander Konovalov (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (FLEX-27217) Mouse wheel scrolling does not work with Spark Scroller
Date Wed, 19 Nov 2014 16:53:33 GMT

    [ https://issues.apache.org/jira/browse/FLEX-27217?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14218126#comment-14218126

Alexander Konovalov commented on FLEX-27217:

Hello. I've encountered with the same bug. What I've found looking deeper.
Problem is caused by includeInLayout="false" elements in the group.
More details:
scrollPositionChanged() method calculate _firstIndexInView and _lastIndexInView variables.
First of all it makes some default checks (1. no controls at all, 2. no scrollRect, 3. scrollRect.bottom
is less/higher then scrollRect.top, 4. no LinearLayoutVestor llv for virtualLayout) and finally
it calls private static method findIndexAt, that makes binary search for visible index.
And here is the bug. It makes binary search, and does not check includeInLayout="false" elements.

I'll explain on my example: I have 41 element in the group and scrollRect bounds (0,0, 602,435).
index     Y-position   includeInLayout
0              0                       true
1              22                     true
19            602                  false
20            635                  false
21            345                  true
40            605                  true
Method findIndexAt tries to find element index for _lastIndexInView with Y 435 (scrollRect's
On first iteration findIndexAt goes into recursion with index 20 (Y=635) and makes binary
search in the first 20 elements, instead of second part. So it doesn't find any control and
return -1.
Returning back to scrollPositionChanged() method we go into  if (i1 == -1) clause that return
n-1 element, that is also beyond scrollRect's bounds and finally we have -1 in _lastIndexInView.
Scrolling with mouseWheel after that leads to unpredictable results (scroll will freeze on
one place or always return to 0 position - in my cases)

The problem:
As you can see for includeInLayout="false" Y coordinate is not recalculated, so binary search
in unacceptable here (elements list is not sorted at all).

So I see two solutions here:
1. Reimplement findIndexAt method with direct "for"/"while" loop adding includeInLayout check.
My fix code:
    private static function findIndexAt(y:Number, gap:int, g:GroupBase, i0:int, i1:int):int
        //FIX. Direct search instead of binary
        for (var index: int = i0; index < i1; index++)
            var element:ILayoutElement = g.getElementAt(index);
            if (!element || !element.includeInLayout)
            var elementY:Number = element.getLayoutBoundsY();
            var elementHeight:Number = element.getLayoutBoundsHeight();
            // TBD: deal with null element, includeInLayout false.
            if ((y >= elementY) && (y < elementY + elementHeight + gap))
                return index;
        return -1;
2. Recalculate and update Y coordinate for elements with includeInLayout="false" with Y =
previous control's Y+height+gap. In other words all neighbour elements with includeInLayout="false"
will have same Y position and it will be equals to Y position of next element with includeInLayout="true".
In that case ALL elements will be sorted by Y coordinate and binary search can be applied
(don't forget to add includeInLayout check there).
Fix in method updateDisplayListReal (line 1981 Flex 4.6, line 1990 Flex 4.12.1, seems it will
be the same for 4.13), clause
            if (!layoutElement || !layoutElement.includeInLayout)
should be changed to 
            if (!layoutElement || !layoutElement.includeInLayout)
                layoutElement.setLayoutBoundsPosition(layoutElement.getLayoutBoundsX(), y);
or something like that.

> Mouse wheel scrolling does not work with Spark Scroller
> -------------------------------------------------------
>                 Key: FLEX-27217
>                 URL: https://issues.apache.org/jira/browse/FLEX-27217
>             Project: Apache Flex
>          Issue Type: Bug
>          Components: Spark: Scroller
>    Affects Versions: Adobe Flex SDK 4.1 (Release)
>         Environment: Affected OS(s): Windows
> Affected OS(s): Windows 7
> Language Found: English
>            Reporter: Adobe JIRA
> Steps to reproduce:
> 1. open & run the attached scrollProblem.mxml (scrollProblemV2.mxml refers to another
problem in bug FP-5145)
> 2. toggle some sections
> 2. try scrolling up & down via the mouse wheel
>  Actual Results:
> at some points vertical scrolling stucks and the scroller does not move up/down. Scrolling
works ok using the scrollbar.
>  Expected Results:
> vertical scroll position should be updated

This message was sent by Atlassian JIRA

View raw message