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

fix: galleryItemDef directive should override gallery-item content #579

Closed

Conversation

cybercyst
Copy link

@cybercyst cybercyst commented Sep 1, 2023

After many frustrating attempts to try and follow the example code for *galleryItemDef I noticed that the boolean logic seemed to not work as the demo code indicated it would.

With the logic laid out this way, *galleryItemDef will override whatever the gallery-item's default template would do.

@MurhafSousli
Copy link
Owner

Can you explain the issue! what were you trying to do and what did not work as expected?

@cybercyst
Copy link
Author

Of course!

I was following the tutorial code here https://ngx-gallery.netlify.app/#/custom-templates for GalleryItemDef and it didn't do anything.

I was trying to replace the entire template for a given item in the gallery, which is what that demo code indicates that the *galleryItemDef directive is for.

Looking at the code, it would never replace the content of the item template when it is part of the ngSwitch and would always use the gallery item's default templates, and only if the gallery item's type was not known would it use the *galleryItemDef you've defined. (which is not easy to do due to the typing which states that the GalleryItem's type will be one of 4 well-known types)

I hope that helps!

Basically, I wanted to replace the template used with my custom defined template.

@MurhafSousli
Copy link
Owner

MurhafSousli commented Sep 3, 2023

@cybercyst Whoops! I didn't pay attention to the docs, actually you can override the whole item template, you just need to add the items using different function or interface where you can set the type name.

galleryRef.add({
  type: 'my-custom-item',
  data: {
    src: 'IMAGE_SRC_URL',
    thumb: 'IMAGE_THUMBNAIL_URL'
    alt: 'Test'
  }
})
  
// or using items array
const items: GalleryItem[] = [
  {
     type: 'custom-item'
     data: {
       src: 'IMAGE_SRC_URL',
       thumb: 'IMAGE_THUMBNAIL_URL'
     }
  }
  // more items
];

I either have to fix the docs, or apply this fix... give me some time to revise the usage, meanwhile you can use this as a workaround

@MurhafSousli
Copy link
Owner

MurhafSousli commented Sep 3, 2023

The idea was, give the ability for users to have their own custom template, along with the other available types, for example a user wants to use his own video item template but keeps using the original image template for images.

@cybercyst
Copy link
Author

Ahhh I understand now, I thought it was there to give you a way to override the whole template for a gallery item!

@cybercyst
Copy link
Author

@MurhafSousli thanks for your time and attention! Would you like me to close this PR then?

@MurhafSousli
Copy link
Owner

@cybercyst Yes, thanks for the attempt to contribute!

@cybercyst cybercyst deleted the floomis/fix/gallery-item-def branch October 9, 2023 00:05
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

Successfully merging this pull request may close these issues.

None yet

2 participants