I am facing a challenge with an ion-content
scrollable item that contains anchors to jump to specific positions.
In addition to the ion-content
, there is also a button outside that allows users to jump to the next position.
Here's an example:
Jump to Position2
**Position1**
Text
Text
Text
Text
**Position2**
Text
Text
Text
A quick solution was to add a listener for on-scroll completion:
<ion-content delegate-handle="scroll1" on-scroll-complete="setTextForScroll()">
By setting the label depending on the scroll position in the controller.
var settingsScroller = $ionicScrollDelegate.$getByHandle('scroll1');
var posXScroll = settingsScroller.getScrollPosition().top;
if posXScroll === xy ...
However, this workaround may not be effective for different screen sizes or dynamically changing templates.
My idea now is to create an attribute directive that identifies marked elements and their positions in the scroll, then calculates the closest element to the current scroll position.
Despite my efforts, I am struggling to retrieve the DOM Element position in the controller and wonder if my approach is too complicated :/.
Any suggestions? Your assistance would be greatly appreciated! It seems like it should be simple... Scroll -> Label. Done :D
Cheers AucklandDB