Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reinitialize scrollbar on dynamically delete content #77

Open
abdelrhman92 opened this issue Dec 4, 2017 · 8 comments
Open

Reinitialize scrollbar on dynamically delete content #77

abdelrhman92 opened this issue Dec 4, 2017 · 8 comments

Comments

@abdelrhman92
Copy link

the slim scroll working fine when I am dynamically adding content. I mean the scrollbar keep getting smaller giving me the space for more scrolling to reveal more content. But It doesn't adjust when I remove content. Till it reach the minimum height then disappear. if is there any event should I emit when content change ??

@jkuri
Copy link
Owner

jkuri commented Dec 4, 2017

hi @abdelrhman92. I see event is missing in the readme. you should send recalculate event, something like:

const ev = new SlimScrollEvent({ type: 'recalculate' });

please let me know if it works.

@abdelrhman92
Copy link
Author

Nah, It's not working

@mirzinho
Copy link

@jkuri

public scrollEvents: EventEmitter<SlimScrollEvent>;

  ngOnInit() {
    this.scrollEvents = new EventEmitter<SlimScrollEvent>();
  }
 const ev = new SlimScrollEvent({ type: 'recalculate' });

    this.scrollEvents.emit(ev);

Please confirm this is the correct way to recalculate the scrollbar, because its not working, but strangely enough if i resize the window the scrollbar is recalculated. Could you look into it pelase.

Thank you

@jkuri
Copy link
Owner

jkuri commented Jun 25, 2021

try wrapping into setTimeout or run change detection manually,

const ev = new SlimScrollEvent({ type: 'recalculate' });
setTimeout(() => this.scrollEvents.emit(ev));

@mirzinho
Copy link

@jkuri unfortunately its not working... not matter what the time out is none, 0 or 10sec..

i see that event is created but looks like the emitted event does nothing

@jkuri
Copy link
Owner

jkuri commented Jun 25, 2021

did you bind scrollEvents in your template?

<div slimScroll [scrollEvents]="scrollEvents"></div>

@mirzinho
Copy link

@jkuri

now i have and got another error but that is easly fixed,

public scrollEvents: EventEmitter<ISlimScrollEvent>;

this.scrollEvents = new EventEmitter<ISlimScrollEvent>();

should be this insted of EventEmitter<SlimScrollEvent> ,

otherwise you get this error

error TS2322: Type 'EventEmitter<SlimScrollEvent>' is not assignable to type 'EventEmitter<ISlimScrollEvent>'. Types of property 'observers' are incompatible. Type 'Observer<SlimScrollEvent>[]' is not assignable to type 'Observer<ISlimScrollEvent>[]'. Type 'Observer<SlimScrollEvent>' is not assignable to type 'Observer<ISlimScrollEvent>'. Type 'ISlimScrollEvent' is not assignable to type 'SlimScrollEvent'.

i can confirm now that the recalculate event is working properly, thx for the help

@jkuri
Copy link
Owner

jkuri commented Jun 25, 2021

no problem, glad you got it working.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants