Flex - 将滚动条的位置更改为 Horizo​​ntalList 组件的顶部

发布于 2024-07-14 12:10:46 字数 178 浏览 8 评论 0原文

默认情况下,Horizo​​ntalList 组件的水平滚动条位于底部。 有没有办法重新定位它,使其位于顶部?

为了清楚起见,我并不是指使用scrollToIndex或horizo​​ntalScrollPosition或类似的方法移动滚动位置,而是滚动条组件的实际物理位置。

任何建议将不胜感激!

By default, the Horizontal ScrollBar of a HorizontalList component will be at the bottom. Is there a way to reposition it so it is at the top?

Just for clarity, I do not mean moving the scroll position using either scrollToIndex or horizontalScrollPosition or similar, but the actual physical position of the scrollbar component.

Any suggestions would be very appreciated!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

紙鸢 2024-07-21 12:10:46

我不久前也在寻找类似的东西,发现这个发布。 我最终以另一种方式解决了我的问题,所以没有使用该解决方案,但它可能适合你想要的。

I was looking for something similar myself a while ago and found this post. I eventually ended up solving my problem in another way, so didn't use that solution, however it might work for what you want.

伤痕我心 2024-07-21 12:10:46

我以前也必须做同样的事情。 我必须深入研究基类(以处理一些掩蔽/定位问题),这就是我想到的:

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);
        }

    }
}

I've had to do the same thing previously. I had to dig around in the base classes (to handle some masking/positioning issues) and this is what I came up with:

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);
        }

    }
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文