Flex - changing the position of the scroll bar at the top of the HorizontalList component

By default, the horizontal ScrollBar of the HorizontalList component will be at the bottom. Is there any way to move it so that it is at the top?

Just for clarity, I do not mean moving the scroll position with scrollToIndex or horizontalScrollPosition, or a similar but actual physical position of the scroll bar component.

Any suggestions would be much appreciated!

+3
source share
2 answers

- . -, , , .

+3

. ( /), , :

package
{
    import flash.display.DisplayObject;

    import mx.controls.HorizontalList;
    import mx.core.EdgeMetrics;

    public class ReverseHList extends HorizontalList
    {
        override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void
        {
            super.updateDisplayList(unscaledWidth, unscaledHeight);

            var w:Number = unscaledWidth;
            var h:Number = unscaledHeight;
            var vm:EdgeMetrics = viewMetrics;
            if (horizontalScrollBar && horizontalScrollBar.visible)
            {
                horizontalScrollBar.setActualSize(w - vm.left - vm.right,
                                                  horizontalScrollBar.minHeight);
                horizontalScrollBar.move(vm.left, vm.top);

                horizontalScrollBar.enabled = enabled;
            }

            var mask:DisplayObject = maskShape;

            var wd:Number = w - vm.left - vm.right;
            var ht:Number = h - vm.top - vm.bottom;

            mask.width = wd < 0 ? 0 : wd;
            mask.height = ht < 0 ? 0 : ht;

            mask.x = vm.left;
            mask.y = vm.top + vm.bottom;
        }

        override protected function adjustListContent(unscaledWidth:Number = -1,
                                       unscaledHeight:Number = -1):void
        {
            super.adjustListContent(unscaledWidth, unscaledHeight);

            var lcx:Number = viewMetrics.left + listContent.leftOffset;
            var lcy:Number = (viewMetrics.top + listContent.topOffset) + viewMetrics.bottom;
            listContent.move(lcx, lcy);
        }

    }
}
+1

Source: https://habr.com/ru/post/1704277/


All Articles