ganlanyuan / tiny-slider

Vanilla javascript slider for all purposes.
MIT License
5.24k stars 786 forks source link

Please provide method to refresh edgePadding and gutter or allow clamp values #831

Open nlighteneddesign opened 1 year ago

nlighteneddesign commented 1 year ago

Issue description: There is no way to refresh gutter and edgepadding after build.

We have a complex calculation for edge and gutter in order to line up with content above that uses clamp settings. We've attempted the refresh method, but that does not recalculate the spacing.

This could be resolved if we could put clamp as the values instead of an integer as well.

NB in the demo below the positionInfo does calculate the correct value on refresh, but it does not translate to the gutter.

Demo link/slider setting:

this.carousel = tns({
      autoHeight: false,
      autoplay: false,
      center: true,
      container: this.lightDom.carousel,
      controlsContainer: this.dom.controls,
      edgePadding: this.getSpacing().edgePadding,
      gutter: this.getSpacing().gutter,
      items: 1,
      loop: false,
      mouseDrag: true,
      nav: false,
      slideBy: 1,
      onInit: (info) => {
        this.dom.numbersTotal.innerText = info.slideCount;
        this.positionInfo();
      },
    });

Tiny-slider version: 2.9.4 Browser name && version: Firefox 116.0.2 OS name && version: Ubuntu 22.04