aptechka 0.88.8 → 0.88.10
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/lib/notched/index.cjs +1 -16
- package/lib/notched/index.js +7 -30
- package/lib/scroll-kit/index.cjs +1 -1
- package/lib/scroll-kit/index.js +3 -2
- package/package.json +1 -1
package/lib/notched/index.cjs
CHANGED
|
@@ -44,19 +44,4 @@
|
|
|
44
44
|
a ${cornerRadius} ${cornerRadius} 0 0 1 ${arcSectionLength} -${arcSectionLength}
|
|
45
45
|
c ${c} ${-d}
|
|
46
46
|
${b+c} ${-d}
|
|
47
|
-
${a+b+c} ${-d}`:rounded`l 0 ${-p}`}__name(drawTopLeftPath,"drawTopLeftPath");function toRadians(degrees){return degrees*Math.PI/180}__name(toRadians,"toRadians");function rounded(strings,...values){return strings.reduce((acc,str,i)=>{const value=values[i];return typeof value=="number"?acc+str+value.toFixed(4):acc+str+(value!=null?value:"")},"")}__name(rounded,"rounded");function getSvgPath({cornerRadius=0,topLeftCornerRadius,topRightCornerRadius,bottomRightCornerRadius,bottomLeftCornerRadius,cornerAngleAlpha=90,topLeftCornerAngleAlpha,topRightCornerAngleAlpha,bottomRightCornerAngleAlpha,bottomLeftCornerAngleAlpha,cornerSmoothing,preserveSmoothing=!1,topNotches,rightNotches,bottomNotches,leftNotches,width,height}){if(topLeftCornerRadius=topLeftCornerRadius!=null?topLeftCornerRadius:cornerRadius,topRightCornerRadius=topRightCornerRadius!=null?topRightCornerRadius:cornerRadius,bottomLeftCornerRadius=bottomLeftCornerRadius!=null?bottomLeftCornerRadius:cornerRadius,bottomRightCornerRadius=bottomRightCornerRadius!=null?bottomRightCornerRadius:cornerRadius,topLeftCornerAngleAlpha=topLeftCornerAngleAlpha!=null?topLeftCornerAngleAlpha:cornerAngleAlpha,topRightCornerAngleAlpha=topRightCornerAngleAlpha!=null?topRightCornerAngleAlpha:cornerAngleAlpha,bottomLeftCornerAngleAlpha=bottomLeftCornerAngleAlpha!=null?bottomLeftCornerAngleAlpha:cornerAngleAlpha,bottomRightCornerAngleAlpha=bottomRightCornerAngleAlpha!=null?bottomRightCornerAngleAlpha:cornerAngleAlpha,topLeftCornerRadius===topRightCornerRadius&&topRightCornerRadius===bottomRightCornerRadius&&bottomRightCornerRadius===bottomLeftCornerRadius&&bottomLeftCornerRadius===topLeftCornerRadius&&topLeftCornerAngleAlpha===topRightCornerAngleAlpha&&topRightCornerAngleAlpha===bottomRightCornerAngleAlpha&&bottomRightCornerAngleAlpha===bottomLeftCornerAngleAlpha&&bottomLeftCornerAngleAlpha===topLeftCornerAngleAlpha){const roundingAndSmoothingBudget=Math.min(width,height)/2,cornerRadius2=Math.min(topLeftCornerRadius,roundingAndSmoothingBudget),pathParams=getPathParamsForCorner({cornerRadius:cornerRadius2,cornerSmoothing,cornerAngleAlpha,preserveSmoothing,roundingAndSmoothingBudget});return getSVGPathFromPathParams({width,height,topLeftPathParams:pathParams,topRightPathParams:pathParams,bottomLeftPathParams:pathParams,bottomRightPathParams:pathParams,topNotches,rightNotches,bottomNotches,leftNotches})}const{topLeft,topRight,bottomLeft,bottomRight}=distributeAndNormalize({topLeftCornerRadius,topRightCornerRadius,bottomRightCornerRadius,bottomLeftCornerRadius,width,height});return getSVGPathFromPathParams({width,height,topLeftPathParams:getPathParamsForCorner({cornerSmoothing,preserveSmoothing,cornerRadius:topLeft.radius,roundingAndSmoothingBudget:topLeft.roundingAndSmoothingBudget,cornerAngleAlpha:topLeftCornerAngleAlpha}),topRightPathParams:getPathParamsForCorner({cornerSmoothing,preserveSmoothing,cornerRadius:topRight.radius,roundingAndSmoothingBudget:topRight.roundingAndSmoothingBudget,cornerAngleAlpha:topRightCornerAngleAlpha}),bottomRightPathParams:getPathParamsForCorner({cornerSmoothing,preserveSmoothing,cornerRadius:bottomRight.radius,roundingAndSmoothingBudget:bottomRight.roundingAndSmoothingBudget,cornerAngleAlpha:bottomRightCornerAngleAlpha}),bottomLeftPathParams:getPathParamsForCorner({cornerSmoothing,preserveSmoothing,cornerRadius:bottomLeft.radius,roundingAndSmoothingBudget:bottomLeft.roundingAndSmoothingBudget,cornerAngleAlpha:bottomLeftCornerAngleAlpha}),topNotches,rightNotches,bottomNotches,leftNotches})}__name(getSvgPath,"getSvgPath");var
|
|
48
|
-
<svg xmlns="http://www.w3.org/2000/svg">
|
|
49
|
-
${clipId?`<clipPath id="${clipId}">`:""}
|
|
50
|
-
<path></path>
|
|
51
|
-
${clipId?"</clipPath>":""}
|
|
52
|
-
</svg>
|
|
53
|
-
<slot></slot>
|
|
54
|
-
`,clipId&&(clipContent&&this.firstElementChild instanceof HTMLElement?this.firstElementChild.style.clipPath=`url(#${clipId})`:this.style.clipPath=`url(#${clipId})`),this.style.position="relative",__privateSet(this,_svgElement,tmpElement.querySelector("svg")),__privateGet(this,_svgElement).style.cssText=`
|
|
55
|
-
position: absolute;
|
|
56
|
-
top: 0;
|
|
57
|
-
left: 0;
|
|
58
|
-
zIndex: -1;
|
|
59
|
-
display: block;
|
|
60
|
-
width: 100%;
|
|
61
|
-
height: 100%;
|
|
62
|
-
`,__privateSet(this,_pathElement,tmpElement.querySelector("path")),this.prepend(tmpElement.firstElementChild)}connectedCallback(){elementResizer_index.elementResizer.subscribe(this,__privateGet(this,_resizeListener)),intersector_index.ticker.subscribe(__privateGet(this,_resizeListener))}disconnectedCallback(){elementResizer_index.elementResizer.unsubscribe(__privateGet(this,_resizeListener))}};_svgElement=new WeakMap,_pathElement=new WeakMap,_resizeListener=new WeakMap,_NotchedElement_instances=new WeakSet,parseCSSNotchValue_fn=__name(function(value){const notchesString=value.split(",").map(v=>v.trim()).filter(v=>!!v),notches=[];return notchesString.forEach(notchString=>{const valuesStrings=notchString.split(" ").map(v=>v.trim()).filter(v=>!!v);notches.push({start:cssUnitParser_index.cssUnitParser.parse(valuesStrings[0])||0,length:cssUnitParser_index.cssUnitParser.parse(valuesStrings[1])||0,slope:cssUnitParser_index.cssUnitParser.parse(valuesStrings[2])||0,depth:cssUnitParser_index.cssUnitParser.parse(valuesStrings[3])||0})}),notches},"#parseCSSNotchValue"),__name(_NotchedElement,"NotchedElement");let NotchedElement=_NotchedElement;customElements.get("e-notched")||customElements.define("e-notched",NotchedElement);exports.NotchedElement=NotchedElement;
|
|
47
|
+
${a+b+c} ${-d}`:rounded`l 0 ${-p}`}__name(drawTopLeftPath,"drawTopLeftPath");function toRadians(degrees){return degrees*Math.PI/180}__name(toRadians,"toRadians");function rounded(strings,...values){return strings.reduce((acc,str,i)=>{const value=values[i];return typeof value=="number"?acc+str+value.toFixed(4):acc+str+(value!=null?value:"")},"")}__name(rounded,"rounded");function getSvgPath({cornerRadius=0,topLeftCornerRadius,topRightCornerRadius,bottomRightCornerRadius,bottomLeftCornerRadius,cornerAngleAlpha=90,topLeftCornerAngleAlpha,topRightCornerAngleAlpha,bottomRightCornerAngleAlpha,bottomLeftCornerAngleAlpha,cornerSmoothing,preserveSmoothing=!1,topNotches,rightNotches,bottomNotches,leftNotches,width,height}){if(topLeftCornerRadius=topLeftCornerRadius!=null?topLeftCornerRadius:cornerRadius,topRightCornerRadius=topRightCornerRadius!=null?topRightCornerRadius:cornerRadius,bottomLeftCornerRadius=bottomLeftCornerRadius!=null?bottomLeftCornerRadius:cornerRadius,bottomRightCornerRadius=bottomRightCornerRadius!=null?bottomRightCornerRadius:cornerRadius,topLeftCornerAngleAlpha=topLeftCornerAngleAlpha!=null?topLeftCornerAngleAlpha:cornerAngleAlpha,topRightCornerAngleAlpha=topRightCornerAngleAlpha!=null?topRightCornerAngleAlpha:cornerAngleAlpha,bottomLeftCornerAngleAlpha=bottomLeftCornerAngleAlpha!=null?bottomLeftCornerAngleAlpha:cornerAngleAlpha,bottomRightCornerAngleAlpha=bottomRightCornerAngleAlpha!=null?bottomRightCornerAngleAlpha:cornerAngleAlpha,topLeftCornerRadius===topRightCornerRadius&&topRightCornerRadius===bottomRightCornerRadius&&bottomRightCornerRadius===bottomLeftCornerRadius&&bottomLeftCornerRadius===topLeftCornerRadius&&topLeftCornerAngleAlpha===topRightCornerAngleAlpha&&topRightCornerAngleAlpha===bottomRightCornerAngleAlpha&&bottomRightCornerAngleAlpha===bottomLeftCornerAngleAlpha&&bottomLeftCornerAngleAlpha===topLeftCornerAngleAlpha){const roundingAndSmoothingBudget=Math.min(width,height)/2,cornerRadius2=Math.min(topLeftCornerRadius,roundingAndSmoothingBudget),pathParams=getPathParamsForCorner({cornerRadius:cornerRadius2,cornerSmoothing,cornerAngleAlpha,preserveSmoothing,roundingAndSmoothingBudget});return getSVGPathFromPathParams({width,height,topLeftPathParams:pathParams,topRightPathParams:pathParams,bottomLeftPathParams:pathParams,bottomRightPathParams:pathParams,topNotches,rightNotches,bottomNotches,leftNotches})}const{topLeft,topRight,bottomLeft,bottomRight}=distributeAndNormalize({topLeftCornerRadius,topRightCornerRadius,bottomRightCornerRadius,bottomLeftCornerRadius,width,height});return getSVGPathFromPathParams({width,height,topLeftPathParams:getPathParamsForCorner({cornerSmoothing,preserveSmoothing,cornerRadius:topLeft.radius,roundingAndSmoothingBudget:topLeft.roundingAndSmoothingBudget,cornerAngleAlpha:topLeftCornerAngleAlpha}),topRightPathParams:getPathParamsForCorner({cornerSmoothing,preserveSmoothing,cornerRadius:topRight.radius,roundingAndSmoothingBudget:topRight.roundingAndSmoothingBudget,cornerAngleAlpha:topRightCornerAngleAlpha}),bottomRightPathParams:getPathParamsForCorner({cornerSmoothing,preserveSmoothing,cornerRadius:bottomRight.radius,roundingAndSmoothingBudget:bottomRight.roundingAndSmoothingBudget,cornerAngleAlpha:bottomRightCornerAngleAlpha}),bottomLeftPathParams:getPathParamsForCorner({cornerSmoothing,preserveSmoothing,cornerRadius:bottomLeft.radius,roundingAndSmoothingBudget:bottomLeft.roundingAndSmoothingBudget,cornerAngleAlpha:bottomLeftCornerAngleAlpha}),topNotches,rightNotches,bottomNotches,leftNotches})}__name(getSvgPath,"getSvgPath");var _clipId,_resizeListener,_NotchedElement_instances,parseCSSNotchValue_fn;const _NotchedElement=class _NotchedElement extends HTMLElement{constructor(){super();__privateAdd(this,_NotchedElement_instances);__privateAdd(this,_clipId);__privateAdd(this,_resizeListener,__name(()=>{const width=this.offsetWidth,height=this.offsetHeight,computed=getComputedStyle(this),cornerRadius=cssUnitParser_index.cssUnitParser.parse(computed.getPropertyValue("--notched-corner-radius")),topLeftCornerRadius=cssUnitParser_index.cssUnitParser.parse(computed.getPropertyValue("--notched-top-left-corner-radius")),topRightCornerRadius=cssUnitParser_index.cssUnitParser.parse(computed.getPropertyValue("--notched-top-right-corner-radius")),bottomRightCornerRadius=cssUnitParser_index.cssUnitParser.parse(computed.getPropertyValue("--notched-bottom-right-corner-radius")),bottomLeftCornerRadius=cssUnitParser_index.cssUnitParser.parse(computed.getPropertyValue("--notched-bottom-left-corner-radius")),cornerAngleAlpha=parseFloat(computed.getPropertyValue("--notched-corner-angle-alpha"))||void 0,topLeftCornerAngleAlpha=parseFloat(computed.getPropertyValue("--notched-top-left-corner-angle-alpha"))||void 0,topRightCornerAngleAlpha=parseFloat(computed.getPropertyValue("--notched-top-right-corner-angle-alpha"))||void 0,bottomRightCornerAngleAlpha=parseFloat(computed.getPropertyValue("--notched-bottom-right-corner-angle-alpha"))||void 0,bottomLeftCornerAngleAlpha=parseFloat(computed.getPropertyValue("--notched-bottom-left-corner-angle-alpha"))||void 0,cornerSmoothing=parseFloat(computed.getPropertyValue("--notched-corner-smoothing"))||0,preserveSmoothing=computed.getPropertyValue("--notched-preserve-smoothing")!=="false",topNotches=__privateMethod(this,_NotchedElement_instances,parseCSSNotchValue_fn).call(this,computed.getPropertyValue("--notched-top-notches")),rightNotches=__privateMethod(this,_NotchedElement_instances,parseCSSNotchValue_fn).call(this,computed.getPropertyValue("--notched-right-notches")),bottomNotches=__privateMethod(this,_NotchedElement_instances,parseCSSNotchValue_fn).call(this,computed.getPropertyValue("--notched-bottom-notches")),leftNotches=__privateMethod(this,_NotchedElement_instances,parseCSSNotchValue_fn).call(this,computed.getPropertyValue("--notched-left-notches")),path=getSvgPath({cornerRadius,topLeftCornerRadius,topRightCornerRadius,bottomRightCornerRadius,bottomLeftCornerRadius,cornerAngleAlpha,topLeftCornerAngleAlpha,topRightCornerAngleAlpha,bottomRightCornerAngleAlpha,bottomLeftCornerAngleAlpha,cornerSmoothing,preserveSmoothing,topNotches,rightNotches,bottomNotches,leftNotches,width,height});this.style.maskImage=`url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='${this.offsetWidth}' height='${this.offsetHeight}' viewBox='0 0 ${this.offsetWidth} ${this.offsetHeight}'%3E%3Cdefs%3E%3CclipPath id='${__privateGet(this,_clipId)}'%3E%3Cpath fill='%23000' d='${path}'/%3E%3C/clipPath%3E%3C/defs%3E%3Cg clip-path='url(%23${__privateGet(this,_clipId)})' %3E%3Crect width='${this.offsetWidth}' height='${this.offsetHeight}' fill='%23000'/%3E%3C/g%3E%3C/svg%3E")`,this.style.maskPosition="center center",this.style.maskRepeat="no-repeat",this.style.maskSize="contain"},"#resizeListener"));__privateSet(this,_clipId,"clip-"+string.generateId(10))}connectedCallback(){elementResizer_index.elementResizer.subscribe(this,__privateGet(this,_resizeListener)),intersector_index.ticker.subscribe(__privateGet(this,_resizeListener))}disconnectedCallback(){elementResizer_index.elementResizer.unsubscribe(__privateGet(this,_resizeListener))}};_clipId=new WeakMap,_resizeListener=new WeakMap,_NotchedElement_instances=new WeakSet,parseCSSNotchValue_fn=__name(function(value){const notchesString=value.split(",").map(v=>v.trim()).filter(v=>!!v),notches=[];return notchesString.forEach(notchString=>{const valuesStrings=notchString.split(" ").map(v=>v.trim()).filter(v=>!!v);notches.push({start:cssUnitParser_index.cssUnitParser.parse(valuesStrings[0])||0,length:cssUnitParser_index.cssUnitParser.parse(valuesStrings[1])||0,slope:cssUnitParser_index.cssUnitParser.parse(valuesStrings[2])||0,depth:cssUnitParser_index.cssUnitParser.parse(valuesStrings[3])||0})}),notches},"#parseCSSNotchValue"),__name(_NotchedElement,"NotchedElement");let NotchedElement=_NotchedElement;customElements.get("e-notched")||customElements.define("e-notched",NotchedElement);exports.NotchedElement=NotchedElement;
|
package/lib/notched/index.js
CHANGED
|
@@ -372,21 +372,14 @@ function getSvgPath({
|
|
|
372
372
|
});
|
|
373
373
|
}
|
|
374
374
|
__name(getSvgPath, "getSvgPath");
|
|
375
|
-
var
|
|
375
|
+
var _clipId, _resizeListener, _NotchedElement_instances, parseCSSNotchValue_fn;
|
|
376
376
|
const _NotchedElement = class _NotchedElement extends HTMLElement {
|
|
377
377
|
constructor() {
|
|
378
378
|
super();
|
|
379
379
|
__privateAdd(this, _NotchedElement_instances);
|
|
380
|
-
__privateAdd(this,
|
|
381
|
-
__privateAdd(this, _pathElement);
|
|
380
|
+
__privateAdd(this, _clipId);
|
|
382
381
|
__privateAdd(this, _resizeListener, /* @__PURE__ */ __name(() => {
|
|
383
|
-
const width = this.offsetWidth, height = this.offsetHeight, computed = getComputedStyle(this)
|
|
384
|
-
__privateGet(this, _svgElement).setAttributeNS(
|
|
385
|
-
"http://www.w3.org/2000/svg",
|
|
386
|
-
"viewBox",
|
|
387
|
-
`0 0 ${width} ${height}`
|
|
388
|
-
);
|
|
389
|
-
const cornerRadius = cssUnitParser.parse(
|
|
382
|
+
const width = this.offsetWidth, height = this.offsetHeight, computed = getComputedStyle(this), cornerRadius = cssUnitParser.parse(
|
|
390
383
|
computed.getPropertyValue("--notched-corner-radius")
|
|
391
384
|
), topLeftCornerRadius = cssUnitParser.parse(
|
|
392
385
|
computed.getPropertyValue("--notched-top-left-corner-radius")
|
|
@@ -404,7 +397,7 @@ const _NotchedElement = class _NotchedElement extends HTMLElement {
|
|
|
404
397
|
computed.getPropertyValue("--notched-bottom-right-corner-angle-alpha")
|
|
405
398
|
) || void 0, bottomLeftCornerAngleAlpha = parseFloat(
|
|
406
399
|
computed.getPropertyValue("--notched-bottom-left-corner-angle-alpha")
|
|
407
|
-
) || void 0, cornerSmoothing = parseFloat(computed.getPropertyValue("--notched-corner-smoothing")) || 0, preserveSmoothing = computed.getPropertyValue("--notched-preserve-smoothing") !== "false", topNotches = __privateMethod(this, _NotchedElement_instances, parseCSSNotchValue_fn).call(this, computed.getPropertyValue("--notched-top-notches")), rightNotches = __privateMethod(this, _NotchedElement_instances, parseCSSNotchValue_fn).call(this, computed.getPropertyValue("--notched-right-notches")), bottomNotches = __privateMethod(this, _NotchedElement_instances, parseCSSNotchValue_fn).call(this, computed.getPropertyValue("--notched-bottom-notches")), leftNotches = __privateMethod(this, _NotchedElement_instances, parseCSSNotchValue_fn).call(this, computed.getPropertyValue("--notched-left-notches")),
|
|
400
|
+
) || void 0, cornerSmoothing = parseFloat(computed.getPropertyValue("--notched-corner-smoothing")) || 0, preserveSmoothing = computed.getPropertyValue("--notched-preserve-smoothing") !== "false", topNotches = __privateMethod(this, _NotchedElement_instances, parseCSSNotchValue_fn).call(this, computed.getPropertyValue("--notched-top-notches")), rightNotches = __privateMethod(this, _NotchedElement_instances, parseCSSNotchValue_fn).call(this, computed.getPropertyValue("--notched-right-notches")), bottomNotches = __privateMethod(this, _NotchedElement_instances, parseCSSNotchValue_fn).call(this, computed.getPropertyValue("--notched-bottom-notches")), leftNotches = __privateMethod(this, _NotchedElement_instances, parseCSSNotchValue_fn).call(this, computed.getPropertyValue("--notched-left-notches")), path = getSvgPath({
|
|
408
401
|
cornerRadius,
|
|
409
402
|
topLeftCornerRadius,
|
|
410
403
|
topRightCornerRadius,
|
|
@@ -424,25 +417,9 @@ const _NotchedElement = class _NotchedElement extends HTMLElement {
|
|
|
424
417
|
width,
|
|
425
418
|
height
|
|
426
419
|
});
|
|
427
|
-
|
|
420
|
+
this.style.maskImage = `url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='${this.offsetWidth}' height='${this.offsetHeight}' viewBox='0 0 ${this.offsetWidth} ${this.offsetHeight}'%3E%3Cdefs%3E%3CclipPath id='${__privateGet(this, _clipId)}'%3E%3Cpath fill='%23000' d='${path}'/%3E%3C/clipPath%3E%3C/defs%3E%3Cg clip-path='url(%23${__privateGet(this, _clipId)})' %3E%3Crect width='${this.offsetWidth}' height='${this.offsetHeight}' fill='%23000'/%3E%3C/g%3E%3C/svg%3E")`, this.style.maskPosition = "center center", this.style.maskRepeat = "no-repeat", this.style.maskSize = "contain";
|
|
428
421
|
}, "#resizeListener"));
|
|
429
|
-
|
|
430
|
-
tmpElement.innerHTML = `
|
|
431
|
-
<svg xmlns="http://www.w3.org/2000/svg">
|
|
432
|
-
${clipId ? `<clipPath id="${clipId}">` : ""}
|
|
433
|
-
<path></path>
|
|
434
|
-
${clipId ? "</clipPath>" : ""}
|
|
435
|
-
</svg>
|
|
436
|
-
<slot></slot>
|
|
437
|
-
`, clipId && (clipContent && this.firstElementChild instanceof HTMLElement ? this.firstElementChild.style.clipPath = `url(#${clipId})` : this.style.clipPath = `url(#${clipId})`), this.style.position = "relative", __privateSet(this, _svgElement, tmpElement.querySelector("svg")), __privateGet(this, _svgElement).style.cssText = `
|
|
438
|
-
position: absolute;
|
|
439
|
-
top: 0;
|
|
440
|
-
left: 0;
|
|
441
|
-
zIndex: -1;
|
|
442
|
-
display: block;
|
|
443
|
-
width: 100%;
|
|
444
|
-
height: 100%;
|
|
445
|
-
`, __privateSet(this, _pathElement, tmpElement.querySelector("path")), this.prepend(tmpElement.firstElementChild);
|
|
422
|
+
__privateSet(this, _clipId, "clip-" + generateId(10));
|
|
446
423
|
}
|
|
447
424
|
connectedCallback() {
|
|
448
425
|
elementResizer.subscribe(this, __privateGet(this, _resizeListener)), ticker.subscribe(__privateGet(this, _resizeListener));
|
|
@@ -451,7 +428,7 @@ const _NotchedElement = class _NotchedElement extends HTMLElement {
|
|
|
451
428
|
elementResizer.unsubscribe(__privateGet(this, _resizeListener));
|
|
452
429
|
}
|
|
453
430
|
};
|
|
454
|
-
|
|
431
|
+
_clipId = new WeakMap(), _resizeListener = new WeakMap(), _NotchedElement_instances = new WeakSet(), parseCSSNotchValue_fn = /* @__PURE__ */ __name(function(value) {
|
|
455
432
|
const notchesString = value.split(",").map((v) => v.trim()).filter((v) => !!v), notches = [];
|
|
456
433
|
return notchesString.forEach((notchString) => {
|
|
457
434
|
const valuesStrings = notchString.split(" ").map((v) => v.trim()).filter((v) => !!v);
|
package/lib/scroll-kit/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var __defProp=Object.defineProperty;var __typeError=msg=>{throw TypeError(msg)};var __name=(target,value)=>__defProp(target,"name",{value,configurable:!0});var __accessCheck=(obj,member,msg)=>member.has(obj)||__typeError("Cannot "+msg);var __privateGet=(obj,member,getter)=>(__accessCheck(obj,member,"read from private field"),getter?getter.call(obj):member.get(obj)),__privateAdd=(obj,member,value)=>member.has(obj)?__typeError("Cannot add the same private member more than once"):member instanceof WeakSet?member.add(obj):member.set(obj,value),__privateSet=(obj,member,value,setter)=>(__accessCheck(obj,member,"write to private field"),setter?setter.call(obj,value):member.set(obj,value),value),__privateMethod=(obj,member,method)=>(__accessCheck(obj,member,"access private method"),method);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const intersector_index=require("../index-Cz5-98rw.cjs"),dom=require("../dom-B40i6NXw.cjs"),gestures=require("../gestures-DtYbQr49.cjs");require("construct-style-sheets-polyfill");const order_index=require("../order/index.cjs");require("../Store-BkYJHJp5.cjs");const scroll=require("../scroll-Dv9QcIKd.cjs"),Damped=require("../Damped-CYCcZu-z.cjs"),Tweened=require("../Tweened-BoGo9vz9.cjs"),cssProperty_index=require("../css-property/index.cjs"),Viewport=require("../Viewport-DwPeXyM2.cjs"),scrollEntries_index=require("../scroll-entries/index.cjs"),elementLinkedStore_index=require("../element-linked-store/index.cjs"),elementResizer_index=require("../element-resizer/index.cjs"),events=require("../events-UlGk63iC.cjs"),layout=require("../layout-CnGLl7oe.cjs"),math=require("../math-C-knY2TL.cjs"),windowResizer_index=require("../window-resizer/index.cjs");var _scrollElement,_thumbElement,_thumbScrollSize,_limit,_isHorizontal,_activeTimeoutId,_ScrollbarElement_instances,scrollPosition_get,scrollSize_get,scrollViewportSize_get,_scrollListener,_resizeListener,_grabListener,_tickListener,_intersectionListener;const _ScrollbarElement=class _ScrollbarElement extends HTMLElement{constructor(){super(...arguments);__privateAdd(this,_ScrollbarElement_instances);__privateAdd(this,_scrollElement,null);__privateAdd(this,_thumbElement,null);__privateAdd(this,_thumbScrollSize,0);__privateAdd(this,_limit,0);__privateAdd(this,_isHorizontal,!1);__privateAdd(this,_activeTimeoutId);__privateAdd(this,_scrollListener,__name(()=>{this.classList.add("active"),clearTimeout(__privateGet(this,_activeTimeoutId));const position=__privateGet(this,_ScrollbarElement_instances,scrollPosition_get)/__privateGet(this,_limit)*__privateGet(this,_thumbScrollSize);__privateGet(this,_isHorizontal)?__privateGet(this,_thumbElement).style.transform=`translate3d(${position}px, 0px, 0px)`:__privateGet(this,_thumbElement).style.transform=`translate3d(0px, ${position}px, 0px)`,__privateSet(this,_activeTimeoutId,setTimeout(()=>{this.classList.remove("active")},1e3))},"#scrollListener"));__privateAdd(this,_resizeListener,__name(()=>{const barSize=__privateGet(this,_isHorizontal)?this.offsetWidth:this.offsetHeight,scrollSize=__privateGet(this,_ScrollbarElement_instances,scrollSize_get),viewportSize=__privateGet(this,_ScrollbarElement_instances,scrollViewportSize_get);__privateSet(this,_limit,scrollSize-viewportSize);let thumbSize=barSize*barSize/(__privateGet(this,_limit)+barSize);thumbSize=Math.max(thumbSize,30),__privateGet(this,_isHorizontal)?(__privateGet(this,_thumbElement).style.width=thumbSize+"px",__privateGet(this,_thumbElement).style.height="100%"):(__privateGet(this,_thumbElement).style.width="100%",__privateGet(this,_thumbElement).style.height=thumbSize+"px"),__privateSet(this,_thumbScrollSize,barSize-thumbSize),scrollSize<=viewportSize?this.style.display="none":this.style.display="block"},"#resizeListener"));__privateAdd(this,_grabListener,__name(grabEvent=>{const startValue=__privateGet(this,_ScrollbarElement_instances,scrollPosition_get),grabCursor=__privateGet(this,_isHorizontal)?grabEvent.x:grabEvent.y;gestures.setupDrag(moveEvent=>{const mult=__privateGet(this,_limit)/__privateGet(this,_thumbScrollSize),delta=(__privateGet(this,_isHorizontal)?moveEvent.x-grabCursor:moveEvent.y-grabCursor)*mult;__privateGet(this,_isHorizontal)?__privateGet(this,_scrollElement).scroll({left:startValue+delta,behavior:"instant"}):__privateGet(this,_scrollElement).scroll({top:startValue+delta,behavior:"instant"})})},"#grabListener"));__privateAdd(this,_tickListener,__name(()=>{__privateGet(this,_resizeListener).call(this)},"#tickListener"));__privateAdd(this,_intersectionListener,__name(e=>{e.isIntersecting?(intersector_index.ticker.subscribe(__privateGet(this,_tickListener),{maxFPS:5}),__privateGet(this,_tickListener).call(this)):intersector_index.ticker.unsubscribe(__privateGet(this,_tickListener))},"#intersectionListener"))}connectedCallback(){const scrollSelector=this.getAttribute("data-scroll");let scrollElement=null;scrollSelector&&(scrollSelector==="parent"?scrollElement=this.parentElement:scrollElement=document.querySelector(scrollSelector)),scrollElement||(scrollElement=dom.findScrollParentElement(this),scrollElement===document.body&&(scrollElement=window)),__privateSet(this,_isHorizontal,this.hasAttribute("horisontal"));const thumbElement=this.querySelector("[data-thumb]");scrollElement&&thumbElement&&(__privateSet(this,_scrollElement,scrollElement),__privateSet(this,_thumbElement,thumbElement),__privateGet(this,_scrollElement).addEventListener("scroll",__privateGet(this,_scrollListener)),__privateGet(this,_thumbElement).addEventListener("pointerdown",__privateGet(this,_grabListener)),intersector_index.intersector.subscribe(this.parentElement===document.body?this:this.parentElement,__privateGet(this,_intersectionListener)))}disconnectedCallback(){var _a,_b;(_a=__privateGet(this,_scrollElement))==null||_a.removeEventListener("scroll",__privateGet(this,_scrollListener)),(_b=__privateGet(this,_thumbElement))==null||_b.removeEventListener("pointerdown",__privateGet(this,_grabListener)),clearTimeout(__privateGet(this,_activeTimeoutId)),intersector_index.intersector.unsubscribe(__privateGet(this,_intersectionListener)),intersector_index.ticker.unsubscribe(__privateGet(this,_tickListener))}};_scrollElement=new WeakMap,_thumbElement=new WeakMap,_thumbScrollSize=new WeakMap,_limit=new WeakMap,_isHorizontal=new WeakMap,_activeTimeoutId=new WeakMap,_ScrollbarElement_instances=new WeakSet,scrollPosition_get=__name(function(){return __privateGet(this,_scrollElement)instanceof HTMLElement?__privateGet(this,_isHorizontal)?__privateGet(this,_scrollElement).scrollLeft:__privateGet(this,_scrollElement).scrollTop:__privateGet(this,_isHorizontal)?__privateGet(this,_scrollElement).scrollX:__privateGet(this,_scrollElement).scrollY},"#scrollPosition"),scrollSize_get=__name(function(){return __privateGet(this,_scrollElement)instanceof HTMLElement?__privateGet(this,_isHorizontal)?__privateGet(this,_scrollElement).scrollWidth:__privateGet(this,_scrollElement).scrollHeight:__privateGet(this,_isHorizontal)?Math.max(document.body.scrollWidth,document.documentElement.scrollWidth,document.body.offsetWidth,document.documentElement.offsetWidth,document.body.clientWidth,document.documentElement.clientWidth):Math.max(document.body.scrollHeight,document.documentElement.scrollHeight,document.body.offsetHeight,document.documentElement.offsetHeight,document.body.clientHeight,document.documentElement.clientHeight)},"#scrollSize"),scrollViewportSize_get=__name(function(){return __privateGet(this,_scrollElement)instanceof HTMLElement?__privateGet(this,_isHorizontal)?__privateGet(this,_scrollElement).offsetWidth:__privateGet(this,_scrollElement).offsetHeight:__privateGet(this,_isHorizontal)?innerWidth:innerHeight},"#scrollViewportSize"),_scrollListener=new WeakMap,_resizeListener=new WeakMap,_grabListener=new WeakMap,_tickListener=new WeakMap,_intersectionListener=new WeakMap,__name(_ScrollbarElement,"ScrollbarElement");let ScrollbarElement=_ScrollbarElement;intersector_index.isBrowser&&!customElements.get("e-scrollbar")&&customElements.define("e-scrollbar",ScrollbarElement);const scrollKeys=new Set(["ArrowUp","ArrowDown","ArrowLeft","ArrowRight","PageUp","PageDown","Home","End","Space"]);var _cssDisabled,_cssDamping,_value,_currentRoundedValue,_needSync,_tweened,_SmoothScrollElement_instances,checkDisabled_fn,destroyTweened_fn,_wheelListener,_pointerdownListener,_resizeListener2,_keydownListener,_scrollListener2;const _SmoothScrollElement=class _SmoothScrollElement extends HTMLElement{constructor(){super(...arguments);__privateAdd(this,_SmoothScrollElement_instances);__privateAdd(this,_cssDisabled,new cssProperty_index.CSSProperty(this,"--smooth-scroll-disabled",!1));__privateAdd(this,_cssDamping,new cssProperty_index.CSSProperty(this,"--smooth-scroll-damping",10));__privateAdd(this,_value,new Damped.Damped(0));__privateAdd(this,_currentRoundedValue,0);__privateAdd(this,_needSync,!1);__privateAdd(this,_tweened);__privateAdd(this,_wheelListener,__name(e=>{if(!(__privateMethod(this,_SmoothScrollElement_instances,checkDisabled_fn).call(this)||Viewport.device.isMobile)){if(__privateMethod(this,_SmoothScrollElement_instances,destroyTweened_fn).call(this),Math.sign(e.deltaY)<0&&__privateGet(this,_value).target===0&&__privateGet(this,_value).direction<0||Math.sign(e.deltaY)>0&&__privateGet(this,_value).target===__privateGet(this,_value).max&&__privateGet(this,_value).direction>0||e.stopPropagation(),e.target instanceof Element){const preventElement=e.target.closest("[data-prevent-smooth-scroll]");if(preventElement){const attrValue=preventElement.getAttribute("data-prevent-smooth-scroll");if(attrValue){if(matchMedia(attrValue).matches)return}else return}}Math.abs(e.deltaX)>Math.abs(e.deltaY)||(e.preventDefault(),this.shiftPosition(e.deltaY))}},"#wheelListener"));__privateAdd(this,_pointerdownListener,__name(e=>{if(!(e.button!==0||__privateMethod(this,_SmoothScrollElement_instances,checkDisabled_fn).call(this)||Viewport.device.isMobile)&&e.target instanceof Element){const anchorElement=e.target.closest("a");if(anchorElement){this.stop();const url=new URL(anchorElement.href);url.hash&&(e.preventDefault(),scroll.scrollToElement(url.hash,{behavior:anchorElement.getAttribute("data-behavior")||"smooth",center:anchorElement.hasAttribute("data-center"),offset:anchorElement.getAttribute("data-offset")||void 0,scrollElement:this,scrollCallback:__name((top,behaviour)=>{const duration=parseFloat(anchorElement.getAttribute("data-duration")||"0"),easing=anchorElement.getAttribute("data-easing");duration?(__privateGet(this,_tweened)&&__privateGet(this,_tweened).close(),__privateSet(this,_tweened,new Tweened.Tweened(__privateGet(this,_value).current,{duration,easing,order:order_index.TICK_ORDER.SCROLL})),__privateGet(this,_tweened).subscribe(e2=>{this.setPosition(e2.current,{equalize:!0})}),__privateGet(this,_tweened).set(top,{duration,easing})):this.setPosition(top,{equalize:behaviour==="instant"})},"scrollCallback")}))}}},"#pointerdownListener"));__privateAdd(this,_resizeListener2,__name(()=>{this.resize(),this.sync()},"#resizeListener"));__privateAdd(this,_keydownListener,__name(e=>{__privateMethod(this,_SmoothScrollElement_instances,checkDisabled_fn).call(this)||(__privateMethod(this,_SmoothScrollElement_instances,destroyTweened_fn).call(this),scrollKeys.has(e.code)&&this.stop())},"#keydownListener"));__privateAdd(this,_scrollListener2,__name(()=>{Viewport.device.isMobile&&this.sync()},"#scrollListener"))}resize(){__privateGet(this,_value).min=0,__privateGet(this,_value).max=this.scrollHeight-this.offsetHeight}stop(){__privateGet(this,_value).unlistenAnimationFrame(),__privateSet(this,_needSync,!0)}sync(){const currentValue=this.scrollTop;(Viewport.device.isMobile||__privateGet(this,_needSync)||Math.abs(currentValue-__privateGet(this,_value).current)>100)&&(__privateSet(this,_needSync,!1),__privateGet(this,_value).set(currentValue,{equalize:!0}))}shiftPosition(value){this.resize(),this.sync(),__privateGet(this,_value).shift(value)}setPosition(value,options){this.resize(),this.sync(),__privateGet(this,_value).set(value,options)}connectedCallback(){window.addEventListener("resize",__privateGet(this,_resizeListener2)),this.addEventListener("keydown",__privateGet(this,_keydownListener)),document.documentElement.addEventListener("pointerdown",__privateGet(this,_pointerdownListener)),this.addEventListener("wheel",__privateGet(this,_wheelListener),{passive:!1}),this.addEventListener("scroll",__privateGet(this,_scrollListener2)),__privateGet(this,_value).set(this.scrollTop,{equalize:!0}),__privateGet(this,_value).subscribe(e=>{const roundedCurrent=Math.round(e.current);scrollEntries_index.scrollEntries.update(this,"y",e.current),roundedCurrent!==__privateGet(this,_currentRoundedValue)&&this.scroll({top:roundedCurrent,behavior:"instant"}),__privateSet(this,_currentRoundedValue,roundedCurrent)}),__privateGet(this,_cssDamping).observe(),__privateGet(this,_cssDisabled).observe(),__privateGet(this,_cssDamping).subscribe(e=>{__privateGet(this,_value).damping=e.current}),scrollEntries_index.scrollEntries.register(this),this.resize()}disconnectedCallback(){var _a;__privateGet(this,_value).close(),__privateGet(this,_cssDamping).close(),__privateGet(this,_cssDisabled).close(),(_a=__privateGet(this,_tweened))==null||_a.close(),scrollEntries_index.scrollEntries.unregister(this),window.removeEventListener("resize",__privateGet(this,_resizeListener2)),this.removeEventListener("keydown",__privateGet(this,_keydownListener)),document.documentElement.removeEventListener("pointerdown",__privateGet(this,_pointerdownListener)),this.removeEventListener("wheel",__privateGet(this,_wheelListener)),this.removeEventListener("scroll",__privateGet(this,_scrollListener2))}};_cssDisabled=new WeakMap,_cssDamping=new WeakMap,_value=new WeakMap,_currentRoundedValue=new WeakMap,_needSync=new WeakMap,_tweened=new WeakMap,_SmoothScrollElement_instances=new WeakSet,checkDisabled_fn=__name(function(){return __privateGet(this,_cssDisabled).current||getComputedStyle(this).getPropertyValue("overflow")==="hidden"},"#checkDisabled"),destroyTweened_fn=__name(function(){var _a;(_a=__privateGet(this,_tweened))==null||_a.close(),__privateSet(this,_tweened,void 0)},"#destroyTweened"),_wheelListener=new WeakMap,_pointerdownListener=new WeakMap,_resizeListener2=new WeakMap,_keydownListener=new WeakMap,_scrollListener2=new WeakMap,__name(_SmoothScrollElement,"SmoothScrollElement");let SmoothScrollElement=_SmoothScrollElement;customElements.get("e-smooth-scroll")||customElements.define("e-smooth-scroll",SmoothScrollElement);var _statusHolderElement,_progressHolderElement,_scrollElement2,_statusHolderCSSProperty,_progressHolderCSSProperty,_disabledCSSProperty,_startOffsetCSSProperty,_startOffsetMinCSSProperty,_startExtraOffsetCSSProperty,_distanceCSSProperty,_distanceOffsetCSSProperty,_progressVarCSSProperty,_enterOnceCSSProperty,_status,_initialPosition,_start,_finish,_distance,_scrolled,_progress,_visible,_ScrollRegionElement_instances,addGlobalClasses_fn,removeGlobalClasses_fn,init_fn,_resizeListener3,_tickListener2,enter_fn,exit_fn,cssVar_fn,_readyStateChangeListener;const _ScrollRegionElement=class _ScrollRegionElement extends HTMLElement{constructor(){super(...arguments);__privateAdd(this,_ScrollRegionElement_instances);__privateAdd(this,_statusHolderElement,this);__privateAdd(this,_progressHolderElement,this);__privateAdd(this,_scrollElement2,null);__privateAdd(this,_statusHolderCSSProperty,new cssProperty_index.CSSProperty(this,"--scroll-region-status-holder",!1));__privateAdd(this,_progressHolderCSSProperty,new cssProperty_index.CSSProperty(this,"--scroll-region-progress-holder",!1));__privateAdd(this,_disabledCSSProperty,new cssProperty_index.CSSProperty(this,"--scroll-region-disabled",!1));__privateAdd(this,_startOffsetCSSProperty,new cssProperty_index.CSSProperty(this,"--scroll-region-start-offset",0,{rawValueCheck:!1}));__privateAdd(this,_startOffsetMinCSSProperty,new cssProperty_index.CSSProperty(this,"--scroll-region-start-offset-min",!1,{rawValueCheck:!1}));__privateAdd(this,_startExtraOffsetCSSProperty,new cssProperty_index.CSSProperty(this,"--scroll-region-start-extra-offset",0,{rawValueCheck:!1}));__privateAdd(this,_distanceCSSProperty,new cssProperty_index.CSSProperty(this,"--scroll-region-distance",0,{rawValueCheck:!1}));__privateAdd(this,_distanceOffsetCSSProperty,new cssProperty_index.CSSProperty(this,"--scroll-region-distance-offset",0,{rawValueCheck:!1}));__privateAdd(this,_progressVarCSSProperty,new cssProperty_index.CSSProperty(this,"--scroll-region-progress-var",""));__privateAdd(this,_enterOnceCSSProperty,new cssProperty_index.CSSProperty(this,"--scroll-region-enter-once",!1));__privateAdd(this,_status,new elementLinkedStore_index.ElementLinkedStore(this,{enabled:!1,entered:!1,enteredOnLoad:!1,activated:!1}));__privateAdd(this,_initialPosition,0);__privateAdd(this,_start,0);__privateAdd(this,_finish,0);__privateAdd(this,_distance,0);__privateAdd(this,_scrolled,0);__privateAdd(this,_progress,0);__privateAdd(this,_visible,!1);__privateAdd(this,_resizeListener3,__name(()=>{this.resize()},"#resizeListener"));__privateAdd(this,_tickListener2,__name(()=>{this.tick()},"#tickListener"));__privateAdd(this,_readyStateChangeListener,__name(()=>{document.readyState==="complete"&&__privateMethod(this,_ScrollRegionElement_instances,init_fn).call(this)},"#readyStateChangeListener"))}get start(){return __privateGet(this,_start)}get finish(){return __privateGet(this,_finish)}get distance(){return __privateGet(this,_distance)}get scrolled(){return __privateGet(this,_scrolled)}get progress(){return __privateGet(this,_progress)}get status(){return __privateGet(this,_status)}get scrollValue(){return __privateGet(this,_scrollElement2)instanceof HTMLElement?__privateGet(this,_scrollElement2).scrollTop:__privateGet(this,_scrollElement2).scrollY}resize(){__privateGet(this,_disabledCSSProperty).current||(__privateSet(this,_initialPosition,layout.getCumulativeOffsetTop(this)),__privateSet(this,_start,__privateGet(this,_initialPosition)),typeof __privateGet(this,_startOffsetMinCSSProperty).current=="number"?__privateSet(this,_start,__privateGet(this,_start)+Math.max(__privateGet(this,_startOffsetCSSProperty).current,__privateGet(this,_startOffsetMinCSSProperty).current)):__privateSet(this,_start,__privateGet(this,_start)+__privateGet(this,_startOffsetCSSProperty).current),__privateSet(this,_start,__privateGet(this,_start)+__privateGet(this,_startExtraOffsetCSSProperty).current),__privateSet(this,_start,__privateGet(this,_start)-layout.getStickyOffset(this,"top")),__privateSet(this,_finish,__privateGet(this,_start)),__privateGet(this,_distanceCSSProperty).current?__privateSet(this,_finish,__privateGet(this,_finish)+__privateGet(this,_distanceCSSProperty).current):__privateSet(this,_finish,__privateGet(this,_finish)+this.offsetHeight),__privateSet(this,_finish,__privateGet(this,_finish)+__privateGet(this,_distanceOffsetCSSProperty).current),__privateSet(this,_distance,__privateGet(this,_finish)-__privateGet(this,_start)),__privateSet(this,_visible,this.offsetWidth!==0&&this.offsetHeight!==0),this.tick())}tick(){if(__privateGet(this,_disabledCSSProperty).current)return;const scrollValue=this.scrollValue;__privateSet(this,_scrolled,math.clamp(scrollValue-__privateGet(this,_start),0,__privateGet(this,_distance))),__privateSet(this,_progress,__privateGet(this,_scrolled)/__privateGet(this,_distance)||0),__privateGet(this,_progressVarCSSProperty).current&&__privateGet(this,_progressHolderElement).style.setProperty(__privateMethod(this,_ScrollRegionElement_instances,cssVar_fn).call(this,__privateGet(this,_progressVarCSSProperty).current),__privateGet(this,_progress).toFixed(6)),__privateGet(this,_status).set("activated",scrollValue>=__privateGet(this,_start)),__privateGet(this,_visible)&&__privateGet(this,_status).isFalse("entered")&&scrollValue>=__privateGet(this,_start)&&scrollValue<=__privateGet(this,_finish)?__privateMethod(this,_ScrollRegionElement_instances,enter_fn).call(this):__privateGet(this,_visible)&&!__privateGet(this,_enterOnceCSSProperty).current&&__privateGet(this,_status).isTrue("entered")&&(scrollValue<__privateGet(this,_start)||scrollValue>__privateGet(this,_finish))&&__privateMethod(this,_ScrollRegionElement_instances,exit_fn).call(this),__privateGet(this,_enterOnceCSSProperty).current&&__privateGet(this,_progress)===1&&(__privateGet(this,_status).current.entered||__privateMethod(this,_ScrollRegionElement_instances,enter_fn).call(this),this.destroy()),events.dispatchEvent(this,"scrollRegionProgress",{detail:{progress:__privateGet(this,_progress),scrolled:__privateGet(this,_scrolled)}})}destroy(){document.removeEventListener("readystatechange",__privateGet(this,_readyStateChangeListener)),this.disable(!1),__privateGet(this,_statusHolderCSSProperty).close(),__privateGet(this,_progressHolderCSSProperty).close(),__privateGet(this,_disabledCSSProperty).close(),__privateGet(this,_startOffsetCSSProperty).close(),__privateGet(this,_startOffsetMinCSSProperty).close(),__privateGet(this,_startExtraOffsetCSSProperty).close(),__privateGet(this,_distanceCSSProperty).close(),__privateGet(this,_distanceOffsetCSSProperty).close(),__privateGet(this,_progressVarCSSProperty).close(),__privateGet(this,_enterOnceCSSProperty).close()}enable(){intersector_index.ticker.subscribe(__privateGet(this,_tickListener2),{culling:this}),elementResizer_index.elementResizer.subscribe(this,__privateGet(this,_resizeListener3)),windowResizer_index.windowResizer.subscribe(__privateGet(this,_resizeListener3)),__privateGet(this,_tickListener2).call(this),__privateGet(this,_status).set("enabled",!0)}disable(resetStatus=!0){intersector_index.ticker.unsubscribe(__privateGet(this,_tickListener2)),elementResizer_index.elementResizer.unsubscribe(__privateGet(this,_resizeListener3)),windowResizer_index.windowResizer.unsubscribe(__privateGet(this,_resizeListener3)),resetStatus&&__privateGet(this,_status).reset(),__privateMethod(this,_ScrollRegionElement_instances,removeGlobalClasses_fn).call(this)}connectedCallback(){const scrollSelector=this.getAttribute("data-scroll")||".page-scroll";__privateSet(this,_scrollElement2,document.querySelector(scrollSelector)),document.readyState==="complete"?__privateGet(this,_readyStateChangeListener).call(this):document.addEventListener("readystatechange",__privateGet(this,_readyStateChangeListener))}disconnectedCallback(){this.destroy()}};_statusHolderElement=new WeakMap,_progressHolderElement=new WeakMap,_scrollElement2=new WeakMap,_statusHolderCSSProperty=new WeakMap,_progressHolderCSSProperty=new WeakMap,_disabledCSSProperty=new WeakMap,_startOffsetCSSProperty=new WeakMap,_startOffsetMinCSSProperty=new WeakMap,_startExtraOffsetCSSProperty=new WeakMap,_distanceCSSProperty=new WeakMap,_distanceOffsetCSSProperty=new WeakMap,_progressVarCSSProperty=new WeakMap,_enterOnceCSSProperty=new WeakMap,_status=new WeakMap,_initialPosition=new WeakMap,_start=new WeakMap,_finish=new WeakMap,_distance=new WeakMap,_scrolled=new WeakMap,_progress=new WeakMap,_visible=new WeakMap,_ScrollRegionElement_instances=new WeakSet,addGlobalClasses_fn=__name(function(){this.hasAttribute("data-global-class")&&document.documentElement.classList.add(this.getAttribute("data-global-class"))},"#addGlobalClasses"),removeGlobalClasses_fn=__name(function(){this.hasAttribute("data-global-class")&&document.documentElement.classList.remove(this.getAttribute("data-global-class"))},"#removeGlobalClasses"),init_fn=__name(function(){__privateGet(this,_statusHolderCSSProperty).subscribe(e=>{__privateGet(this,_statusHolderElement)&&__privateGet(this,_status).removeElement(__privateGet(this,_statusHolderElement)),__privateSet(this,_statusHolderElement,e.current?document.querySelector(e.current)||this:this),__privateGet(this,_status).addElement(__privateGet(this,_statusHolderElement))}),__privateGet(this,_progressHolderCSSProperty).subscribe(e=>{__privateGet(this,_progressHolderElement)&&__privateGet(this,_progressHolderElement).style.removeProperty(__privateMethod(this,_ScrollRegionElement_instances,cssVar_fn).call(this,__privateGet(this,_progressVarCSSProperty).current)),__privateSet(this,_progressHolderElement,e.current?document.querySelector(e.current)||this:this)}),__privateGet(this,_disabledCSSProperty).subscribe(e=>{e.current&&!e.previous?this.disable():this.enable()}),__privateGet(this,_progressVarCSSProperty).subscribe(e=>{e.current?__privateGet(this,_tickListener2).call(this):e.previous&&__privateGet(this,_progressHolderElement).style.removeProperty(__privateMethod(this,_ScrollRegionElement_instances,cssVar_fn).call(this,e.previous))}),__privateGet(this,_distanceCSSProperty).subscribe(()=>{__privateGet(this,_resizeListener3).call(this)}),__privateGet(this,_statusHolderCSSProperty).observe(),__privateGet(this,_progressHolderCSSProperty).observe(),__privateGet(this,_disabledCSSProperty).observe(),__privateGet(this,_startOffsetCSSProperty).observe(),__privateGet(this,_startOffsetMinCSSProperty).observe(),__privateGet(this,_startExtraOffsetCSSProperty).observe(),__privateGet(this,_distanceCSSProperty).observe(),__privateGet(this,_distanceOffsetCSSProperty).observe(),__privateGet(this,_progressVarCSSProperty).observe(),__privateGet(this,_enterOnceCSSProperty).observe()},"#init"),_resizeListener3=new WeakMap,_tickListener2=new WeakMap,enter_fn=__name(function(){const scrollValue=this.scrollValue;__privateGet(this,_status).set("entered",!0),scrollValue===0&&__privateGet(this,_status).set("enteredOnLoad",!0),__privateMethod(this,_ScrollRegionElement_instances,addGlobalClasses_fn).call(this),events.dispatchEvent(this,"scrollRegionEnter")},"#enter"),exit_fn=__name(function(){__privateGet(this,_status).set("entered",!1),__privateMethod(this,_ScrollRegionElement_instances,removeGlobalClasses_fn).call(this),events.dispatchEvent(this,"scrollRegionExit")},"#exit"),cssVar_fn=__name(function(value){return`--${value}`},"#cssVar"),_readyStateChangeListener=new WeakMap,__name(_ScrollRegionElement,"ScrollRegionElement");let ScrollRegionElement=_ScrollRegionElement;customElements.get("e-scroll-region")||customElements.define("e-scroll-region",ScrollRegionElement);exports.ScrollRegionElement=ScrollRegionElement;exports.ScrollbarElement=ScrollbarElement;exports.SmoothScrollElement=SmoothScrollElement;
|
|
1
|
+
"use strict";var __defProp=Object.defineProperty;var __typeError=msg=>{throw TypeError(msg)};var __name=(target,value)=>__defProp(target,"name",{value,configurable:!0});var __accessCheck=(obj,member,msg)=>member.has(obj)||__typeError("Cannot "+msg);var __privateGet=(obj,member,getter)=>(__accessCheck(obj,member,"read from private field"),getter?getter.call(obj):member.get(obj)),__privateAdd=(obj,member,value)=>member.has(obj)?__typeError("Cannot add the same private member more than once"):member instanceof WeakSet?member.add(obj):member.set(obj,value),__privateSet=(obj,member,value,setter)=>(__accessCheck(obj,member,"write to private field"),setter?setter.call(obj,value):member.set(obj,value),value),__privateMethod=(obj,member,method)=>(__accessCheck(obj,member,"access private method"),method);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const intersector_index=require("../index-Cz5-98rw.cjs"),dom=require("../dom-B40i6NXw.cjs"),gestures=require("../gestures-DtYbQr49.cjs");require("construct-style-sheets-polyfill");const order_index=require("../order/index.cjs");require("../Store-BkYJHJp5.cjs");const scroll=require("../scroll-Dv9QcIKd.cjs"),Damped=require("../Damped-CYCcZu-z.cjs"),Tweened=require("../Tweened-BoGo9vz9.cjs"),cssProperty_index=require("../css-property/index.cjs"),Viewport=require("../Viewport-DwPeXyM2.cjs"),scrollEntries_index=require("../scroll-entries/index.cjs"),elementLinkedStore_index=require("../element-linked-store/index.cjs"),elementResizer_index=require("../element-resizer/index.cjs"),events=require("../events-UlGk63iC.cjs"),layout=require("../layout-CnGLl7oe.cjs"),math=require("../math-C-knY2TL.cjs"),windowResizer_index=require("../window-resizer/index.cjs");var _scrollElement,_thumbElement,_thumbScrollSize,_limit,_isHorizontal,_activeTimeoutId,_ScrollbarElement_instances,scrollPosition_get,scrollSize_get,scrollViewportSize_get,_scrollListener,_resizeListener,_grabListener,_tickListener,_intersectionListener;const _ScrollbarElement=class _ScrollbarElement extends HTMLElement{constructor(){super(...arguments);__privateAdd(this,_ScrollbarElement_instances);__privateAdd(this,_scrollElement,null);__privateAdd(this,_thumbElement,null);__privateAdd(this,_thumbScrollSize,0);__privateAdd(this,_limit,0);__privateAdd(this,_isHorizontal,!1);__privateAdd(this,_activeTimeoutId);__privateAdd(this,_scrollListener,__name(()=>{this.classList.add("active"),clearTimeout(__privateGet(this,_activeTimeoutId));const position=__privateGet(this,_ScrollbarElement_instances,scrollPosition_get)/__privateGet(this,_limit)*__privateGet(this,_thumbScrollSize);__privateGet(this,_isHorizontal)?__privateGet(this,_thumbElement).style.transform=`translate3d(${position}px, 0px, 0px)`:__privateGet(this,_thumbElement).style.transform=`translate3d(0px, ${position}px, 0px)`,__privateSet(this,_activeTimeoutId,setTimeout(()=>{this.classList.remove("active")},1e3))},"#scrollListener"));__privateAdd(this,_resizeListener,__name(()=>{const barSize=__privateGet(this,_isHorizontal)?this.offsetWidth:this.offsetHeight,scrollSize=__privateGet(this,_ScrollbarElement_instances,scrollSize_get),viewportSize=__privateGet(this,_ScrollbarElement_instances,scrollViewportSize_get);__privateSet(this,_limit,scrollSize-viewportSize);let thumbSize=barSize*barSize/(__privateGet(this,_limit)+barSize);thumbSize=Math.max(thumbSize,30),__privateGet(this,_isHorizontal)?(__privateGet(this,_thumbElement).style.width=thumbSize+"px",__privateGet(this,_thumbElement).style.height="100%"):(__privateGet(this,_thumbElement).style.width="100%",__privateGet(this,_thumbElement).style.height=thumbSize+"px"),__privateSet(this,_thumbScrollSize,barSize-thumbSize),scrollSize<=viewportSize?this.style.display="none":this.style.display="block"},"#resizeListener"));__privateAdd(this,_grabListener,__name(grabEvent=>{const startValue=__privateGet(this,_ScrollbarElement_instances,scrollPosition_get),grabCursor=__privateGet(this,_isHorizontal)?grabEvent.x:grabEvent.y;gestures.setupDrag(moveEvent=>{const mult=__privateGet(this,_limit)/__privateGet(this,_thumbScrollSize),delta=(__privateGet(this,_isHorizontal)?moveEvent.x-grabCursor:moveEvent.y-grabCursor)*mult;__privateGet(this,_isHorizontal)?__privateGet(this,_scrollElement).scroll({left:startValue+delta,behavior:"instant"}):__privateGet(this,_scrollElement).scroll({top:startValue+delta,behavior:"instant"})})},"#grabListener"));__privateAdd(this,_tickListener,__name(()=>{__privateGet(this,_resizeListener).call(this)},"#tickListener"));__privateAdd(this,_intersectionListener,__name(e=>{e.isIntersecting?(intersector_index.ticker.subscribe(__privateGet(this,_tickListener),{maxFPS:5}),__privateGet(this,_tickListener).call(this)):intersector_index.ticker.unsubscribe(__privateGet(this,_tickListener))},"#intersectionListener"))}connectedCallback(){const scrollSelector=this.getAttribute("data-scroll");let scrollElement=null;scrollSelector&&(scrollSelector==="parent"?scrollElement=this.parentElement:scrollElement=document.querySelector(scrollSelector)),scrollElement||(scrollElement=dom.findScrollParentElement(this),scrollElement===document.body&&(scrollElement=window)),__privateSet(this,_isHorizontal,this.hasAttribute("horisontal"));const thumbElement=this.querySelector("[data-thumb]");scrollElement&&thumbElement&&(__privateSet(this,_scrollElement,scrollElement),__privateSet(this,_thumbElement,thumbElement),__privateGet(this,_scrollElement).addEventListener("scroll",__privateGet(this,_scrollListener)),__privateGet(this,_thumbElement).addEventListener("pointerdown",__privateGet(this,_grabListener)),intersector_index.intersector.subscribe(this.parentElement===document.body?this:this.parentElement,__privateGet(this,_intersectionListener)))}disconnectedCallback(){var _a,_b;(_a=__privateGet(this,_scrollElement))==null||_a.removeEventListener("scroll",__privateGet(this,_scrollListener)),(_b=__privateGet(this,_thumbElement))==null||_b.removeEventListener("pointerdown",__privateGet(this,_grabListener)),clearTimeout(__privateGet(this,_activeTimeoutId)),intersector_index.intersector.unsubscribe(__privateGet(this,_intersectionListener)),intersector_index.ticker.unsubscribe(__privateGet(this,_tickListener))}};_scrollElement=new WeakMap,_thumbElement=new WeakMap,_thumbScrollSize=new WeakMap,_limit=new WeakMap,_isHorizontal=new WeakMap,_activeTimeoutId=new WeakMap,_ScrollbarElement_instances=new WeakSet,scrollPosition_get=__name(function(){return __privateGet(this,_scrollElement)instanceof HTMLElement?__privateGet(this,_isHorizontal)?__privateGet(this,_scrollElement).scrollLeft:__privateGet(this,_scrollElement).scrollTop:__privateGet(this,_isHorizontal)?__privateGet(this,_scrollElement).scrollX:__privateGet(this,_scrollElement).scrollY},"#scrollPosition"),scrollSize_get=__name(function(){return __privateGet(this,_scrollElement)instanceof HTMLElement?__privateGet(this,_isHorizontal)?__privateGet(this,_scrollElement).scrollWidth:__privateGet(this,_scrollElement).scrollHeight:__privateGet(this,_isHorizontal)?Math.max(document.body.scrollWidth,document.documentElement.scrollWidth,document.body.offsetWidth,document.documentElement.offsetWidth,document.body.clientWidth,document.documentElement.clientWidth):Math.max(document.body.scrollHeight,document.documentElement.scrollHeight,document.body.offsetHeight,document.documentElement.offsetHeight,document.body.clientHeight,document.documentElement.clientHeight)},"#scrollSize"),scrollViewportSize_get=__name(function(){return __privateGet(this,_scrollElement)instanceof HTMLElement?__privateGet(this,_isHorizontal)?__privateGet(this,_scrollElement).offsetWidth:__privateGet(this,_scrollElement).offsetHeight:__privateGet(this,_isHorizontal)?innerWidth:innerHeight},"#scrollViewportSize"),_scrollListener=new WeakMap,_resizeListener=new WeakMap,_grabListener=new WeakMap,_tickListener=new WeakMap,_intersectionListener=new WeakMap,__name(_ScrollbarElement,"ScrollbarElement");let ScrollbarElement=_ScrollbarElement;intersector_index.isBrowser&&!customElements.get("e-scrollbar")&&customElements.define("e-scrollbar",ScrollbarElement);const scrollKeys=new Set(["ArrowUp","ArrowDown","ArrowLeft","ArrowRight","PageUp","PageDown","Home","End","Space"]);var _cssDisabled,_cssDamping,_value,_currentRoundedValue,_needSync,_tweened,_SmoothScrollElement_instances,checkDisabled_fn,destroyTweened_fn,_wheelListener,_pointerdownListener,_resizeListener2,_keydownListener,_scrollListener2;const _SmoothScrollElement=class _SmoothScrollElement extends HTMLElement{constructor(){super(...arguments);__privateAdd(this,_SmoothScrollElement_instances);__privateAdd(this,_cssDisabled,new cssProperty_index.CSSProperty(this,"--smooth-scroll-disabled",!1));__privateAdd(this,_cssDamping,new cssProperty_index.CSSProperty(this,"--smooth-scroll-damping",10));__privateAdd(this,_value,new Damped.Damped(0));__privateAdd(this,_currentRoundedValue,0);__privateAdd(this,_needSync,!1);__privateAdd(this,_tweened);__privateAdd(this,_wheelListener,__name(e=>{if(!(__privateMethod(this,_SmoothScrollElement_instances,checkDisabled_fn).call(this)||Viewport.device.isMobile)){if(__privateMethod(this,_SmoothScrollElement_instances,destroyTweened_fn).call(this),Math.sign(e.deltaY)<0&&__privateGet(this,_value).target===0&&__privateGet(this,_value).direction<0||Math.sign(e.deltaY)>0&&__privateGet(this,_value).target===__privateGet(this,_value).max&&__privateGet(this,_value).direction>0||e.stopPropagation(),e.target instanceof Element){const preventElement=e.target.closest("[data-prevent-smooth-scroll]");if(preventElement){const attrValue=preventElement.getAttribute("data-prevent-smooth-scroll");if(attrValue){if(matchMedia(attrValue).matches)return}else return}}Math.abs(e.deltaX)>Math.abs(e.deltaY)||(e.preventDefault(),this.shiftPosition(e.deltaY))}},"#wheelListener"));__privateAdd(this,_pointerdownListener,__name(e=>{if(!(e.button!==0||__privateMethod(this,_SmoothScrollElement_instances,checkDisabled_fn).call(this))&&e.target instanceof Element){const anchorElement=e.target.closest("a");if(anchorElement){this.stop();const url=new URL(anchorElement.href);url.hash&&(e.preventDefault(),scroll.scrollToElement(url.hash,{behavior:anchorElement.getAttribute("data-behavior")||"smooth",center:anchorElement.hasAttribute("data-center"),offset:anchorElement.getAttribute("data-offset")||void 0,scrollElement:this,scrollCallback:__name((top,behaviour)=>{const duration=parseFloat(anchorElement.getAttribute("data-duration")||"0"),easing=anchorElement.getAttribute("data-easing");duration?(__privateGet(this,_tweened)&&__privateGet(this,_tweened).close(),__privateSet(this,_tweened,new Tweened.Tweened(__privateGet(this,_value).current,{duration,easing,order:order_index.TICK_ORDER.SCROLL})),__privateGet(this,_tweened).subscribe(e2=>{this.setPosition(e2.current,{equalize:!0})}),__privateGet(this,_tweened).set(top,{duration,easing})):this.setPosition(top,{equalize:behaviour==="instant"})},"scrollCallback")}))}}},"#pointerdownListener"));__privateAdd(this,_resizeListener2,__name(()=>{this.resize(),this.sync()},"#resizeListener"));__privateAdd(this,_keydownListener,__name(e=>{__privateMethod(this,_SmoothScrollElement_instances,checkDisabled_fn).call(this)||(__privateMethod(this,_SmoothScrollElement_instances,destroyTweened_fn).call(this),scrollKeys.has(e.code)&&this.stop())},"#keydownListener"));__privateAdd(this,_scrollListener2,__name(()=>{Viewport.device.isMobile&&this.sync()},"#scrollListener"))}resize(){__privateGet(this,_value).min=0,__privateGet(this,_value).max=this.scrollHeight-this.offsetHeight}stop(){__privateGet(this,_value).unlistenAnimationFrame(),__privateSet(this,_needSync,!0)}sync(){const currentValue=this.scrollTop;(Viewport.device.isMobile||__privateGet(this,_needSync)||Math.abs(currentValue-__privateGet(this,_value).current)>100)&&(__privateSet(this,_needSync,!1),__privateGet(this,_value).set(currentValue,{equalize:!0}))}shiftPosition(value){this.resize(),this.sync(),__privateGet(this,_value).shift(value)}setPosition(value,options){this.resize(),this.sync(),__privateGet(this,_value).set(value,options)}connectedCallback(){window.addEventListener("resize",__privateGet(this,_resizeListener2)),this.addEventListener("keydown",__privateGet(this,_keydownListener)),document.documentElement.addEventListener("pointerdown",__privateGet(this,_pointerdownListener)),this.addEventListener("wheel",__privateGet(this,_wheelListener),{passive:!1}),this.addEventListener("scroll",__privateGet(this,_scrollListener2)),__privateGet(this,_value).set(this.scrollTop,{equalize:!0}),__privateGet(this,_value).subscribe(e=>{var _a;const roundedCurrent=Math.round(e.current);scrollEntries_index.scrollEntries.update(this,"y",e.current),roundedCurrent!==__privateGet(this,_currentRoundedValue)&&(!Viewport.device.isMobile||(_a=__privateGet(this,_tweened))!=null&&_a.isRunning.current)&&this.scroll({top:roundedCurrent,behavior:"instant"}),__privateSet(this,_currentRoundedValue,roundedCurrent)}),__privateGet(this,_cssDamping).observe(),__privateGet(this,_cssDisabled).observe(),__privateGet(this,_cssDamping).subscribe(e=>{__privateGet(this,_value).damping=e.current}),scrollEntries_index.scrollEntries.register(this),this.resize()}disconnectedCallback(){var _a;__privateGet(this,_value).close(),__privateGet(this,_cssDamping).close(),__privateGet(this,_cssDisabled).close(),(_a=__privateGet(this,_tweened))==null||_a.close(),scrollEntries_index.scrollEntries.unregister(this),window.removeEventListener("resize",__privateGet(this,_resizeListener2)),this.removeEventListener("keydown",__privateGet(this,_keydownListener)),document.documentElement.removeEventListener("pointerdown",__privateGet(this,_pointerdownListener)),this.removeEventListener("wheel",__privateGet(this,_wheelListener)),this.removeEventListener("scroll",__privateGet(this,_scrollListener2))}};_cssDisabled=new WeakMap,_cssDamping=new WeakMap,_value=new WeakMap,_currentRoundedValue=new WeakMap,_needSync=new WeakMap,_tweened=new WeakMap,_SmoothScrollElement_instances=new WeakSet,checkDisabled_fn=__name(function(){return __privateGet(this,_cssDisabled).current||getComputedStyle(this).getPropertyValue("overflow")==="hidden"},"#checkDisabled"),destroyTweened_fn=__name(function(){var _a;(_a=__privateGet(this,_tweened))==null||_a.close(),__privateSet(this,_tweened,void 0)},"#destroyTweened"),_wheelListener=new WeakMap,_pointerdownListener=new WeakMap,_resizeListener2=new WeakMap,_keydownListener=new WeakMap,_scrollListener2=new WeakMap,__name(_SmoothScrollElement,"SmoothScrollElement");let SmoothScrollElement=_SmoothScrollElement;customElements.get("e-smooth-scroll")||customElements.define("e-smooth-scroll",SmoothScrollElement);var _statusHolderElement,_progressHolderElement,_scrollElement2,_statusHolderCSSProperty,_progressHolderCSSProperty,_disabledCSSProperty,_startOffsetCSSProperty,_startOffsetMinCSSProperty,_startExtraOffsetCSSProperty,_distanceCSSProperty,_distanceOffsetCSSProperty,_progressVarCSSProperty,_enterOnceCSSProperty,_status,_initialPosition,_start,_finish,_distance,_scrolled,_progress,_visible,_ScrollRegionElement_instances,addGlobalClasses_fn,removeGlobalClasses_fn,init_fn,_resizeListener3,_tickListener2,enter_fn,exit_fn,cssVar_fn,_readyStateChangeListener;const _ScrollRegionElement=class _ScrollRegionElement extends HTMLElement{constructor(){super(...arguments);__privateAdd(this,_ScrollRegionElement_instances);__privateAdd(this,_statusHolderElement,this);__privateAdd(this,_progressHolderElement,this);__privateAdd(this,_scrollElement2,null);__privateAdd(this,_statusHolderCSSProperty,new cssProperty_index.CSSProperty(this,"--scroll-region-status-holder",!1));__privateAdd(this,_progressHolderCSSProperty,new cssProperty_index.CSSProperty(this,"--scroll-region-progress-holder",!1));__privateAdd(this,_disabledCSSProperty,new cssProperty_index.CSSProperty(this,"--scroll-region-disabled",!1));__privateAdd(this,_startOffsetCSSProperty,new cssProperty_index.CSSProperty(this,"--scroll-region-start-offset",0,{rawValueCheck:!1}));__privateAdd(this,_startOffsetMinCSSProperty,new cssProperty_index.CSSProperty(this,"--scroll-region-start-offset-min",!1,{rawValueCheck:!1}));__privateAdd(this,_startExtraOffsetCSSProperty,new cssProperty_index.CSSProperty(this,"--scroll-region-start-extra-offset",0,{rawValueCheck:!1}));__privateAdd(this,_distanceCSSProperty,new cssProperty_index.CSSProperty(this,"--scroll-region-distance",0,{rawValueCheck:!1}));__privateAdd(this,_distanceOffsetCSSProperty,new cssProperty_index.CSSProperty(this,"--scroll-region-distance-offset",0,{rawValueCheck:!1}));__privateAdd(this,_progressVarCSSProperty,new cssProperty_index.CSSProperty(this,"--scroll-region-progress-var",""));__privateAdd(this,_enterOnceCSSProperty,new cssProperty_index.CSSProperty(this,"--scroll-region-enter-once",!1));__privateAdd(this,_status,new elementLinkedStore_index.ElementLinkedStore(this,{enabled:!1,entered:!1,enteredOnLoad:!1,activated:!1}));__privateAdd(this,_initialPosition,0);__privateAdd(this,_start,0);__privateAdd(this,_finish,0);__privateAdd(this,_distance,0);__privateAdd(this,_scrolled,0);__privateAdd(this,_progress,0);__privateAdd(this,_visible,!1);__privateAdd(this,_resizeListener3,__name(()=>{this.resize()},"#resizeListener"));__privateAdd(this,_tickListener2,__name(()=>{this.tick()},"#tickListener"));__privateAdd(this,_readyStateChangeListener,__name(()=>{document.readyState==="complete"&&__privateMethod(this,_ScrollRegionElement_instances,init_fn).call(this)},"#readyStateChangeListener"))}get start(){return __privateGet(this,_start)}get finish(){return __privateGet(this,_finish)}get distance(){return __privateGet(this,_distance)}get scrolled(){return __privateGet(this,_scrolled)}get progress(){return __privateGet(this,_progress)}get status(){return __privateGet(this,_status)}get scrollValue(){return __privateGet(this,_scrollElement2)instanceof HTMLElement?__privateGet(this,_scrollElement2).scrollTop:__privateGet(this,_scrollElement2).scrollY}resize(){__privateGet(this,_disabledCSSProperty).current||(__privateSet(this,_initialPosition,layout.getCumulativeOffsetTop(this)),__privateSet(this,_start,__privateGet(this,_initialPosition)),typeof __privateGet(this,_startOffsetMinCSSProperty).current=="number"?__privateSet(this,_start,__privateGet(this,_start)+Math.max(__privateGet(this,_startOffsetCSSProperty).current,__privateGet(this,_startOffsetMinCSSProperty).current)):__privateSet(this,_start,__privateGet(this,_start)+__privateGet(this,_startOffsetCSSProperty).current),__privateSet(this,_start,__privateGet(this,_start)+__privateGet(this,_startExtraOffsetCSSProperty).current),__privateSet(this,_start,__privateGet(this,_start)-layout.getStickyOffset(this,"top")),__privateSet(this,_finish,__privateGet(this,_start)),__privateGet(this,_distanceCSSProperty).current?__privateSet(this,_finish,__privateGet(this,_finish)+__privateGet(this,_distanceCSSProperty).current):__privateSet(this,_finish,__privateGet(this,_finish)+this.offsetHeight),__privateSet(this,_finish,__privateGet(this,_finish)+__privateGet(this,_distanceOffsetCSSProperty).current),__privateSet(this,_distance,__privateGet(this,_finish)-__privateGet(this,_start)),__privateSet(this,_visible,this.offsetWidth!==0&&this.offsetHeight!==0),this.tick())}tick(){if(__privateGet(this,_disabledCSSProperty).current)return;const scrollValue=this.scrollValue;__privateSet(this,_scrolled,math.clamp(scrollValue-__privateGet(this,_start),0,__privateGet(this,_distance))),__privateSet(this,_progress,__privateGet(this,_scrolled)/__privateGet(this,_distance)||0),__privateGet(this,_progressVarCSSProperty).current&&__privateGet(this,_progressHolderElement).style.setProperty(__privateMethod(this,_ScrollRegionElement_instances,cssVar_fn).call(this,__privateGet(this,_progressVarCSSProperty).current),__privateGet(this,_progress).toFixed(6)),__privateGet(this,_status).set("activated",scrollValue>=__privateGet(this,_start)),__privateGet(this,_visible)&&__privateGet(this,_status).isFalse("entered")&&scrollValue>=__privateGet(this,_start)&&scrollValue<=__privateGet(this,_finish)?__privateMethod(this,_ScrollRegionElement_instances,enter_fn).call(this):__privateGet(this,_visible)&&!__privateGet(this,_enterOnceCSSProperty).current&&__privateGet(this,_status).isTrue("entered")&&(scrollValue<__privateGet(this,_start)||scrollValue>__privateGet(this,_finish))&&__privateMethod(this,_ScrollRegionElement_instances,exit_fn).call(this),__privateGet(this,_enterOnceCSSProperty).current&&__privateGet(this,_progress)===1&&(__privateGet(this,_status).current.entered||__privateMethod(this,_ScrollRegionElement_instances,enter_fn).call(this),this.destroy()),events.dispatchEvent(this,"scrollRegionProgress",{detail:{progress:__privateGet(this,_progress),scrolled:__privateGet(this,_scrolled)}})}destroy(){document.removeEventListener("readystatechange",__privateGet(this,_readyStateChangeListener)),this.disable(!1),__privateGet(this,_statusHolderCSSProperty).close(),__privateGet(this,_progressHolderCSSProperty).close(),__privateGet(this,_disabledCSSProperty).close(),__privateGet(this,_startOffsetCSSProperty).close(),__privateGet(this,_startOffsetMinCSSProperty).close(),__privateGet(this,_startExtraOffsetCSSProperty).close(),__privateGet(this,_distanceCSSProperty).close(),__privateGet(this,_distanceOffsetCSSProperty).close(),__privateGet(this,_progressVarCSSProperty).close(),__privateGet(this,_enterOnceCSSProperty).close()}enable(){intersector_index.ticker.subscribe(__privateGet(this,_tickListener2),{culling:this}),elementResizer_index.elementResizer.subscribe(this,__privateGet(this,_resizeListener3)),windowResizer_index.windowResizer.subscribe(__privateGet(this,_resizeListener3)),__privateGet(this,_tickListener2).call(this),__privateGet(this,_status).set("enabled",!0)}disable(resetStatus=!0){intersector_index.ticker.unsubscribe(__privateGet(this,_tickListener2)),elementResizer_index.elementResizer.unsubscribe(__privateGet(this,_resizeListener3)),windowResizer_index.windowResizer.unsubscribe(__privateGet(this,_resizeListener3)),resetStatus&&__privateGet(this,_status).reset(),__privateMethod(this,_ScrollRegionElement_instances,removeGlobalClasses_fn).call(this)}connectedCallback(){const scrollSelector=this.getAttribute("data-scroll")||".page-scroll";__privateSet(this,_scrollElement2,document.querySelector(scrollSelector)),document.readyState==="complete"?__privateGet(this,_readyStateChangeListener).call(this):document.addEventListener("readystatechange",__privateGet(this,_readyStateChangeListener))}disconnectedCallback(){this.destroy()}};_statusHolderElement=new WeakMap,_progressHolderElement=new WeakMap,_scrollElement2=new WeakMap,_statusHolderCSSProperty=new WeakMap,_progressHolderCSSProperty=new WeakMap,_disabledCSSProperty=new WeakMap,_startOffsetCSSProperty=new WeakMap,_startOffsetMinCSSProperty=new WeakMap,_startExtraOffsetCSSProperty=new WeakMap,_distanceCSSProperty=new WeakMap,_distanceOffsetCSSProperty=new WeakMap,_progressVarCSSProperty=new WeakMap,_enterOnceCSSProperty=new WeakMap,_status=new WeakMap,_initialPosition=new WeakMap,_start=new WeakMap,_finish=new WeakMap,_distance=new WeakMap,_scrolled=new WeakMap,_progress=new WeakMap,_visible=new WeakMap,_ScrollRegionElement_instances=new WeakSet,addGlobalClasses_fn=__name(function(){this.hasAttribute("data-global-class")&&document.documentElement.classList.add(this.getAttribute("data-global-class"))},"#addGlobalClasses"),removeGlobalClasses_fn=__name(function(){this.hasAttribute("data-global-class")&&document.documentElement.classList.remove(this.getAttribute("data-global-class"))},"#removeGlobalClasses"),init_fn=__name(function(){__privateGet(this,_statusHolderCSSProperty).subscribe(e=>{__privateGet(this,_statusHolderElement)&&__privateGet(this,_status).removeElement(__privateGet(this,_statusHolderElement)),__privateSet(this,_statusHolderElement,e.current?document.querySelector(e.current)||this:this),__privateGet(this,_status).addElement(__privateGet(this,_statusHolderElement))}),__privateGet(this,_progressHolderCSSProperty).subscribe(e=>{__privateGet(this,_progressHolderElement)&&__privateGet(this,_progressHolderElement).style.removeProperty(__privateMethod(this,_ScrollRegionElement_instances,cssVar_fn).call(this,__privateGet(this,_progressVarCSSProperty).current)),__privateSet(this,_progressHolderElement,e.current?document.querySelector(e.current)||this:this)}),__privateGet(this,_disabledCSSProperty).subscribe(e=>{e.current&&!e.previous?this.disable():this.enable()}),__privateGet(this,_progressVarCSSProperty).subscribe(e=>{e.current?__privateGet(this,_tickListener2).call(this):e.previous&&__privateGet(this,_progressHolderElement).style.removeProperty(__privateMethod(this,_ScrollRegionElement_instances,cssVar_fn).call(this,e.previous))}),__privateGet(this,_distanceCSSProperty).subscribe(()=>{__privateGet(this,_resizeListener3).call(this)}),__privateGet(this,_statusHolderCSSProperty).observe(),__privateGet(this,_progressHolderCSSProperty).observe(),__privateGet(this,_disabledCSSProperty).observe(),__privateGet(this,_startOffsetCSSProperty).observe(),__privateGet(this,_startOffsetMinCSSProperty).observe(),__privateGet(this,_startExtraOffsetCSSProperty).observe(),__privateGet(this,_distanceCSSProperty).observe(),__privateGet(this,_distanceOffsetCSSProperty).observe(),__privateGet(this,_progressVarCSSProperty).observe(),__privateGet(this,_enterOnceCSSProperty).observe()},"#init"),_resizeListener3=new WeakMap,_tickListener2=new WeakMap,enter_fn=__name(function(){const scrollValue=this.scrollValue;__privateGet(this,_status).set("entered",!0),scrollValue===0&&__privateGet(this,_status).set("enteredOnLoad",!0),__privateMethod(this,_ScrollRegionElement_instances,addGlobalClasses_fn).call(this),events.dispatchEvent(this,"scrollRegionEnter")},"#enter"),exit_fn=__name(function(){__privateGet(this,_status).set("entered",!1),__privateMethod(this,_ScrollRegionElement_instances,removeGlobalClasses_fn).call(this),events.dispatchEvent(this,"scrollRegionExit")},"#exit"),cssVar_fn=__name(function(value){return`--${value}`},"#cssVar"),_readyStateChangeListener=new WeakMap,__name(_ScrollRegionElement,"ScrollRegionElement");let ScrollRegionElement=_ScrollRegionElement;customElements.get("e-scroll-region")||customElements.define("e-scroll-region",ScrollRegionElement);exports.ScrollRegionElement=ScrollRegionElement;exports.ScrollbarElement=ScrollbarElement;exports.SmoothScrollElement=SmoothScrollElement;
|
package/lib/scroll-kit/index.js
CHANGED
|
@@ -145,7 +145,7 @@ const _SmoothScrollElement = class _SmoothScrollElement extends HTMLElement {
|
|
|
145
145
|
}
|
|
146
146
|
}, "#wheelListener"));
|
|
147
147
|
__privateAdd(this, _pointerdownListener, /* @__PURE__ */ __name((e) => {
|
|
148
|
-
if (!(e.button !== 0 || __privateMethod(this, _SmoothScrollElement_instances, checkDisabled_fn).call(this)
|
|
148
|
+
if (!(e.button !== 0 || __privateMethod(this, _SmoothScrollElement_instances, checkDisabled_fn).call(this)) && e.target instanceof Element) {
|
|
149
149
|
const anchorElement = e.target.closest("a");
|
|
150
150
|
if (anchorElement) {
|
|
151
151
|
this.stop();
|
|
@@ -208,8 +208,9 @@ const _SmoothScrollElement = class _SmoothScrollElement extends HTMLElement {
|
|
|
208
208
|
), this.addEventListener("wheel", __privateGet(this, _wheelListener), {
|
|
209
209
|
passive: !1
|
|
210
210
|
}), this.addEventListener("scroll", __privateGet(this, _scrollListener2)), __privateGet(this, _value).set(this.scrollTop, { equalize: !0 }), __privateGet(this, _value).subscribe((e) => {
|
|
211
|
+
var _a;
|
|
211
212
|
const roundedCurrent = Math.round(e.current);
|
|
212
|
-
scrollEntries.update(this, "y", e.current), roundedCurrent !== __privateGet(this, _currentRoundedValue) && this.scroll({
|
|
213
|
+
scrollEntries.update(this, "y", e.current), roundedCurrent !== __privateGet(this, _currentRoundedValue) && (!device.isMobile || (_a = __privateGet(this, _tweened)) != null && _a.isRunning.current) && this.scroll({
|
|
213
214
|
top: roundedCurrent,
|
|
214
215
|
behavior: "instant"
|
|
215
216
|
}), __privateSet(this, _currentRoundedValue, roundedCurrent);
|