@inappstory/slide-api 0.0.23 → 0.0.24

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
@@ -15815,6 +15815,7 @@ class SwipeGestureDetector {
15815
15815
  threshold = Math.max(1, Math.floor(0.01 * this.pageWidth));
15816
15816
  supportsTouch = false;
15817
15817
  handleDown(e) {
15818
+ // console.log("handleDown", {e, startPageCoordinate: this.startPageCoordinate})
15818
15819
  if (!this.canContinueHandleDown(e)) {
15819
15820
  return;
15820
15821
  }
@@ -15886,9 +15887,13 @@ class SwipeGestureDetector {
15886
15887
  destroy() {
15887
15888
  if (this.isScreenSupportsTouch) {
15888
15889
  this.env.document.removeEventListener("touchstart", this.handleDown);
15890
+ this.env.document.removeEventListener("touchmove", this.handleMove);
15891
+ this.env.document.removeEventListener("touchend", this.handleEnd);
15889
15892
  }
15890
15893
  else {
15891
15894
  this.env.document.removeEventListener("mousedown", this.handleDown);
15895
+ this.env.document.removeEventListener("mousemove", this.handleMove);
15896
+ this.env.document.removeEventListener("mouseup", this.handleEnd);
15892
15897
  }
15893
15898
  }
15894
15899
  getPageCoordinate(e) {
@@ -16150,23 +16155,30 @@ class WidgetProducts extends WidgetBase {
16150
16155
  }
16151
16156
  initSwipeGestureDetector() {
16152
16157
  if (this.isOpen) {
16153
- this.swipeGestureDetector = new SwipeGestureDetector(this.env, this.isScreenSupportsTouch, () => true, e => {
16154
- // this.isClickCapturedByWidget = true;
16155
- return;
16156
- }, e => {
16157
- return;
16158
- }, (e, gesture) => {
16159
- if (gesture === 3 /* SwipeGesture.SwipeDown */) {
16160
- this.closeProductsView();
16161
- }
16162
- // this.env.requestAnimationFrame(() => {
16163
- // this.isClickCapturedByWidget = false;
16164
- // });
16165
- });
16158
+ if (this.swipeGestureDetector == null) {
16159
+ this.swipeGestureDetector = new SwipeGestureDetector(this.env, this.isScreenSupportsTouch,
16160
+ // detect gestures started on backdrop view
16161
+ (e) => e.target instanceof HTMLElement ? e.target.classList.contains("ias-products-container-backdrop-view") : true, e => {
16162
+ // this.isClickCapturedByWidget = true;
16163
+ return;
16164
+ }, e => {
16165
+ return;
16166
+ }, (e, gesture) => {
16167
+ if (gesture === 3 /* SwipeGesture.SwipeDown */) {
16168
+ this.closeProductsView();
16169
+ }
16170
+ // this.env.requestAnimationFrame(() => {
16171
+ // this.isClickCapturedByWidget = false;
16172
+ // });
16173
+ });
16174
+ }
16166
16175
  }
16167
16176
  }
16168
16177
  productsView = null;
16169
16178
  isOpen = false;
16179
+ get isForcePaused() {
16180
+ return this.isOpen;
16181
+ }
16170
16182
  currentModels = [];
16171
16183
  async openProductsView() {
16172
16184
  if (this.isOpen) {
@@ -16214,6 +16226,7 @@ class WidgetProducts extends WidgetBase {
16214
16226
  this.isClickCapturedByWidget = false;
16215
16227
  if (this.swipeGestureDetector != null) {
16216
16228
  this.swipeGestureDetector.destroy();
16229
+ this.swipeGestureDetector = null;
16217
16230
  }
16218
16231
  this.sdkApi.enableVerticalSwipeGesture();
16219
16232
  this.sdkApi.enableBackpress();
@@ -16282,14 +16295,56 @@ class WidgetProducts extends WidgetBase {
16282
16295
  return card;
16283
16296
  }
16284
16297
  createScrollView(offers) {
16298
+ const scrollViewGroup = document.createElement("div");
16299
+ scrollViewGroup.classList.add("ias-products-scroll-view-group");
16285
16300
  const scrollView = document.createElement("div");
16286
16301
  scrollView.classList.add("ias-products-scroll-view");
16287
16302
  offers.forEach(offer => scrollView.appendChild(this.createCardView(offer)));
16288
- return scrollView;
16303
+ scrollViewGroup.appendChild(scrollView);
16304
+ if (!this.isScreenSupportsTouch) {
16305
+ const { scrollLeft, scrollRight, mountScrollControls } = this.createScrollControls(scrollView);
16306
+ const scrollControlsView = document.createElement("div");
16307
+ scrollControlsView.classList.add("ias-products-scroll-controls-view");
16308
+ const scrollControlStartView = document.createElement("div");
16309
+ scrollControlStartView.classList.add("ias-products-scroll-control-start-view");
16310
+ const scrollControlStartIconView = document.createElement("div");
16311
+ scrollControlStartIconView.classList.add("ias-products-scroll-control-start-icon-view");
16312
+ scrollControlStartView.appendChild(scrollControlStartIconView);
16313
+ scrollControlsView.appendChild(scrollControlStartView);
16314
+ scrollControlStartView.onclick = e => {
16315
+ e.preventDefault();
16316
+ e.stopPropagation();
16317
+ if (this.layoutDirection === "ltr") {
16318
+ scrollLeft();
16319
+ }
16320
+ else {
16321
+ scrollRight();
16322
+ }
16323
+ };
16324
+ const scrollControlEndView = document.createElement("div");
16325
+ scrollControlEndView.classList.add("ias-products-scroll-control-end-view");
16326
+ const scrollControlEndIconView = document.createElement("div");
16327
+ scrollControlEndIconView.classList.add("ias-products-scroll-control-end-icon-view");
16328
+ scrollControlEndView.appendChild(scrollControlEndIconView);
16329
+ scrollControlsView.appendChild(scrollControlEndView);
16330
+ scrollControlEndView.onclick = e => {
16331
+ e.preventDefault();
16332
+ e.stopPropagation();
16333
+ if (this.layoutDirection === "ltr") {
16334
+ scrollRight();
16335
+ }
16336
+ else {
16337
+ scrollLeft();
16338
+ }
16339
+ };
16340
+ mountScrollControls(() => scrollViewGroup.appendChild(scrollControlsView));
16341
+ }
16342
+ return scrollViewGroup;
16289
16343
  }
16290
16344
  createProductsView(offers, onClose) {
16291
16345
  const containerView = document.createElement("div");
16292
16346
  containerView.classList.add("ias-products-container-view");
16347
+ containerView.dir = this.layoutDirection;
16293
16348
  const backdropView = document.createElement("div");
16294
16349
  backdropView.classList.add("ias-products-container-backdrop-view");
16295
16350
  backdropView.onclick = e => {
@@ -16315,6 +16370,32 @@ class WidgetProducts extends WidgetBase {
16315
16370
  containerView.appendChild(backgroundView);
16316
16371
  return containerView;
16317
16372
  }
16373
+ scrollViewRef = null;
16374
+ getScrollLeft() {
16375
+ if (this.scrollViewRef != null) {
16376
+ return this.scrollViewRef.scrollLeft;
16377
+ }
16378
+ return 0;
16379
+ }
16380
+ getScrollViewportWidth() {
16381
+ if (this.scrollViewRef != null) {
16382
+ return this.scrollViewRef.clientWidth;
16383
+ }
16384
+ return 0;
16385
+ }
16386
+ setScrollLeft(value) {
16387
+ if (this.scrollViewRef != null) {
16388
+ this.scrollViewRef.scrollLeft = Math.round(value);
16389
+ }
16390
+ }
16391
+ createScrollControls(scrollViewRef) {
16392
+ this.scrollViewRef = scrollViewRef;
16393
+ return {
16394
+ scrollLeft: () => this.setScrollLeft(this.getScrollLeft() - this.getScrollViewportWidth()),
16395
+ scrollRight: () => this.setScrollLeft(this.getScrollLeft() + this.getScrollViewportWidth()),
16396
+ mountScrollControls: (cb) => this.env.requestAnimationFrame(() => scrollViewRef.scrollWidth > scrollViewRef.clientWidth && cb()),
16397
+ };
16398
+ }
16318
16399
  getIsClickCapturedByWidget() {
16319
16400
  return this.isClickCapturedByWidget;
16320
16401
  }
@@ -16360,6 +16441,16 @@ class WidgetProducts extends WidgetBase {
16360
16441
  }
16361
16442
  return false;
16362
16443
  },
16444
+ isForcePaused: function (element) {
16445
+ const widgetElement = element.closest(`.${WidgetProducts.widgetClassName}`);
16446
+ if (widgetElement) {
16447
+ const widget = WidgetProducts.getInstance(widgetElement);
16448
+ if (widget) {
16449
+ return widget.isForcePaused;
16450
+ }
16451
+ }
16452
+ return false;
16453
+ },
16363
16454
  onHandleBackpress: function (element) {
16364
16455
  const widgetElement = element.closest(`.${WidgetProducts.widgetClassName}`);
16365
16456
  if (widgetElement) {