Closed rdkmaster closed 7 years ago
Hi @rdkmaster,
Thanks for pointing it out, following your steps I've been able to improve the performance.
Please update to v1.2.1 and give me some feedback.
I've look into the source code of malihu scrollbar, I found that the scrollbar's implementation is using setTimeout
to perform a loop check and thus to perform scrolling, it update in 50ms in default. That is to say, the implementation will invoke setTimeout
time and time again as soon as it initialized.
As we have already known, everytime after setTimeout
, zone of Angular will run the change detection, and the DoCheck
life cycle will be invoked, and this is the reason that causes this issue. I check latest commit of malihu scrollbar, it is more that one year ago, and I think the author is not likely to fix this issue, I also sadly think this issue is NOT fixable, because it is the base of the implementation.
I've decided to give up this scrollbar implementation.
Btw, you can take a look at my repo, we've made 30 components based on Angular including a scrollbar directive, and the number is increasing, you can find it here https://github.com/rdkmaster/jigsaw, join us if you like it.
@jfcere you need to leave at least one scrollbar in the view, this is the key to this issue, remove
all scrollbars in the view and angular will not initialize malihu-scrollbar anymore, and the setTimeout
will not be invoked.
I did pretty much the best I could do on my side by improving the change detection for this Angular wrap but of course it won't fix the existing behavior or the original Malihu Scrollbar plugin.
reproduce this issue
follow this to reproduce this issue, all code is based on the repo:
malihu-scrollbar-demo.component.html
MalihuScrollbarDemoComponent
defined inmalihu-scrollbar-demo.component.ts
this is a series performance problem
as we known, the
ngFor
implements theDoCheck
life cicle hook, which makes thengFor
very sensitive to any change, because that after any event, the ngDoCheck ofngFor
will be invoked. It seems that malihu keep firing event and make angular executes thengDoCheck
hook time and time again.How to fix this?