MurhafSousli / ngx-gallery

Angular Gallery, Carousel and Lightbox
https://ngx-gallery.netlify.app/
MIT License
610 stars 129 forks source link

indexChange does not get called in lightbox mode #624

Closed TupiC closed 9 hours ago

TupiC commented 10 hours ago

What is the expected behavior?

indexChanged should be called in lightbox mode

What is the current behavior?

indexChanged does not get called in lightbox mode

What are the steps to reproduce?

open https://stackblitz.com/edit/ng-gallery-index-change?file=src%2Fmain.ts indexChanged gets logged in "normal mode" but not in lightbox mode

What is the use-case or motivation for changing an existing behavior?

want to handle several things no matter the mode

Which versions are you using for the following packages?

Angular: 18.2.13 Angular CDK: 18.2.13 Angular CLI: 18.2.13 Typescript: 5.5.4 Gallery: 12.0.0

Is there anything else we should know?

-

MurhafSousli commented 9 hours ago

Because the lightbox has its own gallery instance. here is how you get the indexChanged for the lightbox

@Component({ ... })
export class App {

  constructor(public gallery: Gallery) {
  }

  ngOnInit() {
    this.gallery.ref('lightbox').indexChanged.subscribe(x => {
      console.log('lightbox index changed', x);
    })
  }
}

See fixed stackblitz