sachinchoolur / lightGallery

A customizable, modular, responsive, lightbox gallery plugin.
https://www.lightgalleryjs.com/
Other
6.55k stars 1.29k forks source link

Can't add videos through refresh or dynamicEl in Angular due to interface declaration #1518

Closed jlaguio closed 1 year ago

jlaguio commented 1 year ago

Description

I'm having issue trying to add videos in dynamic mode for angular. This is due to the interface / data type of the GalleryItem requiring HTML elements. Could this be a mistake?

Steps to reproduce

For example in this code, typescript would throw an error. I tried the following the codepen made by @sachinchoolur here . I got the sample from #567

import type { LightGallerySettings } from 'lightgallery/lg-settings';

const settings: LightGallerySettings = {
  licenseKey: this.config.licenseKey,
  dynamic: true,
  dynamicEl: [
    {
      video: {
        source: [
          {
            src: 'https://www.lightgalleryjs.com//videos/video1.mp4',
            type: 'video/mp4',
          },
        ],
        attributes: { preload: false, controls: true },
      },
      thumb:
        'https://www.lightgalleryjs.com//images/demo/html5-video-poster.jpg',
      subHtml: `<div class="lightGallery-captions">
                  <h4>Photo by <a href="https://unsplash.com/@brookecagle">Brooke Cagle</a></h4>
                  <p>Description of the slide 2</p>
              </div>`,
    },
  ],
};

image

Context

Currently this is the interface for the GalleryItem

export interface GalleryItem {
     // .... Omitted some stuff not related to video
    /**
     * Video source
     * @data-attr data-video
     */
    video?: VideoSource;
    /**
     * Poster url
     * @data-attr data-poster
     */
    poster?: string;
    // .... Omitted some stuff not related to video
    [key: string]: any;
}

The video attribute has the VideoSource interface, tracing further...

export interface VideoSource {
    source: {
        src: string;
        type: string;
    }[];
    tracks: HTMLTrackElement[];
    attributes: HTMLVideoElement;
}

Which doesn't match the documentations nor the example codepen

Environment

stale[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.