@inappstory/slide-api 0.1.16 → 0.1.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -3082,6 +3082,7 @@ class Layer {
3082
3082
  _showNextSlide;
3083
3083
  sdkApi;
3084
3084
  _slideRoot;
3085
+ _getLayoutDirection;
3085
3086
  _slidePauseUI;
3086
3087
  _slideResumeUI;
3087
3088
  _slideIndex;
@@ -3094,7 +3095,7 @@ class Layer {
3094
3095
  _elements = [];
3095
3096
  _timeline;
3096
3097
  _widgetDeps;
3097
- constructor(_nodeRef, _slide, _slideReadyPromise, _afterAppResumeQueuePush, _afterStartInitQueuePush, _showNextSlide, sdkApi, _slideRoot, _slidePauseUI, _slideResumeUI) {
3098
+ constructor(_nodeRef, _slide, _slideReadyPromise, _afterAppResumeQueuePush, _afterStartInitQueuePush, _showNextSlide, sdkApi, _slideRoot, _getLayoutDirection, _slidePauseUI, _slideResumeUI) {
3098
3099
  this._nodeRef = _nodeRef;
3099
3100
  this._slide = _slide;
3100
3101
  this._slideReadyPromise = _slideReadyPromise;
@@ -3103,6 +3104,7 @@ class Layer {
3103
3104
  this._showNextSlide = _showNextSlide;
3104
3105
  this.sdkApi = sdkApi;
3105
3106
  this._slideRoot = _slideRoot;
3107
+ this._getLayoutDirection = _getLayoutDirection;
3106
3108
  this._slidePauseUI = _slidePauseUI;
3107
3109
  this._slideResumeUI = _slideResumeUI;
3108
3110
  this._slideIndex = parseInt(this._nodeRef.getAttribute("data-index") ?? "0");
@@ -3113,7 +3115,7 @@ class Layer {
3113
3115
  this._disabledTimer = this._nodeRef.getAttribute("data-disable-timer") === "1";
3114
3116
  this._disabledNavigation = this._nodeRef.getAttribute("data-disable-navigation") === "1";
3115
3117
  this._timeline = new SlideTimeline(this._slideIndex, this._duration, this._disabledTimer, this._slideReadyPromise, this._afterAppResumeQueuePush, this.sdkApi);
3116
- this._widgetDeps = { sdkApi: this.sdkApi, slideRoot: this._slideRoot };
3118
+ this._widgetDeps = { sdkApi: this.sdkApi, slideRoot: this._slideRoot, getLayoutDirection: this._getLayoutDirection };
3117
3119
  const onWidgetComplete = (cardId, slideIndex) => {
3118
3120
  // todo if nothing more widgets with disabled timers - we can start layer timeline
3119
3121
  const fallback = () => this._showNextSlide(DEFAULT_SLIDE_DURATION);
@@ -3167,10 +3169,7 @@ class Layer {
3167
3169
  return promises;
3168
3170
  }
3169
3171
  onAfterAllMediaResourcesLoaded() {
3170
- if (this.sdkApi.isIOS) {
3171
- // only for bug in WKWebWebkit
3172
- this._initTextElementAutoWidthCorrection();
3173
- }
3172
+ if (this.sdkApi.isIOS) ;
3174
3173
  this._initTextFit();
3175
3174
  }
3176
3175
  get nodeRef() {
@@ -3453,7 +3452,7 @@ class Layer {
3453
3452
  get isLayerForcePaused() {
3454
3453
  return this.elements.some(element => element.isLayerForcePaused);
3455
3454
  }
3456
- static get [Symbol.for("___CTOR_ARGS___")]() { return [`HTMLElement`, `Slide`, `Promise`, `(cb: () => void) => void`, `(cb: () => void) => void`, `(duration: number) => void`, `SDKApi`, `HTMLElement`, `() => Promise<void>`, `() => Promise<void>`]; }
3455
+ static get [Symbol.for("___CTOR_ARGS___")]() { return [`HTMLElement`, `Slide`, `Promise`, `(cb: () => void) => void`, `(cb: () => void) => void`, `(duration: number) => void`, `SDKApi`, `HTMLElement`, `() => "ltr" | "rtl"`, `() => Promise<void>`, `() => Promise<void>`]; }
3457
3456
  }
3458
3457
  const TextFit = (function () {
3459
3458
  const defaultSettings = {
@@ -3632,7 +3631,8 @@ class TextElementAutoWidthCorrection {
3632
3631
  // });
3633
3632
  // }, 10 * 1000);
3634
3633
  textRef.style.setProperty("min-width", `${textMinWidth}px`);
3635
- textRef.style.setProperty("max-width", `${textMaxWidth}px`);
3634
+ // try to fix - to small max-width of text in iOS IAM (removing max-width from css)
3635
+ // textRef.style.setProperty("max-width", `${textMaxWidth}px`);
3636
3636
  }
3637
3637
  }
3638
3638
  static get [Symbol.for("___CTOR_ARGS___")]() { return [`HTMLElement`]; }
@@ -3646,11 +3646,12 @@ class Slide {
3646
3646
  _showNextSlide;
3647
3647
  sdkApi;
3648
3648
  _slideRoot;
3649
+ _getLayoutDirection;
3649
3650
  _slidePauseUI;
3650
3651
  _slideResumeUI;
3651
3652
  _layers;
3652
3653
  _start;
3653
- constructor(_slidesNodesRefs, _slideReadyPromise, _afterAppResumeQueuePush, _afterStartInitQueuePush, _showNextSlide, sdkApi, _slideRoot, _slidePauseUI, _slideResumeUI) {
3654
+ constructor(_slidesNodesRefs, _slideReadyPromise, _afterAppResumeQueuePush, _afterStartInitQueuePush, _showNextSlide, sdkApi, _slideRoot, _getLayoutDirection, _slidePauseUI, _slideResumeUI) {
3654
3655
  this._slidesNodesRefs = _slidesNodesRefs;
3655
3656
  this._slideReadyPromise = _slideReadyPromise;
3656
3657
  this._afterAppResumeQueuePush = _afterAppResumeQueuePush;
@@ -3658,13 +3659,14 @@ class Slide {
3658
3659
  this._showNextSlide = _showNextSlide;
3659
3660
  this.sdkApi = sdkApi;
3660
3661
  this._slideRoot = _slideRoot;
3662
+ this._getLayoutDirection = _getLayoutDirection;
3661
3663
  this._slidePauseUI = _slidePauseUI;
3662
3664
  this._slideResumeUI = _slideResumeUI;
3663
3665
  this._start = window.performance.now();
3664
3666
  if (!this._slidesNodesRefs.length) {
3665
3667
  throw new Error("No slides found.");
3666
3668
  }
3667
- this._layers = this._slidesNodesRefs.map(item => new Layer(item, this, this._slideReadyPromise, this._afterAppResumeQueuePush, this._afterStartInitQueuePush, this._showNextSlide, this.sdkApi, this._slideRoot, this._slidePauseUI, this._slideResumeUI));
3669
+ this._layers = this._slidesNodesRefs.map(item => new Layer(item, this, this._slideReadyPromise, this._afterAppResumeQueuePush, this._afterStartInitQueuePush, this._showNextSlide, this.sdkApi, this._slideRoot, this._getLayoutDirection, this._slidePauseUI, this._slideResumeUI));
3668
3670
  this._activeLayer = this._layers[0];
3669
3671
  }
3670
3672
  _activeLayer;
@@ -3683,7 +3685,11 @@ class Slide {
3683
3685
  const multiSlideApi = this.layoutService.layoutApi.widgetMultiSlideApi;
3684
3686
  if (multiSlideApi != null && this.layers.length > 1) {
3685
3687
  try {
3686
- multiSlideApi.init(this.layersNodesRefs, localData, { sdkApi: this.sdkApi, slideRoot: this._slideRoot });
3688
+ multiSlideApi.init(this.layersNodesRefs, localData, {
3689
+ sdkApi: this.sdkApi,
3690
+ slideRoot: this._slideRoot,
3691
+ getLayoutDirection: this._getLayoutDirection,
3692
+ });
3687
3693
  }
3688
3694
  catch (e) {
3689
3695
  console.error(e);
@@ -3756,7 +3762,7 @@ class Slide {
3756
3762
  get disabledNavigation() {
3757
3763
  return this._activeLayer.disabledNavigation;
3758
3764
  }
3759
- static get [Symbol.for("___CTOR_ARGS___")]() { return [`Array`, `Promise`, `(cb: () => void) => void`, `(cb: () => void) => void`, `(duration: number) => void`, `SDKApi`, `HTMLElement`, `() => Promise<void>`, `() => Promise<void>`]; }
3765
+ static get [Symbol.for("___CTOR_ARGS___")]() { return [`Array`, `Promise`, `(cb: () => void) => void`, `(cb: () => void) => void`, `(duration: number) => void`, `SDKApi`, `HTMLElement`, `() => "ltr" | "rtl"`, `() => Promise<void>`, `() => Promise<void>`]; }
3760
3766
  }
3761
3767
 
3762
3768
  let SlideApi$1 = class SlideApi {
@@ -4043,7 +4049,7 @@ let SlideApi$1 = class SlideApi {
4043
4049
  const slideReadyPromise = new Promise(resolve => {
4044
4050
  slideReadyResolve = resolve;
4045
4051
  });
4046
- const slide = new Slide(slidesNodesRefs, slideReadyPromise, this.afterAppResumeQueuePush.bind(this), this.afterStartInitQueuePush.bind(this), this.sdkApi.showNextSlide.bind(this), this.sdkApi, this._slideWrapper, this.slidePauseUI.bind(this), this.slideResumeUI.bind(this));
4052
+ const slide = new Slide(slidesNodesRefs, slideReadyPromise, this.afterAppResumeQueuePush.bind(this), this.afterStartInitQueuePush.bind(this), this.sdkApi.showNextSlide.bind(this), this.sdkApi, this._slideWrapper, () => this.layoutDirection, this.slidePauseUI.bind(this), this.slideResumeUI.bind(this));
4047
4053
  this._slideInInit = slide;
4048
4054
  slide.activeLayer.timeline.triggerSlideLoadState();
4049
4055
  if (this.sdkApi.isAndroid) {
@@ -16869,14 +16875,14 @@ class Formatter {
16869
16875
  const formatter = new Formatter({ determineLocale, i18n: undefined });
16870
16876
 
16871
16877
  class SwipeGestureDetector {
16872
- env;
16878
+ slideRoot;
16873
16879
  isScreenSupportsTouch;
16874
16880
  canContinueHandleDown;
16875
16881
  onStart;
16876
16882
  onUpdate;
16877
16883
  onEnd;
16878
- constructor(env, isScreenSupportsTouch, canContinueHandleDown, onStart, onUpdate, onEnd) {
16879
- this.env = env;
16884
+ constructor(slideRoot, isScreenSupportsTouch, canContinueHandleDown, onStart, onUpdate, onEnd) {
16885
+ this.slideRoot = slideRoot;
16880
16886
  this.isScreenSupportsTouch = isScreenSupportsTouch;
16881
16887
  this.canContinueHandleDown = canContinueHandleDown;
16882
16888
  this.onStart = onStart;
@@ -16888,10 +16894,10 @@ class SwipeGestureDetector {
16888
16894
  this.handleEnd = this.handleEnd.bind(this);
16889
16895
  this.supportsTouch = false;
16890
16896
  if (this.isScreenSupportsTouch) {
16891
- this.env.document.addEventListener("touchstart", this.handleDown, false);
16897
+ this.slideRoot.addEventListener("touchstart", this.handleDown, false);
16892
16898
  }
16893
16899
  else {
16894
- this.env.document.addEventListener("mousedown", this.handleDown, false);
16900
+ this.slideRoot.addEventListener("mousedown", this.handleDown, false);
16895
16901
  }
16896
16902
  }
16897
16903
  startPageCoordinate = [0, 0];
@@ -16906,12 +16912,12 @@ class SwipeGestureDetector {
16906
16912
  }
16907
16913
  this.startPageCoordinate = this.getPageCoordinate(e);
16908
16914
  if (this.isScreenSupportsTouch) {
16909
- this.env.document.addEventListener("touchmove", this.handleMove, false);
16910
- this.env.document.addEventListener("touchend", this.handleEnd, false);
16915
+ this.slideRoot.addEventListener("touchmove", this.handleMove, false);
16916
+ this.slideRoot.addEventListener("touchend", this.handleEnd, false);
16911
16917
  }
16912
16918
  else {
16913
- this.env.document.addEventListener("mousemove", this.handleMove, false);
16914
- this.env.document.addEventListener("mouseup", this.handleEnd, false);
16919
+ this.slideRoot.addEventListener("mousemove", this.handleMove, false);
16920
+ this.slideRoot.addEventListener("mouseup", this.handleEnd, false);
16915
16921
  }
16916
16922
  this.onStart(e);
16917
16923
  }
@@ -16922,12 +16928,12 @@ class SwipeGestureDetector {
16922
16928
  }
16923
16929
  handleEnd(e) {
16924
16930
  if (this.isScreenSupportsTouch) {
16925
- this.env.document.removeEventListener("touchmove", this.handleMove);
16926
- this.env.document.removeEventListener("touchend", this.handleEnd);
16931
+ this.slideRoot.removeEventListener("touchmove", this.handleMove);
16932
+ this.slideRoot.removeEventListener("touchend", this.handleEnd);
16927
16933
  }
16928
16934
  else {
16929
- this.env.document.removeEventListener("mousemove", this.handleMove);
16930
- this.env.document.removeEventListener("mouseup", this.handleEnd);
16935
+ this.slideRoot.removeEventListener("mousemove", this.handleMove);
16936
+ this.slideRoot.removeEventListener("mouseup", this.handleEnd);
16931
16937
  }
16932
16938
  const currentPageCoordinate = this.getPageCoordinate(e);
16933
16939
  let gesture = 0 /* SwipeGesture.undefined */;
@@ -16971,14 +16977,14 @@ class SwipeGestureDetector {
16971
16977
  }
16972
16978
  destroy() {
16973
16979
  if (this.isScreenSupportsTouch) {
16974
- this.env.document.removeEventListener("touchstart", this.handleDown);
16975
- this.env.document.removeEventListener("touchmove", this.handleMove);
16976
- this.env.document.removeEventListener("touchend", this.handleEnd);
16980
+ this.slideRoot.removeEventListener("touchstart", this.handleDown);
16981
+ this.slideRoot.removeEventListener("touchmove", this.handleMove);
16982
+ this.slideRoot.removeEventListener("touchend", this.handleEnd);
16977
16983
  }
16978
16984
  else {
16979
- this.env.document.removeEventListener("mousedown", this.handleDown);
16980
- this.env.document.removeEventListener("mousemove", this.handleMove);
16981
- this.env.document.removeEventListener("mouseup", this.handleEnd);
16985
+ this.slideRoot.removeEventListener("mousedown", this.handleDown);
16986
+ this.slideRoot.removeEventListener("mousemove", this.handleMove);
16987
+ this.slideRoot.removeEventListener("mouseup", this.handleEnd);
16982
16988
  }
16983
16989
  }
16984
16990
  getPageCoordinate(e) {
@@ -17011,7 +17017,7 @@ class SwipeGestureDetector {
17011
17017
  }
17012
17018
  return [x, y];
17013
17019
  }
17014
- static get [Symbol.for("___CTOR_ARGS___")]() { return [`Window`, `boolean`, `(e: MouseEvent | TouchEvent) => boolean`, `(e: MouseEvent | TouchEvent) => void`, `(e: MouseEvent | TouchEvent) => void`, `(e: MouseEvent | TouchEvent, gesture: SwipeGesture) => void`]; }
17020
+ static get [Symbol.for("___CTOR_ARGS___")]() { return [`HTMLElement`, `boolean`, `(e: MouseEvent | TouchEvent) => boolean`, `(e: MouseEvent | TouchEvent) => void`, `(e: MouseEvent | TouchEvent) => void`, `(e: MouseEvent | TouchEvent, gesture: SwipeGesture) => void`]; }
17015
17021
  }
17016
17022
 
17017
17023
  /**
@@ -17252,7 +17258,7 @@ class WidgetProducts extends WidgetBase {
17252
17258
  initSwipeGestureDetector() {
17253
17259
  if (this.isOpen) {
17254
17260
  if (this.swipeGestureDetector == null) {
17255
- this.swipeGestureDetector = new SwipeGestureDetector(this.env, this.isScreenSupportsTouch,
17261
+ this.swipeGestureDetector = new SwipeGestureDetector(this.widgetDeps.slideRoot, this.isScreenSupportsTouch,
17256
17262
  // detect gestures started on backdrop view
17257
17263
  (e) => e.target instanceof HTMLElement ? e.target.classList.contains("ias-products-container-backdrop-view") : true, e => {
17258
17264
  // this.isClickCapturedByWidget = true;
@@ -18572,8 +18578,8 @@ class WidgetRangeSlider extends WidgetBase {
18572
18578
  isTouchListenersInit = false;
18573
18579
  initTouchListeners() {
18574
18580
  if (!this.isTouchListenersInit) {
18575
- this.env.document.addEventListener("touchstart", this.handleDown);
18576
- this.env.document.addEventListener("mousedown", this.handleDown);
18581
+ this.widgetDeps.slideRoot.addEventListener("touchstart", this.handleDown);
18582
+ this.widgetDeps.slideRoot.addEventListener("mousedown", this.handleDown);
18577
18583
  this.isTouchListenersInit = true;
18578
18584
  }
18579
18585
  }
@@ -18701,7 +18707,7 @@ class WidgetRangeSlider extends WidgetBase {
18701
18707
  }
18702
18708
  if (this.elementAverageResult != null && averageValue !== null) {
18703
18709
  this.update(true, false);
18704
- const positionDimension = this.env.document.documentElement.dir === "rtl" ? "right" : "left";
18710
+ const positionDimension = this.widgetDeps.getLayoutDirection() === "rtl" ? "right" : "left";
18705
18711
  const position = this.getPositionFromValue(averageValue) + this.handleDimension / 2;
18706
18712
  this.elementAverageResult.style[positionDimension] = position + "px";
18707
18713
  // this.elementAverageResult.style.display = 'block';
@@ -18786,10 +18792,10 @@ class WidgetRangeSlider extends WidgetBase {
18786
18792
  if (!this.maxHandlePos) {
18787
18793
  this.update(true, false);
18788
18794
  }
18789
- this.env.document.addEventListener("touchmove", this.handleMove);
18790
- this.env.document.addEventListener("touchend", this.handleEnd);
18791
- this.env.document.addEventListener("mousemove", this.handleMove);
18792
- this.env.document.addEventListener("mouseup", this.handleEnd);
18795
+ this.widgetDeps.slideRoot.addEventListener("touchmove", this.handleMove);
18796
+ this.widgetDeps.slideRoot.addEventListener("touchend", this.handleEnd);
18797
+ this.widgetDeps.slideRoot.addEventListener("mousemove", this.handleMove);
18798
+ this.widgetDeps.slideRoot.addEventListener("mouseup", this.handleEnd);
18793
18799
  // add active class because Firefox is ignoring
18794
18800
  // the handle:active pseudo selector because of `e.preventDefault();`
18795
18801
  this.range.classList.add(this.options.activeClass);
@@ -18815,10 +18821,10 @@ class WidgetRangeSlider extends WidgetBase {
18815
18821
  this.widgetDeps.sdkApi.enableHorizontalSwipeGesture();
18816
18822
  });
18817
18823
  // e.preventDefault();
18818
- this.env.document.removeEventListener("touchmove", this.handleMove);
18819
- this.env.document.removeEventListener("touchend", this.handleEnd);
18820
- this.env.document.removeEventListener("mousemove", this.handleMove);
18821
- this.env.document.removeEventListener("mouseup", this.handleEnd);
18824
+ this.widgetDeps.slideRoot.removeEventListener("touchmove", this.handleMove);
18825
+ this.widgetDeps.slideRoot.removeEventListener("touchend", this.handleEnd);
18826
+ this.widgetDeps.slideRoot.removeEventListener("mousemove", this.handleMove);
18827
+ this.widgetDeps.slideRoot.removeEventListener("mouseup", this.handleEnd);
18822
18828
  this.range.classList.remove(this.options.activeClass);
18823
18829
  this.element.classList.add("input-done");
18824
18830
  if (!this.hasSubmitButton) {
@@ -18948,12 +18954,12 @@ class WidgetRangeSlider extends WidgetBase {
18948
18954
  // .trigger('input', {origin: this.identifier});
18949
18955
  }
18950
18956
  destroy() {
18951
- this.env.document.removeEventListener("touchstart", this.handleDown);
18952
- this.env.document.removeEventListener("mousedown", this.handleDown);
18953
- this.env.document.removeEventListener("touchmove", this.handleMove);
18954
- this.env.document.removeEventListener("touchend", this.handleEnd);
18955
- this.env.document.removeEventListener("mousemove", this.handleMove);
18956
- this.env.document.removeEventListener("mouseup", this.handleEnd);
18957
+ this.widgetDeps.slideRoot.removeEventListener("touchstart", this.handleDown);
18958
+ this.widgetDeps.slideRoot.removeEventListener("mousedown", this.handleDown);
18959
+ this.widgetDeps.slideRoot.removeEventListener("touchmove", this.handleMove);
18960
+ this.widgetDeps.slideRoot.removeEventListener("touchend", this.handleEnd);
18961
+ this.widgetDeps.slideRoot.removeEventListener("mousemove", this.handleMove);
18962
+ this.widgetDeps.slideRoot.removeEventListener("mouseup", this.handleEnd);
18957
18963
  this.isTouchListenersInit = false;
18958
18964
  // off resize event
18959
18965
  // this.$window.off('.' + this.identifier);