In flex, how to get correct Y-axis when there is a vertical scroll?
-
29-09-2019 - |
Question
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.
Solution
You can factor in the scroll position of the parent container by adding the value of its verticalScrollPosition property to your y position.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow