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

Scroll doesn't work with ngFor #9

Open
doidd opened this issue May 29, 2017 · 3 comments
Open

Scroll doesn't work with ngFor #9

doidd opened this issue May 29, 2017 · 3 comments
Labels

Comments

@doidd
Copy link

doidd commented May 29, 2017

I following demo and simple edit code like this
<ul>
<li *ngFor="let num of [1,2,3,4,5,6,7,8,9,10]" [class.current]="id == 's'+ num " (click)="scrollTo('#s'+num, '#v-scrollable')">{{num}}
</ul>

scrolled to: {{id}}
<div id="v-scrollable" class="scrollable section" ng2-scrollable (elementVisible)="id = $event.id">
<div *ngFor="let num of [1,2,3,4,5,6,7,8,9,10]" [id]="'s'+ num ">
Section {{num}} (scroll to here)
</div>
</div>
but demo don't work. How can i fix that?

@allenhwkim
Copy link
Contributor

@Christophe-re
Copy link

Christophe-re commented Aug 22, 2017

It works because you don't use a ngfor.. :

app.tpl.html

<legend>Scroll Within Window</legend>
<div class="scrollable" 
  (elementVisible)="wid = $event.id"
  (elementHidden)="whid = $event.id"
  ng2-scrollable>
  **<div id="w1">One</div>
  <div id="w2">Two</div>
  <div id="w3">Three</div>
  <div id="w4">Four</div>
  <div id="w5">Five</div>
  <div id="w6">Six</div>
  <div id="w7">Seven</div>
  <div id="w8">Eight</div>
  <div id="w9">Nine</div>**
</div>
<div style="height: 1600px"> Spacing </div>

@allenhwkim allenhwkim added the bug label Aug 22, 2017
@allenhwkim
Copy link
Contributor

I am not sure people really do repeat *ngFor for sections. We may need setTimeout() to solve this within ngAfterViewInit https://github.com/ng2-ui/scrollable/blob/master/src/scrollable.directive.ts#L40

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

No branches or pull requests

3 participants