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

Request hit only two image rest it only shows loading icon #256

Closed
anup5708 opened this issue Dec 31, 2017 · 4 comments
Closed

Request hit only two image rest it only shows loading icon #256

anup5708 opened this issue Dec 31, 2017 · 4 comments
Labels

Comments

@anup5708
Copy link

anup5708 commented Dec 31, 2017

Hi,

I am creating an app in Ionic 2 + angularfire2@4.0.0-rc.0 and integrate this lazy load plugins to show loading icon.

Below are my Code

 <ion-list no-padding>
    <ion-item>
      <ion-slides pager>
        <ion-slide *ngFor="let image of topNewsArray">
          <ion-card>
            <img [defaultImage]="global.loading" [lazyLoad]="image.url" [offset]="offset" />
          </ion-card>
        </ion-slide>
      </ion-slides>
    </ion-item>
  </ion-list>

I found that when my image request is two it show me loading icon as it receive response it display me two images correctly.

But when I have more than two images, it display me two image and the rest still shows me loading icon.

@tjoskar
Copy link
Owner

tjoskar commented Dec 31, 2017

@anup5708, are the other images (all images below the first two) outside the viewport?

I guess you are using this slider (I have not been working with Ionic): https://ionicframework.com/docs/api/components/slides/Slides/?
ng-lazyload-image will only listens for scroll events ion-slides will however not emit any scroll events so you have to tell ng-lazyload-image when the world has changed.

Can you try something like this:

// Your controller
imageChange$ = new Subject();

slideChanged() {
  this.imageChange$.next();
}
<ion-list no-padding>
    <ion-item>
      <ion-slides pager (ionSlideDidChange)="slideChanged()">
        <ion-slide *ngFor="let image of topNewsArray">
          <ion-card>
            <img [defaultImage]="global.loading" [lazyLoad]="image.url" [offset]="offset" [scrollObservable]="imageChange$" />
          </ion-card>
        </ion-slide>
      </ion-slides>
    </ion-item>
</ion-list>

@anup5708
Copy link
Author

anup5708 commented Jan 1, 2018

I follow the steps mentioned above now it's working fine as expected, Thanks @tjoskar

@anup5708 anup5708 closed this as completed Jan 1, 2018
@myrsk
Copy link

myrsk commented Jan 3, 2018

Have a similar issue. However, when i tried to use the same fix. I am getting a runtime error.

_co.slideChanged is not a function

ionic 3.

page.ts - here im getting a debug notice on Subject not found. TS.


imageChange$ = new Subject();

  slideChanged() {
    this.imageChange$.next();
  }

page.html

      <ion-slides *ngIf="(item | async).image1" class="image-slider" loop="true" slidesPerView="2" (ionSlideDidChange)="slideChanged()">
        <ion-slide *ngIf="(item | async).image1">
          <img [defaultImage]="'https://www.placecage.com/1000/1000'" [lazyLoad]="(item | async).image1" class="thumb-img" imageViewer [scrollObservable]="imageChange$" [offset]="'100'">
        </ion-slide>
        <ion-slide *ngIf="(item | async).image2">
            <img [defaultImage]="'https://www.placecage.com/1000/1000'" [lazyLoad]="(item | async).image2" class="thumb-img" imageViewer [scrollObservable]="imageChange$" [offset]="'100'">
          </ion-slide>
          <ion-slide *ngIf="(item | async).image3">
              <img [defaultImage]="'https://www.placecage.com/1000/1000'" [lazyLoad]="(item | async).image3" class="thumb-img" imageViewer [scrollObservable]="imageChange$" [offset]="'100'">
            </ion-slide>
            <ion-slide *ngIf="(item | async).image4">
                <img [defaultImage]="'https://www.placecage.com/1000/1000'" [lazyLoad]="(item | async).image4" class="thumb-img" imageViewer [scrollObservable]="imageChange$" [offset]="'100'">
              </ion-slide>
              <ion-slide *ngIf="(item | async).image5">
                  <img [defaultImage]="'https://www.placecage.com/1000/1000'" [lazyLoad]="(item | async).image5" class="thumb-img" imageViewer [scrollObservable]="imageChange$" [offset]="'100'">
                </ion-slide>
                <ion-slide *ngIf="(item | async).image6">
                    <img [defaultImage]="'https://www.placecage.com/1000/1000'" [lazyLoad]="(item | async).image6" class="thumb-img" imageViewer [scrollObservable]="imageChange$" [offset]="'100'">
                  </ion-slide>
      </ion-slides>
    </ion-card>```

@myrsk
Copy link

myrsk commented Jan 3, 2018

Additional: Uncaught (in promise): ReferenceError: Subject is not defined ReferenceError: Subject is not defined

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