makseo / ng2-sticky

Angular 2+ solution to make elements stick during scrolling.
https://domainlines.com
MIT License
92 stars 50 forks source link

Dynamic changing scrollFinish variable #13

Closed rashdeva closed 6 years ago

rashdeva commented 7 years ago

Hi!

If our page can adding elements which change height of window, scrollFinish still have first defined value.

For example. Body height is 1000px. Then we add new element with 1000px height and now body height is 2000px. But scrollFinish is 1000px anyway.

Maybe you will use getter, won't you?

private get scrollFinish():number {
        if (this.parentMode) {
            return this.containerStart - this.start - this.offsetBottom + (this.containerHeight - this.elemHeight);
        }

        return document.body.offsetHeight;
    }
arkhamvm commented 7 years ago

+1. Stack with same problem with infinity scrolling.

makseo commented 7 years ago

It's a nice idea to use "getter", but unfortunately this solution will not work, because "scrollFinish" requires another parameters to be properly recalculated.

Here should be used "defineDimensions".

I will think about how to detect if the DOM was changed and run "defineDimensions".