Coder Social home page Coder Social logo

Comments (8)

lukasz-galka avatar lukasz-galka commented on June 3, 2024

Hi, please check version 0.8.1

from ngx-gallery.

moshecmc avatar moshecmc commented on June 3, 2024

HI, I checked version 0.8.1 and I am not sure what am I to do, I update galleryImages, but nothing happens.

from ngx-gallery.

lukasz-galka avatar lukasz-galka commented on June 3, 2024

I have added example "14. Change Images" on demo page https://lukasz-galka.github.io/ngx-gallery-demo/ and as you can see everything is working fine.

You can check code for demo page here https://github.com/lukasz-galka/ngx-gallery-demo and here is app component https://github.com/lukasz-galka/ngx-gallery-demo/blob/master/src/app/app.component.ts

Maybe try to uninstall and install plugin again?

npm uninstall ngx-gallery
npm cache clear
npm install --save ngx-gallery

Let me know if it helps.

from ngx-gallery.

moshecmc avatar moshecmc commented on June 3, 2024

I tried reinstalling the plug-in, I cleared my cache, I rebuilt the project. Gallery doesn't update.

I do this throughout my code:

this.galleryImages.push({
  'small': asset.url,
  'medium': asset.url,
  'big': asset.url,
  'description': asset.shotCode.description
});

and I run this:

this.gallery.smallImages = this.galleryImages.map(img => img.small);
this.gallery.mediumImages = this.galleryImages.map(img => img.medium);
this.gallery.bigImages = this.galleryImages.map(img => img.big);
this.gallery.descriptions = this.galleryImages.map(img => img.description);

immediately after, otherwise the gallery will not update.

Does your code account for the following cases:
-Append an array (push/unset) ?
-replace an element in Array (this.galleryImages[0] = newImage;)

from ngx-gallery.

lukasz-galka avatar lukasz-galka commented on June 3, 2024

Yes, you are right, it is not working for push/unset or replace. It is because of angular change detection:

"During change detection, when Angular checks components' input properties for change, it uses (essentially) === for dirty checking. For arrays, this means the array references (only) are dirty checked."

from http://stackoverflow.com/a/34799257/5946227

I will take a look on ngDoCheck https://angular.io/docs/ts/latest/guide/lifecycle-hooks.html#!#docheck and try implement custom login for change detection.

from ngx-gallery.

moshecmc avatar moshecmc commented on June 3, 2024

As you can see my use case does require checks to see if the array has been pushed/unset, or had elements replaced. Is there a temporary workaround for this issue?

Thanks

from ngx-gallery.

lukasz-galka avatar lukasz-galka commented on June 3, 2024

As described here http://stackoverflow.com/a/34799257/5946227

"Assign a new array to rawLapsData whenever you make any changes to the array contents. Then ngOnChanges() will be called because the array (reference) will appear as a change."

You have to create new array on every push/unset/update. For example:

This will not work:

this.galleryImages.push({
  'small': asset.url,
  'medium': asset.url,
  'big': asset.url,
  'description': asset.shotCode.description
});

but this should work:

let newImages = this.galleryImages.slice(0, this.galleryImages.length);
newImages.push({
  'small': asset.url,
  'medium': asset.url,
  'big': asset.url,
  'description': asset.shotCode.description
});
this.galleryImages = newImages;

from ngx-gallery.

moshecmc avatar moshecmc commented on June 3, 2024

Thank you so much for fixing this issue!

from ngx-gallery.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.