@brytdesigns/web-component-keen-slider-scrollbar 1.0.5 → 1.0.7

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.
@@ -32,7 +32,7 @@ function findClosestBreakpoint(position, breakpoints, container, scrollbar) {
32
32
  }
33
33
  function getMaxSlides(slider) {
34
34
  const perView = slider.options?.slides?.perView || 1, perScroll = slider.options?.slides?.perScroll || 1, result = Math.ceil((slider.slides.length - perView) / perScroll) + 1;
35
- if (perScroll === 1 && perView > 1) return slider.slides.length;
35
+ if (perScroll === 1 && perView === 1) return slider.slides.length;
36
36
  return result;
37
37
  }
38
38
  function getRelativeBreakpoint(slider, breakpoints) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/utils.ts"],"names":[],"mappings":"AAIO,MAAM,MAAS,GAAA,CAAA,weAAA;AAEf,SAAS,SAAU,CAAA,KAAA,EAAe,GAAM,GAAA,CAAA,QAAA,EAAW,MAAM,QAAU,EAAA;AACxE,EAAA,OAAO,KAAK,GAAI,CAAA,IAAA,CAAK,IAAI,KAAO,EAAA,GAAG,GAAG,GAAG,CAAA;AAC3C;AAEO,SAAS,+BAAA,CACd,EACA,EAAA,SAAA,EACA,SACA,EAAA;AACA,EAAA,MAAM,SAAS,EAAG,CAAA,qBAAA,EAChB,EAAA,aAAA,GAAgB,UAAU,qBAAsB,EAAA,EAChD,aAAgB,GAAA,SAAA,CAAU,uBAC1B,EAAA,YAAA,GAAe,MAAO,CAAA,IAAA,GAAO,cAAc,IAC3C,EAAA,IAAA,GAAO,CACP,EAAA,IAAA,GAAO,cAAc,KAAQ,GAAA,aAAA,CAAc,KAC3C,EAAA,WAAA,GAAc,OAAO,GAAM,GAAA,aAAA,CAAc,GACzC,EAAA,IAAA,GAAO,GACP,IAAO,GAAA,aAAA,CAAc,MAAS,GAAA,aAAA,CAAc,QAC5C,CAAI,GAAA,SAAA;AAAA,IACF,YAAe,GAAA,MAAA,CAAO,KAAQ,GAAA,C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EAAM,MAAA,OAAA,GAAW,OAAO,OAAS,EAAA,MAAA,EAAgB,WAAW,CAC1D,EAAA,SAAA,GAAa,OAAO,OAAS,EAAA,MAAA,EAAgB,aAAa,CAC1D,EAAA,MAAA,GAAS,KAAK,IAAM,CAAA,CAAA,MAAA,CAAO,OAAO,MAAS,GAAA,OAAA,IAAW,SAAS,CAAI,GAAA,CAAA;AACrE,EAAA,IAAI,cAAc,CAAK,IAAA,OAAA,GAAU,CAAG,EAAA,OAAO,OAAO,MAAO,CAAA,MAAA;AAEzD,EAAO,OAAA,MAAA;AACT;AAEO,SAAS,qBAAA,CACd,QACA,WACA,EAAA;AACA,EAAM,MAAA,SAAA,GAAY,aAAa,MAAM,CAAA,EACnC,YAAa,MAAO,CAAA,OAAA,EAAS,QAAgB,SAAa,IAAA,CAAA;AAE5D,EAAA,MAAM,WAAc,GAAA,SAAA;AAAA,IAClB,KAAK,IAAK,CAAA,MAAA,CAAO,KAAM,CAAA,OAAA,CAAQ,MAAM,SAAS,CAAA;AAAA,IAC9C,CAAA;AAAA,IACA,SAAY,GAAA;AAAA,GACd;AAEA,EAAA,OAAO,YAAY,WAAW,CAAA;AAChC","file":"utils.js","sourcesContent":["import type { KeenSliderInstance } from \"@brytdesigns/web-component-keen-slider\";\nimport type { ICustomElement } from \"component-register\";\nimport type { DragEventData } from \"@neodrag/vanilla\";\n\nexport const srOnly = `border-width:0 !important;clip:rect(1px, 1px, 1px, 1px) !important;-webkit-clip-path:inset(50%) !important;clip-path:inset(50%) !important;height:1px !important;margin-top:-1px !important;margin-bottom:-1px !important;margin-right:-1px !important;margin-left:-1px !important;overflow:hidden !important;padding-top:0 !important;padding-bottom:0 !important;padding-right:0 !important;padding-left:0 !important;position:absolute !important;width:1px !important;white-space:nowrap !important;`;\n\nexport function constrain(value: number, min = -Infinity, max = Infinity) {\n return Math.max(Math.min(value, max), min);\n}\n\nexport function calculateMidpointPositionFromBP(\n bp: Element,\n container: HTMLElement,\n scrollbar: HTMLElement\n) {\n const bpRect = bp.getBoundingClientRect(),\n scrollbarRect = scrollbar.getBoundingClientRect(),\n containerRect = container.getBoundingClientRect(),\n relativeLeft = bpRect.left - containerRect.left,\n minX = 0,\n maxX = containerRect.width - scrollbarRect.width,\n relativeTop = bpRect.top - containerRect.top,\n minY = 0,\n maxY = containerRect.height - scrollbarRect.height,\n x = constrain(\n relativeLeft + bpRect.width / 2 - scrollbarRect.width / 2,\n minX,\n maxX\n ),\n y = constrain(\n relativeTop + bpRect.height / 2 - scrollbarRect.height / 2,\n minY,\n maxY\n );\n\n return { x, y };\n}\n\nexport function findClosestBreakpoint(\n position: DragEventData,\n breakpoints: HTMLCollection,\n container: HTMLElement,\n scrollbar: HTMLElement\n) {\n const min = 0,\n max = breakpoints.length - 1;\n\n let closestDiff = { x: Infinity, y: Infinity },\n bpIndex = min;\n\n for (let i = min; i <= max; i++) {\n const bp = breakpoints[i];\n if (!bp) continue;\n const midpointP = calculateMidpointPositionFromBP(bp, container, scrollbar);\n const diffX = Math.abs(midpointP.x - position.offsetX);\n const diffY = Math.abs(midpointP.y - position.offsetY);\n if (diffX <= closestDiff.x && diffY <= closestDiff.y) {\n closestDiff = { x: diffX, y: diffY };\n bpIndex = i;\n }\n }\n\n return breakpoints[bpIndex];\n}\n\nexport function getMaxSlides(slider: KeenSliderInstance) {\n const perView = (slider.options?.slides as any)?.perView || 1,\n perScroll = (slider.options?.slides as any)?.perScroll || 1,\n result = Math.ceil((slider.slides.length - perView) / perScroll) + 1;\n if (perScroll === 1 && perView > 1) return slider.slides.length;\n\n return result;\n}\n\nexport function getRelativeBreakpoint(\n slider: KeenSliderInstance,\n breakpoints: HTMLCollection\n) {\n const maxSlides = getMaxSlides(slider),\n perScroll = (slider.options?.slides as any)?.perScroll || 1;\n\n const relativeIdx = constrain(\n Math.ceil(slider.track.details.rel / perScroll),\n 0,\n maxSlides - 1\n );\n\n return breakpoints[relativeIdx];\n}\n"]}
