@plaidev/karte-action-sdk 1.1.111-27920552.d870b3e9 → 1.1.111-27920638.5cf86d22

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.
@@ -5768,9 +5768,9 @@ function instance$4($$self, $$props, $$invalidate) {
5768
5768
  const dispatch = createEventDispatcher();
5769
5769
 
5770
5770
  setContext('SLIDE', {
5771
- registerItem: ({ onBeforeSlide, onMount }) => {
5771
+ registerItem: ({ onBeforeSlide, onMount, onResize }) => {
5772
5772
  const id = new Date().getTime().toString();
5773
- $$invalidate(7, items = [...items, { id, onBeforeSlide, onMount }]);
5773
+ $$invalidate(7, items = [...items, { id, onBeforeSlide, onMount, onResize }]);
5774
5774
  return id;
5775
5775
  },
5776
5776
  unregisterItem: id => {
@@ -5865,6 +5865,21 @@ function instance$4($$self, $$props, $$invalidate) {
5865
5865
  previousMove = { clientX, timeStamp };
5866
5866
  }
5867
5867
 
5868
+ function handleResize() {
5869
+ containerWidth = containerElement.clientWidth;
5870
+
5871
+ items.forEach((item, index) => {
5872
+ item.onResize({
5873
+ shiftCount,
5874
+ containerElement,
5875
+ index,
5876
+ length: items.length
5877
+ });
5878
+ });
5879
+
5880
+ $$invalidate(8, slidePosition = containerWidth * calcPositionIndex(shiftCount, currentSlideId, items.length));
5881
+ }
5882
+
5868
5883
  function handleMoveEnd() {
5869
5884
  if (!moving) return;
5870
5885
  moving = false;
@@ -5941,6 +5956,12 @@ function instance$4($$self, $$props, $$invalidate) {
5941
5956
  containerElement.addEventListener('touchend', handleTouchEnd);
5942
5957
  containerElement.addEventListener('transitionend', handleTransitionEnd);
5943
5958
 
5959
+ const containerElementResizeObserver = new ResizeObserver(() => {
5960
+ handleResize();
5961
+ });
5962
+
5963
+ containerElementResizeObserver.observe(containerElement);
5964
+
5944
5965
  // setIndex(0);
5945
5966
  dispatch('mount', { itemsCount: items.length });
5946
5967
 
@@ -5953,6 +5974,7 @@ function instance$4($$self, $$props, $$invalidate) {
5953
5974
  containerElement.removeEventListener('touchmove', handleTouchMove);
5954
5975
  containerElement.removeEventListener('touchend', handleTouchEnd);
5955
5976
  containerElement.removeEventListener('transitionend', handleTransitionEnd);
5977
+ containerElementResizeObserver.unobserve(containerElement);
5956
5978
  };
5957
5979
  });
5958
5980
 
@@ -6111,6 +6133,21 @@ function instance$3($$self, $$props, $$invalidate) {
6111
6133
  onMount({ containerElement }) {
6112
6134
  $$invalidate(1, itemWidth = containerElement.clientWidth);
6113
6135
  },
6136
+ // TODO: onBeforeSlideと重複するロジックをまとめる
6137
+ onResize({ containerElement, shiftCount, index, length }) {
6138
+ $$invalidate(1, itemWidth = containerElement.clientWidth);
6139
+ let fixedShiftCount;
6140
+
6141
+ if (index - shiftCount < 0) {
6142
+ fixedShiftCount = shiftCount - length;
6143
+ } else if (index - shiftCount > length - 1) {
6144
+ fixedShiftCount = shiftCount + length;
6145
+ } else {
6146
+ fixedShiftCount = shiftCount;
6147
+ }
6148
+
6149
+ $$invalidate(2, itemTransform = -fixedShiftCount * (itemWidth ?? 0));
6150
+ },
6114
6151
  onBeforeSlide({ shiftCount, index, length }) {
6115
6152
  let fixedShiftCount;
6116
6153
 
package/dist/index.es.js CHANGED
@@ -5495,9 +5495,9 @@ function instance$4($$self, $$props, $$invalidate) {
5495
5495
  const dispatch = createEventDispatcher();
5496
5496
 
5497
5497
  setContext('SLIDE', {
5498
- registerItem: ({ onBeforeSlide, onMount }) => {
5498
+ registerItem: ({ onBeforeSlide, onMount, onResize }) => {
5499
5499
  const id = new Date().getTime().toString();
5500
- $$invalidate(7, items = [...items, { id, onBeforeSlide, onMount }]);
5500
+ $$invalidate(7, items = [...items, { id, onBeforeSlide, onMount, onResize }]);
5501
5501
  return id;
5502
5502
  },
5503
5503
  unregisterItem: id => {
@@ -5592,6 +5592,21 @@ function instance$4($$self, $$props, $$invalidate) {
5592
5592
  previousMove = { clientX, timeStamp };
5593
5593
  }
5594
5594
 
5595
+ function handleResize() {
5596
+ containerWidth = containerElement.clientWidth;
5597
+
5598
+ items.forEach((item, index) => {
5599
+ item.onResize({
5600
+ shiftCount,
5601
+ containerElement,
5602
+ index,
5603
+ length: items.length
5604
+ });
5605
+ });
5606
+
5607
+ $$invalidate(8, slidePosition = containerWidth * calcPositionIndex(shiftCount, currentSlideId, items.length));
5608
+ }
5609
+
5595
5610
  function handleMoveEnd() {
5596
5611
  if (!moving) return;
5597
5612
  moving = false;
@@ -5668,6 +5683,12 @@ function instance$4($$self, $$props, $$invalidate) {
5668
5683
  containerElement.addEventListener('touchend', handleTouchEnd);
5669
5684
  containerElement.addEventListener('transitionend', handleTransitionEnd);
5670
5685
 
5686
+ const containerElementResizeObserver = new ResizeObserver(() => {
5687
+ handleResize();
5688
+ });
5689
+
5690
+ containerElementResizeObserver.observe(containerElement);
5691
+
5671
5692
  // setIndex(0);
5672
5693
  dispatch('mount', { itemsCount: items.length });
5673
5694
 
@@ -5680,6 +5701,7 @@ function instance$4($$self, $$props, $$invalidate) {
5680
5701
  containerElement.removeEventListener('touchmove', handleTouchMove);
5681
5702
  containerElement.removeEventListener('touchend', handleTouchEnd);
5682
5703
  containerElement.removeEventListener('transitionend', handleTransitionEnd);
5704
+ containerElementResizeObserver.unobserve(containerElement);
5683
5705
  };
5684
5706
  });
5685
5707
 
@@ -5828,6 +5850,21 @@ function instance$3($$self, $$props, $$invalidate) {
5828
5850
  onMount({ containerElement }) {
5829
5851
  $$invalidate(1, itemWidth = containerElement.clientWidth);
5830
5852
  },
5853
+ // TODO: onBeforeSlideと重複するロジックをまとめる
5854
+ onResize({ containerElement, shiftCount, index, length }) {
5855
+ $$invalidate(1, itemWidth = containerElement.clientWidth);
5856
+ let fixedShiftCount;
5857
+
5858
+ if (index - shiftCount < 0) {
5859
+ fixedShiftCount = shiftCount - length;
5860
+ } else if (index - shiftCount > length - 1) {
5861
+ fixedShiftCount = shiftCount + length;
5862
+ } else {
5863
+ fixedShiftCount = shiftCount;
5864
+ }
5865
+
5866
+ $$invalidate(2, itemTransform = -fixedShiftCount * (itemWidth ?? 0));
5867
+ },
5831
5868
  onBeforeSlide({ shiftCount, index, length }) {
5832
5869
  let fixedShiftCount;
5833
5870
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plaidev/karte-action-sdk",
3
- "version": "1.1.111-27920552.d870b3e9",
3
+ "version": "1.1.111-27920638.5cf86d22",
4
4
  "author": "Plaid Inc.",
5
5
  "license": "Apache-2.0",
6
6
  "module": "./dist/index.es.js",