在flex中,当存在垂直滚动时如何获得正确的Y轴?

发布于 2024-09-14 21:45:29 字数 303 浏览 0 评论 0原文

在flex中,我通过以下方式获取y坐标:

nextHBox = HBox(ingBox.getChildByName("ing" + nextId));

nextYAxis = ingBox.localToGlobal(new Point(nextHBox.x,nextHBox.y)).y;

newCanvas.x = nextYAxis;

nextYAxis 为我提供 y 轴,我用它来定位新组件。它工作得非常好。但是,当存在垂直滚动时,我滚动它一点,然后上面提到的代码将组件放置在错误的位置。我相信,这与卷轴有关。

In flex, I am getting the y-coordinate in the following way:

nextHBox = HBox(ingBox.getChildByName("ing" + nextId));

nextYAxis = ingBox.localToGlobal(new Point(nextHBox.x,nextHBox.y)).y;

newCanvas.x = nextYAxis;

nextYAxis gives me the y-axis and I use it to position new component. It works absolutely fine. But, when there is vertical scroll, and I scroll it a little bit, and then the above mentioned code places the component at wrong place. I believe, it has something to do with the scroll.

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

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

发布评论

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

评论(1

鲜肉鲜肉永远不皱 2024-09-21 21:45:29

您可以通过将其 VerticalScrollPosition 属性的值添加到 y 位置来考虑父容器的滚动位置。

You can factor in the scroll position of the parent container by adding the value of its verticalScrollPosition property to your y position.

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