1
+ {"version":3,"sources":["../../src/utils.ts"],"names":[],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,SAAa,IAAA,CAAA;AAE5D,EAAA,MAAM,WAAc,GAAA,SAAA;AAAA,IAClB,KAAK,IAAK,CAAA,MAAA,CAAO,KAAM,CAAA,OAAA,CAAQ,MAAM,SAAS,CAAA;AAAA,IAC9C,CAAA;AAAA,IACA,SAAY,GAAA;AAAA,GACd;AAEA,EAAA,OAAO,YAAY,WAAW,CAAA;AAChC","file":"utils.js","sourcesContent":["import type { KeenSliderInstance } from \"@brytdesigns/web-component-keen-slider\";\nimport type { ICustomElement } from \"component-register\";\nimport type { DragEventData } from \"@neodrag/vanilla\";\n\nexport const srOnly = `border-width:0 !important;clip:rect(1px, 1px, 1px, 1px) !important;-webkit-clip-path:inset(50%) !important;clip-path:inset(50%) !important;height:1px !important;margin-top:-1px !important;margin-bottom:-1px !important;margin-right:-1px !important;margin-left:-1px !important;overflow:hidden !important;padding-top:0 !important;padding-bottom:0 !important;padding-right:0 !important;padding-left:0 !important;position:absolute !important;width:1px !important;white-space:nowrap !important;`;\n\nexport function constrain(value: number, min = -Infinity, max = Infinity) {\n return Math.max(Math.min(value, max), min);\n}\n\nexport function calculateMidpointPositionFromBP(\n bp: Element,\n container: HTMLElement,\n scrollbar: HTMLElement\n) {\n const bpRect = bp.getBoundingClientRect(),\n scrollbarRect = scrollbar.getBoundingClientRect(),\n containerRect = container.getBoundingClientRect(),\n relativeLeft = bpRect.left - containerRect.left,\n minX = 0,\n maxX = containerRect.width - scrollbarRect.width,\n relativeTop = bpRect.top - containerRect.top,\n minY = 0,\n maxY = containerRect.height - scrollbarRect.height,\n x = constrain(\n relativeLeft + bpRect.width / 2 - scrollbarRect.width / 2,\n minX,\n maxX\n ),\n y = constrain(\n relativeTop + bpRect.height / 2 - scrollbarRect.height / 2,\n minY,\n maxY\n );\n\n return { x, y };\n}\n\nexport function findClosestBreakpoint(\n position: DragEventData,\n breakpoints: HTMLCollection,\n container: HTMLElement,\n scrollbar: HTMLElement\n) {\n const min = 0,\n max = breakpoints.length - 1;\n\n let closestDiff = { x: Infinity, y: Infinity },\n bpIndex = min;\n\n for (let i = min; i <= max; i++) {\n const bp = breakpoints[i];\n if (!bp) continue;\n const midpointP = calculateMidpointPositionFromBP(bp, container, scrollbar);\n const diffX = Math.abs(midpointP.x - position.offsetX);\n const diffY = Math.abs(midpointP.y - position.offsetY);\n if (diffX <= closestDiff.x && diffY <= closestDiff.y) {\n closestDiff = { x: diffX, y: diffY };\n bpIndex = i;\n }\n }\n\n return breakpoints[bpIndex];\n}\n\nexport function getMaxSlides(slider: KeenSliderInstance) {\n const perView = (slider.options?.slides as any)?.perView || 1,\n perScroll = (slider.options?.slides as any)?.perScroll || 1,\n result = Math.ceil((slider.slides.length - perView) / perScroll) + 1;\n if (perScroll === 1 && perView === 1) return slider.slides.length;\n\n return result;\n}\n\nexport function getRelativeBreakpoint(\n slider: KeenSliderInstance,\n breakpoints: HTMLCollection\n) {\n const maxSlides = getMaxSlides(slider),\n perScroll = (slider.options?.slides as any)?.perScroll || 1;\n\n const relativeIdx = constrain(\n Math.ceil(slider.track.details.rel / perScroll),\n 0,\n maxSlides - 1\n );\n\n return breakpoints[relativeIdx];\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brytdesigns/web-component-keen-slider-scrollbar",
3
- "version": "1.0.5",
3
+ "version": "1.0.7",
4
4
  "description": "Keen slider scrollbar web component",
5
5
  "main": "./dist/main/index.js",
6
6
  "module": "./dist/main/index.js",
@@ -23,9 +23,9 @@
23
23
  "component-register": "^0.8.7",
24
24
  "popmotion": "^11.0.5",
25
25
  "solid-element": "^1.9.1",
26
- "solid-js": "^1.9.5",
27
- "@brytdesigns/web-component-keen-slider": "1.0.3",
28
- "@brytdesigns/web-component-utils": "0.1.8"
26
+ "solid-js": "^1.9.6",
27
+ "@brytdesigns/web-component-keen-slider": "1.0.4",
28
+ "@brytdesigns/web-component-utils": "0.1.9"
29
29
  },
30
30
  "devDependencies": {
31
31
  "dts-bundle-generator": "^9.5.1",