Closed lzm420241 closed 7 years ago
There might be a bug in it. if you click s5, it should scroll 550px, but only scrolls 540px, it result in showing s4 on a box. That's why it shows s4.
I will try to find a reason and solution later.
Thanks for reporting this.
Meanwhile, any help or PR would be appreciated.
@allenhwkim
let step = horizontal ?
Math.ceil((targetOffsetLeft - currentScrollLeft) / 10) :
Math.ceil((targetOffsetTop - currentScrollTop) / 10);
through the code , for step counting value, we left Math.ceil((targetOffsetTop - currentScrollTop) % 10)
that we did not count in step. i think that's why the scroll bar scrolls 540px when you click s5! (the fact that i think scroll value is more than 540px, but less than 550px)
and i couldn't find anywhere to set the element's offsetTop or elements's offsetLeft for srcoll event, that can't synchronize with the distance's value in scrollTo method.
It turns out the example have distance offset specified as 10px. Changed it to 0, and it seems working fine now.
Released as 0.7.1, please verify the change
so, it leads the distance become constant, and others can't change distance. maybe someone need to set distance.
and i set distance value = 0 ,but it still work not well
@lzm420241 , if you create a plunker example, I will take a look at it. You can start build plunker example from https://plnkr.co/edit/wLVudY?p=preview&open=app.component.ts by forking it.
The given plunker example uses scrollTo
from ng2-utils
, which is basically the same one.
i set id from s1 to s7, when i click s5, the active id is s4,and the window show the part of s4 and the part of s5, but s4 is the top of s5. So i think the page run Ng2ScrollableDirective.scrollTo() function , then run scroll event ,so the last value of id is s4, right? but i click s5 ,then s5 should be active , then i want to active s5 ,how to solve the problem?