I am writing a custom component in HarmonyOS using Java SDK and it is a custom page slider indicator. To do that I have added a PageChangedListener
which provides three override methods.
public class CustomPageSliderIndicator extends Component implements PageSlider.PageChangedListener{
@Override
public void onPageSliding(int position, float positionOffset, int positionOffsetPixels) {}
@Override
public void onPageChosen(int i) {}
@Override
public void onPageSlideStateChanged(int i) { }
}
Whenever the user slides a page, onPageSliding
will be called, here I am facing the problem that the position
and positionOffset
are the same for sliding right and left.
So, how to know the direction of sliding?