@design.estate/dees-domtools 2.1.1 → 2.3.0
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_bundle/bundle.js +1077 -21
- package/dist_bundle/bundle.js.map +4 -4
- package/dist_ts/00_commitinfo_data.js +1 -1
- package/dist_ts/domtools.classes.domtools.d.ts +2 -1
- package/dist_ts/domtools.classes.domtools.js +2 -4
- package/dist_ts/domtools.classes.scroller.d.ts +49 -0
- package/dist_ts/domtools.classes.scroller.js +144 -1
- package/dist_ts/domtools.plugins.d.ts +2 -1
- package/dist_ts/domtools.plugins.js +3 -2
- package/package.json +8 -7
- package/ts/00_commitinfo_data.ts +1 -1
- package/ts/domtools.classes.domtools.ts +1 -3
- package/ts/domtools.classes.scroller.ts +172 -2
- package/ts/domtools.plugins.ts +2 -1
package/dist_bundle/bundle.js
CHANGED
|
@@ -1180,7 +1180,7 @@ var require_punycode = __commonJS({
|
|
|
1180
1180
|
if (freeGlobal.global === freeGlobal || freeGlobal.window === freeGlobal || freeGlobal.self === freeGlobal) {
|
|
1181
1181
|
root6 = freeGlobal;
|
|
1182
1182
|
}
|
|
1183
|
-
var punycode, maxInt = 2147483647, base = 36, tMin = 1, tMax = 26, skew = 38,
|
|
1183
|
+
var punycode, maxInt = 2147483647, base = 36, tMin = 1, tMax = 26, skew = 38, damp2 = 700, initialBias = 72, initialN = 128, delimiter = "-", regexPunycode = /^xn--/, regexNonASCII = /[^\x20-\x7E]/, regexSeparators = /[\x2E\u3002\uFF0E\uFF61]/g, errors = {
|
|
1184
1184
|
"overflow": "Overflow: input needs wider integers to process",
|
|
1185
1185
|
"not-basic": "Illegal input >= 0x80 (not a basic code point)",
|
|
1186
1186
|
"invalid-input": "Invalid input"
|
|
@@ -1255,7 +1255,7 @@ var require_punycode = __commonJS({
|
|
|
1255
1255
|
}
|
|
1256
1256
|
function adapt(delta, numPoints, firstTime) {
|
|
1257
1257
|
var k2 = 0;
|
|
1258
|
-
delta = firstTime ? floor(delta /
|
|
1258
|
+
delta = firstTime ? floor(delta / damp2) : delta >> 1;
|
|
1259
1259
|
delta += floor(delta / numPoints);
|
|
1260
1260
|
for (; delta > baseMinusTMin * tMax >> 1; k2 += base) {
|
|
1261
1261
|
delta = floor(delta / baseMinusTMin);
|
|
@@ -7898,12 +7898,12 @@ var require_dist_ts2 = __commonJS({
|
|
|
7898
7898
|
};
|
|
7899
7899
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7900
7900
|
exports.objectToYamlString = exports.yamlStringToObject = void 0;
|
|
7901
|
-
var
|
|
7901
|
+
var plugins2 = __importStar(require_smartyaml_plugins());
|
|
7902
7902
|
exports.yamlStringToObject = async (yamlStringArg, optionsArg = {}) => {
|
|
7903
|
-
return
|
|
7903
|
+
return plugins2.jsYaml.safeLoad(yamlStringArg);
|
|
7904
7904
|
};
|
|
7905
7905
|
exports.objectToYamlString = async (objectArg, optionsArg = {}) => {
|
|
7906
|
-
return
|
|
7906
|
+
return plugins2.jsYaml.safeDump(objectArg);
|
|
7907
7907
|
};
|
|
7908
7908
|
}
|
|
7909
7909
|
});
|
|
@@ -9175,7 +9175,7 @@ __export(dist_ts_exports2, {
|
|
|
9175
9175
|
delayForRandom: () => delayForRandom
|
|
9176
9176
|
});
|
|
9177
9177
|
|
|
9178
|
-
// node_modules/.pnpm/@push.rocks+smartpromise@4.
|
|
9178
|
+
// node_modules/.pnpm/@push.rocks+smartpromise@4.2.2/node_modules/@push.rocks/smartpromise/dist_ts/index.js
|
|
9179
9179
|
var dist_ts_exports = {};
|
|
9180
9180
|
__export(dist_ts_exports, {
|
|
9181
9181
|
CumulativeDeferred: () => CumulativeDeferred,
|
|
@@ -9191,7 +9191,7 @@ __export(dist_ts_exports, {
|
|
|
9191
9191
|
timeoutWrap: () => timeoutWrap
|
|
9192
9192
|
});
|
|
9193
9193
|
|
|
9194
|
-
// node_modules/.pnpm/@push.rocks+smartpromise@4.
|
|
9194
|
+
// node_modules/.pnpm/@push.rocks+smartpromise@4.2.2/node_modules/@push.rocks/smartpromise/dist_ts/smartpromise.classes.deferred.js
|
|
9195
9195
|
var Deferred = class {
|
|
9196
9196
|
claim() {
|
|
9197
9197
|
if (this.claimed) {
|
|
@@ -9228,7 +9228,7 @@ var defer = () => {
|
|
|
9228
9228
|
return new Deferred();
|
|
9229
9229
|
};
|
|
9230
9230
|
|
|
9231
|
-
// node_modules/.pnpm/@push.rocks+smartpromise@4.
|
|
9231
|
+
// node_modules/.pnpm/@push.rocks+smartpromise@4.2.2/node_modules/@push.rocks/smartpromise/dist_ts/smartpromise.classes.cumulativedeferred.js
|
|
9232
9232
|
var CumulativeDeferred = class {
|
|
9233
9233
|
constructor() {
|
|
9234
9234
|
this.accumulatedPromises = [];
|
|
@@ -9242,6 +9242,11 @@ var CumulativeDeferred = class {
|
|
|
9242
9242
|
this.deferred.resolve();
|
|
9243
9243
|
}, 0);
|
|
9244
9244
|
}
|
|
9245
|
+
subDefer() {
|
|
9246
|
+
const done = defer();
|
|
9247
|
+
this.addPromise(done.promise);
|
|
9248
|
+
return done;
|
|
9249
|
+
}
|
|
9245
9250
|
addPromise(promiseArg) {
|
|
9246
9251
|
this.accumulatedPromises.push(promiseArg);
|
|
9247
9252
|
}
|
|
@@ -9250,7 +9255,7 @@ var cumulativeDefer = () => {
|
|
|
9250
9255
|
return new CumulativeDeferred();
|
|
9251
9256
|
};
|
|
9252
9257
|
|
|
9253
|
-
// node_modules/.pnpm/@push.rocks+smartpromise@4.
|
|
9258
|
+
// node_modules/.pnpm/@push.rocks+smartpromise@4.2.2/node_modules/@push.rocks/smartpromise/dist_ts/index.js
|
|
9254
9259
|
var resolvedPromise = (value2) => {
|
|
9255
9260
|
return Promise.resolve(value2);
|
|
9256
9261
|
};
|
|
@@ -21035,8 +21040,8 @@ function wrap(value2) {
|
|
|
21035
21040
|
return newValue;
|
|
21036
21041
|
}
|
|
21037
21042
|
var unwrap = (value2) => reverseTransformCache.get(value2);
|
|
21038
|
-
function openDB(name,
|
|
21039
|
-
const request = indexedDB.open(name,
|
|
21043
|
+
function openDB(name, version3, { blocked, upgrade, blocking, terminated } = {}) {
|
|
21044
|
+
const request = indexedDB.open(name, version3);
|
|
21040
21045
|
const openPromise = wrap(request);
|
|
21041
21046
|
if (upgrade) {
|
|
21042
21047
|
request.addEventListener("upgradeneeded", (event) => {
|
|
@@ -24449,16 +24454,16 @@ var Processor = class _Processor extends CallableInstance {
|
|
|
24449
24454
|
namespace.settings = (0, import_extend.default)(true, namespace.settings, result.settings);
|
|
24450
24455
|
}
|
|
24451
24456
|
}
|
|
24452
|
-
function addList(
|
|
24457
|
+
function addList(plugins2) {
|
|
24453
24458
|
let index2 = -1;
|
|
24454
|
-
if (
|
|
24455
|
-
} else if (Array.isArray(
|
|
24456
|
-
while (++index2 <
|
|
24457
|
-
const thing =
|
|
24459
|
+
if (plugins2 === null || plugins2 === void 0) {
|
|
24460
|
+
} else if (Array.isArray(plugins2)) {
|
|
24461
|
+
while (++index2 < plugins2.length) {
|
|
24462
|
+
const thing = plugins2[index2];
|
|
24458
24463
|
add2(thing);
|
|
24459
24464
|
}
|
|
24460
24465
|
} else {
|
|
24461
|
-
throw new TypeError("Expected a list of plugins, not `" +
|
|
24466
|
+
throw new TypeError("Expected a list of plugins, not `" + plugins2 + "`");
|
|
24462
24467
|
}
|
|
24463
24468
|
}
|
|
24464
24469
|
function addPlugin(plugin, parameters2) {
|
|
@@ -39424,6 +39429,923 @@ var Stringmap2 = class {
|
|
|
39424
39429
|
}
|
|
39425
39430
|
};
|
|
39426
39431
|
|
|
39432
|
+
// node_modules/.pnpm/lenis@1.1.20/node_modules/lenis/dist/lenis.mjs
|
|
39433
|
+
var version2 = "1.1.20";
|
|
39434
|
+
function clamp2(min2, input, max2) {
|
|
39435
|
+
return Math.max(min2, Math.min(input, max2));
|
|
39436
|
+
}
|
|
39437
|
+
function lerp(x2, y4, t3) {
|
|
39438
|
+
return (1 - t3) * x2 + t3 * y4;
|
|
39439
|
+
}
|
|
39440
|
+
function damp(x2, y4, lambda, deltaTime) {
|
|
39441
|
+
return lerp(x2, y4, 1 - Math.exp(-lambda * deltaTime));
|
|
39442
|
+
}
|
|
39443
|
+
function modulo(n5, d4) {
|
|
39444
|
+
return (n5 % d4 + d4) % d4;
|
|
39445
|
+
}
|
|
39446
|
+
var Animate = class {
|
|
39447
|
+
isRunning = false;
|
|
39448
|
+
value = 0;
|
|
39449
|
+
from = 0;
|
|
39450
|
+
to = 0;
|
|
39451
|
+
currentTime = 0;
|
|
39452
|
+
// These are instanciated in the fromTo method
|
|
39453
|
+
lerp;
|
|
39454
|
+
duration;
|
|
39455
|
+
easing;
|
|
39456
|
+
onUpdate;
|
|
39457
|
+
/**
|
|
39458
|
+
* Advance the animation by the given delta time
|
|
39459
|
+
*
|
|
39460
|
+
* @param deltaTime - The time in seconds to advance the animation
|
|
39461
|
+
*/
|
|
39462
|
+
advance(deltaTime) {
|
|
39463
|
+
if (!this.isRunning) return;
|
|
39464
|
+
let completed = false;
|
|
39465
|
+
if (this.duration && this.easing) {
|
|
39466
|
+
this.currentTime += deltaTime;
|
|
39467
|
+
const linearProgress = clamp2(0, this.currentTime / this.duration, 1);
|
|
39468
|
+
completed = linearProgress >= 1;
|
|
39469
|
+
const easedProgress = completed ? 1 : this.easing(linearProgress);
|
|
39470
|
+
this.value = this.from + (this.to - this.from) * easedProgress;
|
|
39471
|
+
} else if (this.lerp) {
|
|
39472
|
+
this.value = damp(this.value, this.to, this.lerp * 60, deltaTime);
|
|
39473
|
+
if (Math.round(this.value) === this.to) {
|
|
39474
|
+
this.value = this.to;
|
|
39475
|
+
completed = true;
|
|
39476
|
+
}
|
|
39477
|
+
} else {
|
|
39478
|
+
this.value = this.to;
|
|
39479
|
+
completed = true;
|
|
39480
|
+
}
|
|
39481
|
+
if (completed) {
|
|
39482
|
+
this.stop();
|
|
39483
|
+
}
|
|
39484
|
+
this.onUpdate?.(this.value, completed);
|
|
39485
|
+
}
|
|
39486
|
+
/** Stop the animation */
|
|
39487
|
+
stop() {
|
|
39488
|
+
this.isRunning = false;
|
|
39489
|
+
}
|
|
39490
|
+
/**
|
|
39491
|
+
* Set up the animation from a starting value to an ending value
|
|
39492
|
+
* with optional parameters for lerping, duration, easing, and onUpdate callback
|
|
39493
|
+
*
|
|
39494
|
+
* @param from - The starting value
|
|
39495
|
+
* @param to - The ending value
|
|
39496
|
+
* @param options - Options for the animation
|
|
39497
|
+
*/
|
|
39498
|
+
fromTo(from2, to, { lerp: lerp2, duration, easing, onStart, onUpdate }) {
|
|
39499
|
+
this.from = this.value = from2;
|
|
39500
|
+
this.to = to;
|
|
39501
|
+
this.lerp = lerp2;
|
|
39502
|
+
this.duration = duration;
|
|
39503
|
+
this.easing = easing;
|
|
39504
|
+
this.currentTime = 0;
|
|
39505
|
+
this.isRunning = true;
|
|
39506
|
+
onStart?.();
|
|
39507
|
+
this.onUpdate = onUpdate;
|
|
39508
|
+
}
|
|
39509
|
+
};
|
|
39510
|
+
function debounce2(callback, delay) {
|
|
39511
|
+
let timer2;
|
|
39512
|
+
return function(...args) {
|
|
39513
|
+
let context2 = this;
|
|
39514
|
+
clearTimeout(timer2);
|
|
39515
|
+
timer2 = setTimeout(() => {
|
|
39516
|
+
timer2 = void 0;
|
|
39517
|
+
callback.apply(context2, args);
|
|
39518
|
+
}, delay);
|
|
39519
|
+
};
|
|
39520
|
+
}
|
|
39521
|
+
var Dimensions = class {
|
|
39522
|
+
constructor(wrapper, content3, { autoResize = true, debounce: debounceValue = 250 } = {}) {
|
|
39523
|
+
this.wrapper = wrapper;
|
|
39524
|
+
this.content = content3;
|
|
39525
|
+
if (autoResize) {
|
|
39526
|
+
this.debouncedResize = debounce2(this.resize, debounceValue);
|
|
39527
|
+
if (this.wrapper instanceof Window) {
|
|
39528
|
+
window.addEventListener("resize", this.debouncedResize, false);
|
|
39529
|
+
} else {
|
|
39530
|
+
this.wrapperResizeObserver = new ResizeObserver(this.debouncedResize);
|
|
39531
|
+
this.wrapperResizeObserver.observe(this.wrapper);
|
|
39532
|
+
}
|
|
39533
|
+
this.contentResizeObserver = new ResizeObserver(this.debouncedResize);
|
|
39534
|
+
this.contentResizeObserver.observe(this.content);
|
|
39535
|
+
}
|
|
39536
|
+
this.resize();
|
|
39537
|
+
}
|
|
39538
|
+
width = 0;
|
|
39539
|
+
height = 0;
|
|
39540
|
+
scrollHeight = 0;
|
|
39541
|
+
scrollWidth = 0;
|
|
39542
|
+
// These are instanciated in the constructor as they need information from the options
|
|
39543
|
+
debouncedResize;
|
|
39544
|
+
wrapperResizeObserver;
|
|
39545
|
+
contentResizeObserver;
|
|
39546
|
+
destroy() {
|
|
39547
|
+
this.wrapperResizeObserver?.disconnect();
|
|
39548
|
+
this.contentResizeObserver?.disconnect();
|
|
39549
|
+
if (this.wrapper === window && this.debouncedResize) {
|
|
39550
|
+
window.removeEventListener("resize", this.debouncedResize, false);
|
|
39551
|
+
}
|
|
39552
|
+
}
|
|
39553
|
+
resize = () => {
|
|
39554
|
+
this.onWrapperResize();
|
|
39555
|
+
this.onContentResize();
|
|
39556
|
+
};
|
|
39557
|
+
onWrapperResize = () => {
|
|
39558
|
+
if (this.wrapper instanceof Window) {
|
|
39559
|
+
this.width = window.innerWidth;
|
|
39560
|
+
this.height = window.innerHeight;
|
|
39561
|
+
} else {
|
|
39562
|
+
this.width = this.wrapper.clientWidth;
|
|
39563
|
+
this.height = this.wrapper.clientHeight;
|
|
39564
|
+
}
|
|
39565
|
+
};
|
|
39566
|
+
onContentResize = () => {
|
|
39567
|
+
if (this.wrapper instanceof Window) {
|
|
39568
|
+
this.scrollHeight = this.content.scrollHeight;
|
|
39569
|
+
this.scrollWidth = this.content.scrollWidth;
|
|
39570
|
+
} else {
|
|
39571
|
+
this.scrollHeight = this.wrapper.scrollHeight;
|
|
39572
|
+
this.scrollWidth = this.wrapper.scrollWidth;
|
|
39573
|
+
}
|
|
39574
|
+
};
|
|
39575
|
+
get limit() {
|
|
39576
|
+
return {
|
|
39577
|
+
x: this.scrollWidth - this.width,
|
|
39578
|
+
y: this.scrollHeight - this.height
|
|
39579
|
+
};
|
|
39580
|
+
}
|
|
39581
|
+
};
|
|
39582
|
+
var Emitter = class {
|
|
39583
|
+
events = {};
|
|
39584
|
+
/**
|
|
39585
|
+
* Emit an event with the given data
|
|
39586
|
+
* @param event Event name
|
|
39587
|
+
* @param args Data to pass to the event handlers
|
|
39588
|
+
*/
|
|
39589
|
+
emit(event, ...args) {
|
|
39590
|
+
let callbacks = this.events[event] || [];
|
|
39591
|
+
for (let i5 = 0, length = callbacks.length; i5 < length; i5++) {
|
|
39592
|
+
callbacks[i5]?.(...args);
|
|
39593
|
+
}
|
|
39594
|
+
}
|
|
39595
|
+
/**
|
|
39596
|
+
* Add a callback to the event
|
|
39597
|
+
* @param event Event name
|
|
39598
|
+
* @param cb Callback function
|
|
39599
|
+
* @returns Unsubscribe function
|
|
39600
|
+
*/
|
|
39601
|
+
on(event, cb) {
|
|
39602
|
+
this.events[event]?.push(cb) || (this.events[event] = [cb]);
|
|
39603
|
+
return () => {
|
|
39604
|
+
this.events[event] = this.events[event]?.filter((i5) => cb !== i5);
|
|
39605
|
+
};
|
|
39606
|
+
}
|
|
39607
|
+
/**
|
|
39608
|
+
* Remove a callback from the event
|
|
39609
|
+
* @param event Event name
|
|
39610
|
+
* @param callback Callback function
|
|
39611
|
+
*/
|
|
39612
|
+
off(event, callback) {
|
|
39613
|
+
this.events[event] = this.events[event]?.filter((i5) => callback !== i5);
|
|
39614
|
+
}
|
|
39615
|
+
/**
|
|
39616
|
+
* Remove all event listeners and clean up
|
|
39617
|
+
*/
|
|
39618
|
+
destroy() {
|
|
39619
|
+
this.events = {};
|
|
39620
|
+
}
|
|
39621
|
+
};
|
|
39622
|
+
var LINE_HEIGHT = 100 / 6;
|
|
39623
|
+
var listenerOptions = { passive: false };
|
|
39624
|
+
var VirtualScroll = class {
|
|
39625
|
+
constructor(element4, options = { wheelMultiplier: 1, touchMultiplier: 1 }) {
|
|
39626
|
+
this.element = element4;
|
|
39627
|
+
this.options = options;
|
|
39628
|
+
window.addEventListener("resize", this.onWindowResize, false);
|
|
39629
|
+
this.onWindowResize();
|
|
39630
|
+
this.element.addEventListener("wheel", this.onWheel, listenerOptions);
|
|
39631
|
+
this.element.addEventListener(
|
|
39632
|
+
"touchstart",
|
|
39633
|
+
this.onTouchStart,
|
|
39634
|
+
listenerOptions
|
|
39635
|
+
);
|
|
39636
|
+
this.element.addEventListener(
|
|
39637
|
+
"touchmove",
|
|
39638
|
+
this.onTouchMove,
|
|
39639
|
+
listenerOptions
|
|
39640
|
+
);
|
|
39641
|
+
this.element.addEventListener("touchend", this.onTouchEnd, listenerOptions);
|
|
39642
|
+
}
|
|
39643
|
+
touchStart = {
|
|
39644
|
+
x: 0,
|
|
39645
|
+
y: 0
|
|
39646
|
+
};
|
|
39647
|
+
lastDelta = {
|
|
39648
|
+
x: 0,
|
|
39649
|
+
y: 0
|
|
39650
|
+
};
|
|
39651
|
+
window = {
|
|
39652
|
+
width: 0,
|
|
39653
|
+
height: 0
|
|
39654
|
+
};
|
|
39655
|
+
emitter = new Emitter();
|
|
39656
|
+
/**
|
|
39657
|
+
* Add an event listener for the given event and callback
|
|
39658
|
+
*
|
|
39659
|
+
* @param event Event name
|
|
39660
|
+
* @param callback Callback function
|
|
39661
|
+
*/
|
|
39662
|
+
on(event, callback) {
|
|
39663
|
+
return this.emitter.on(event, callback);
|
|
39664
|
+
}
|
|
39665
|
+
/** Remove all event listeners and clean up */
|
|
39666
|
+
destroy() {
|
|
39667
|
+
this.emitter.destroy();
|
|
39668
|
+
window.removeEventListener("resize", this.onWindowResize, false);
|
|
39669
|
+
this.element.removeEventListener("wheel", this.onWheel, listenerOptions);
|
|
39670
|
+
this.element.removeEventListener(
|
|
39671
|
+
"touchstart",
|
|
39672
|
+
this.onTouchStart,
|
|
39673
|
+
listenerOptions
|
|
39674
|
+
);
|
|
39675
|
+
this.element.removeEventListener(
|
|
39676
|
+
"touchmove",
|
|
39677
|
+
this.onTouchMove,
|
|
39678
|
+
listenerOptions
|
|
39679
|
+
);
|
|
39680
|
+
this.element.removeEventListener(
|
|
39681
|
+
"touchend",
|
|
39682
|
+
this.onTouchEnd,
|
|
39683
|
+
listenerOptions
|
|
39684
|
+
);
|
|
39685
|
+
}
|
|
39686
|
+
/**
|
|
39687
|
+
* Event handler for 'touchstart' event
|
|
39688
|
+
*
|
|
39689
|
+
* @param event Touch event
|
|
39690
|
+
*/
|
|
39691
|
+
onTouchStart = (event) => {
|
|
39692
|
+
const { clientX, clientY } = event.targetTouches ? event.targetTouches[0] : event;
|
|
39693
|
+
this.touchStart.x = clientX;
|
|
39694
|
+
this.touchStart.y = clientY;
|
|
39695
|
+
this.lastDelta = {
|
|
39696
|
+
x: 0,
|
|
39697
|
+
y: 0
|
|
39698
|
+
};
|
|
39699
|
+
this.emitter.emit("scroll", {
|
|
39700
|
+
deltaX: 0,
|
|
39701
|
+
deltaY: 0,
|
|
39702
|
+
event
|
|
39703
|
+
});
|
|
39704
|
+
};
|
|
39705
|
+
/** Event handler for 'touchmove' event */
|
|
39706
|
+
onTouchMove = (event) => {
|
|
39707
|
+
const { clientX, clientY } = event.targetTouches ? event.targetTouches[0] : event;
|
|
39708
|
+
const deltaX = -(clientX - this.touchStart.x) * this.options.touchMultiplier;
|
|
39709
|
+
const deltaY = -(clientY - this.touchStart.y) * this.options.touchMultiplier;
|
|
39710
|
+
this.touchStart.x = clientX;
|
|
39711
|
+
this.touchStart.y = clientY;
|
|
39712
|
+
this.lastDelta = {
|
|
39713
|
+
x: deltaX,
|
|
39714
|
+
y: deltaY
|
|
39715
|
+
};
|
|
39716
|
+
this.emitter.emit("scroll", {
|
|
39717
|
+
deltaX,
|
|
39718
|
+
deltaY,
|
|
39719
|
+
event
|
|
39720
|
+
});
|
|
39721
|
+
};
|
|
39722
|
+
onTouchEnd = (event) => {
|
|
39723
|
+
this.emitter.emit("scroll", {
|
|
39724
|
+
deltaX: this.lastDelta.x,
|
|
39725
|
+
deltaY: this.lastDelta.y,
|
|
39726
|
+
event
|
|
39727
|
+
});
|
|
39728
|
+
};
|
|
39729
|
+
/** Event handler for 'wheel' event */
|
|
39730
|
+
onWheel = (event) => {
|
|
39731
|
+
let { deltaX, deltaY, deltaMode } = event;
|
|
39732
|
+
const multiplierX = deltaMode === 1 ? LINE_HEIGHT : deltaMode === 2 ? this.window.width : 1;
|
|
39733
|
+
const multiplierY = deltaMode === 1 ? LINE_HEIGHT : deltaMode === 2 ? this.window.height : 1;
|
|
39734
|
+
deltaX *= multiplierX;
|
|
39735
|
+
deltaY *= multiplierY;
|
|
39736
|
+
deltaX *= this.options.wheelMultiplier;
|
|
39737
|
+
deltaY *= this.options.wheelMultiplier;
|
|
39738
|
+
this.emitter.emit("scroll", { deltaX, deltaY, event });
|
|
39739
|
+
};
|
|
39740
|
+
onWindowResize = () => {
|
|
39741
|
+
this.window = {
|
|
39742
|
+
width: window.innerWidth,
|
|
39743
|
+
height: window.innerHeight
|
|
39744
|
+
};
|
|
39745
|
+
};
|
|
39746
|
+
};
|
|
39747
|
+
var Lenis = class {
|
|
39748
|
+
_isScrolling = false;
|
|
39749
|
+
// true when scroll is animating
|
|
39750
|
+
_isStopped = false;
|
|
39751
|
+
// true if user should not be able to scroll - enable/disable programmatically
|
|
39752
|
+
_isLocked = false;
|
|
39753
|
+
// same as isStopped but enabled/disabled when scroll reaches target
|
|
39754
|
+
_preventNextNativeScrollEvent = false;
|
|
39755
|
+
_resetVelocityTimeout = null;
|
|
39756
|
+
__rafID = null;
|
|
39757
|
+
/**
|
|
39758
|
+
* Whether or not the user is touching the screen
|
|
39759
|
+
*/
|
|
39760
|
+
isTouching;
|
|
39761
|
+
/**
|
|
39762
|
+
* The time in ms since the lenis instance was created
|
|
39763
|
+
*/
|
|
39764
|
+
time = 0;
|
|
39765
|
+
/**
|
|
39766
|
+
* User data that will be forwarded through the scroll event
|
|
39767
|
+
*
|
|
39768
|
+
* @example
|
|
39769
|
+
* lenis.scrollTo(100, {
|
|
39770
|
+
* userData: {
|
|
39771
|
+
* foo: 'bar'
|
|
39772
|
+
* }
|
|
39773
|
+
* })
|
|
39774
|
+
*/
|
|
39775
|
+
userData = {};
|
|
39776
|
+
/**
|
|
39777
|
+
* The last velocity of the scroll
|
|
39778
|
+
*/
|
|
39779
|
+
lastVelocity = 0;
|
|
39780
|
+
/**
|
|
39781
|
+
* The current velocity of the scroll
|
|
39782
|
+
*/
|
|
39783
|
+
velocity = 0;
|
|
39784
|
+
/**
|
|
39785
|
+
* The direction of the scroll
|
|
39786
|
+
*/
|
|
39787
|
+
direction = 0;
|
|
39788
|
+
/**
|
|
39789
|
+
* The options passed to the lenis instance
|
|
39790
|
+
*/
|
|
39791
|
+
options;
|
|
39792
|
+
/**
|
|
39793
|
+
* The target scroll value
|
|
39794
|
+
*/
|
|
39795
|
+
targetScroll;
|
|
39796
|
+
/**
|
|
39797
|
+
* The animated scroll value
|
|
39798
|
+
*/
|
|
39799
|
+
animatedScroll;
|
|
39800
|
+
// These are instanciated here as they don't need information from the options
|
|
39801
|
+
animate = new Animate();
|
|
39802
|
+
emitter = new Emitter();
|
|
39803
|
+
// These are instanciated in the constructor as they need information from the options
|
|
39804
|
+
dimensions;
|
|
39805
|
+
// This is not private because it's used in the Snap class
|
|
39806
|
+
virtualScroll;
|
|
39807
|
+
constructor({
|
|
39808
|
+
wrapper = window,
|
|
39809
|
+
content: content3 = document.documentElement,
|
|
39810
|
+
eventsTarget = wrapper,
|
|
39811
|
+
smoothWheel = true,
|
|
39812
|
+
syncTouch = false,
|
|
39813
|
+
syncTouchLerp = 0.075,
|
|
39814
|
+
touchInertiaMultiplier = 35,
|
|
39815
|
+
duration,
|
|
39816
|
+
// in seconds
|
|
39817
|
+
easing = (t3) => Math.min(1, 1.001 - Math.pow(2, -10 * t3)),
|
|
39818
|
+
lerp: lerp2 = 0.1,
|
|
39819
|
+
infinite = false,
|
|
39820
|
+
orientation = "vertical",
|
|
39821
|
+
// vertical, horizontal
|
|
39822
|
+
gestureOrientation = "vertical",
|
|
39823
|
+
// vertical, horizontal, both
|
|
39824
|
+
touchMultiplier = 1,
|
|
39825
|
+
wheelMultiplier = 1,
|
|
39826
|
+
autoResize = true,
|
|
39827
|
+
prevent,
|
|
39828
|
+
virtualScroll,
|
|
39829
|
+
overscroll = true,
|
|
39830
|
+
autoRaf = false,
|
|
39831
|
+
anchors = false,
|
|
39832
|
+
__experimental__naiveDimensions = false
|
|
39833
|
+
} = {}) {
|
|
39834
|
+
window.lenisVersion = version2;
|
|
39835
|
+
if (!wrapper || wrapper === document.documentElement) {
|
|
39836
|
+
wrapper = window;
|
|
39837
|
+
}
|
|
39838
|
+
this.options = {
|
|
39839
|
+
wrapper,
|
|
39840
|
+
content: content3,
|
|
39841
|
+
eventsTarget,
|
|
39842
|
+
smoothWheel,
|
|
39843
|
+
syncTouch,
|
|
39844
|
+
syncTouchLerp,
|
|
39845
|
+
touchInertiaMultiplier,
|
|
39846
|
+
duration,
|
|
39847
|
+
easing,
|
|
39848
|
+
lerp: lerp2,
|
|
39849
|
+
infinite,
|
|
39850
|
+
gestureOrientation,
|
|
39851
|
+
orientation,
|
|
39852
|
+
touchMultiplier,
|
|
39853
|
+
wheelMultiplier,
|
|
39854
|
+
autoResize,
|
|
39855
|
+
prevent,
|
|
39856
|
+
virtualScroll,
|
|
39857
|
+
overscroll,
|
|
39858
|
+
autoRaf,
|
|
39859
|
+
anchors,
|
|
39860
|
+
__experimental__naiveDimensions
|
|
39861
|
+
};
|
|
39862
|
+
this.dimensions = new Dimensions(wrapper, content3, { autoResize });
|
|
39863
|
+
this.updateClassName();
|
|
39864
|
+
this.targetScroll = this.animatedScroll = this.actualScroll;
|
|
39865
|
+
this.options.wrapper.addEventListener("scroll", this.onNativeScroll, false);
|
|
39866
|
+
this.options.wrapper.addEventListener("scrollend", this.onScrollEnd, {
|
|
39867
|
+
capture: true
|
|
39868
|
+
});
|
|
39869
|
+
if (this.options.anchors && this.options.wrapper === window) {
|
|
39870
|
+
this.options.wrapper.addEventListener(
|
|
39871
|
+
"click",
|
|
39872
|
+
this.onClick,
|
|
39873
|
+
false
|
|
39874
|
+
);
|
|
39875
|
+
}
|
|
39876
|
+
this.options.wrapper.addEventListener(
|
|
39877
|
+
"pointerdown",
|
|
39878
|
+
this.onPointerDown,
|
|
39879
|
+
false
|
|
39880
|
+
);
|
|
39881
|
+
this.virtualScroll = new VirtualScroll(eventsTarget, {
|
|
39882
|
+
touchMultiplier,
|
|
39883
|
+
wheelMultiplier
|
|
39884
|
+
});
|
|
39885
|
+
this.virtualScroll.on("scroll", this.onVirtualScroll);
|
|
39886
|
+
if (this.options.autoRaf) {
|
|
39887
|
+
this.__rafID = requestAnimationFrame(this.raf);
|
|
39888
|
+
}
|
|
39889
|
+
}
|
|
39890
|
+
/**
|
|
39891
|
+
* Destroy the lenis instance, remove all event listeners and clean up the class name
|
|
39892
|
+
*/
|
|
39893
|
+
destroy() {
|
|
39894
|
+
this.emitter.destroy();
|
|
39895
|
+
this.options.wrapper.removeEventListener(
|
|
39896
|
+
"scroll",
|
|
39897
|
+
this.onNativeScroll,
|
|
39898
|
+
false
|
|
39899
|
+
);
|
|
39900
|
+
this.options.wrapper.removeEventListener("scrollend", this.onScrollEnd, {
|
|
39901
|
+
capture: true
|
|
39902
|
+
});
|
|
39903
|
+
this.options.wrapper.removeEventListener(
|
|
39904
|
+
"pointerdown",
|
|
39905
|
+
this.onPointerDown,
|
|
39906
|
+
false
|
|
39907
|
+
);
|
|
39908
|
+
if (this.options.anchors && this.options.wrapper === window) {
|
|
39909
|
+
this.options.wrapper.removeEventListener(
|
|
39910
|
+
"click",
|
|
39911
|
+
this.onClick,
|
|
39912
|
+
false
|
|
39913
|
+
);
|
|
39914
|
+
}
|
|
39915
|
+
this.virtualScroll.destroy();
|
|
39916
|
+
this.dimensions.destroy();
|
|
39917
|
+
this.cleanUpClassName();
|
|
39918
|
+
if (this.__rafID) {
|
|
39919
|
+
cancelAnimationFrame(this.__rafID);
|
|
39920
|
+
}
|
|
39921
|
+
}
|
|
39922
|
+
on(event, callback) {
|
|
39923
|
+
return this.emitter.on(event, callback);
|
|
39924
|
+
}
|
|
39925
|
+
off(event, callback) {
|
|
39926
|
+
return this.emitter.off(event, callback);
|
|
39927
|
+
}
|
|
39928
|
+
onScrollEnd = (e4) => {
|
|
39929
|
+
if (!(e4 instanceof CustomEvent)) {
|
|
39930
|
+
if (this.isScrolling === "smooth" || this.isScrolling === false) {
|
|
39931
|
+
e4.stopPropagation();
|
|
39932
|
+
}
|
|
39933
|
+
}
|
|
39934
|
+
};
|
|
39935
|
+
dispatchScrollendEvent = () => {
|
|
39936
|
+
this.options.wrapper.dispatchEvent(
|
|
39937
|
+
new CustomEvent("scrollend", {
|
|
39938
|
+
bubbles: this.options.wrapper === window,
|
|
39939
|
+
// cancelable: false,
|
|
39940
|
+
detail: {
|
|
39941
|
+
lenisScrollEnd: true
|
|
39942
|
+
}
|
|
39943
|
+
})
|
|
39944
|
+
);
|
|
39945
|
+
};
|
|
39946
|
+
setScroll(scroll) {
|
|
39947
|
+
if (this.isHorizontal) {
|
|
39948
|
+
this.options.wrapper.scrollTo({ left: scroll, behavior: "instant" });
|
|
39949
|
+
} else {
|
|
39950
|
+
this.options.wrapper.scrollTo({ top: scroll, behavior: "instant" });
|
|
39951
|
+
}
|
|
39952
|
+
}
|
|
39953
|
+
onClick = (event) => {
|
|
39954
|
+
const path3 = event.composedPath();
|
|
39955
|
+
const anchor = path3.find(
|
|
39956
|
+
(node2) => node2 instanceof HTMLAnchorElement && node2.getAttribute("href")?.startsWith("#")
|
|
39957
|
+
);
|
|
39958
|
+
if (anchor) {
|
|
39959
|
+
const id = anchor.getAttribute("href");
|
|
39960
|
+
if (id) {
|
|
39961
|
+
const options = typeof this.options.anchors === "object" && this.options.anchors ? this.options.anchors : void 0;
|
|
39962
|
+
this.scrollTo(id, options);
|
|
39963
|
+
}
|
|
39964
|
+
}
|
|
39965
|
+
};
|
|
39966
|
+
onPointerDown = (event) => {
|
|
39967
|
+
if (event.button === 1) {
|
|
39968
|
+
this.reset();
|
|
39969
|
+
}
|
|
39970
|
+
};
|
|
39971
|
+
onVirtualScroll = (data) => {
|
|
39972
|
+
if (typeof this.options.virtualScroll === "function" && this.options.virtualScroll(data) === false)
|
|
39973
|
+
return;
|
|
39974
|
+
const { deltaX, deltaY, event } = data;
|
|
39975
|
+
this.emitter.emit("virtual-scroll", { deltaX, deltaY, event });
|
|
39976
|
+
if (event.ctrlKey) return;
|
|
39977
|
+
if (event.lenisStopPropagation) return;
|
|
39978
|
+
const isTouch = event.type.includes("touch");
|
|
39979
|
+
const isWheel = event.type.includes("wheel");
|
|
39980
|
+
this.isTouching = event.type === "touchstart" || event.type === "touchmove";
|
|
39981
|
+
const isClickOrTap = deltaX === 0 && deltaY === 0;
|
|
39982
|
+
const isTapToStop = this.options.syncTouch && isTouch && event.type === "touchstart" && isClickOrTap && !this.isStopped && !this.isLocked;
|
|
39983
|
+
if (isTapToStop) {
|
|
39984
|
+
this.reset();
|
|
39985
|
+
return;
|
|
39986
|
+
}
|
|
39987
|
+
const isUnknownGesture = this.options.gestureOrientation === "vertical" && deltaY === 0 || this.options.gestureOrientation === "horizontal" && deltaX === 0;
|
|
39988
|
+
if (isClickOrTap || isUnknownGesture) {
|
|
39989
|
+
return;
|
|
39990
|
+
}
|
|
39991
|
+
let composedPath = event.composedPath();
|
|
39992
|
+
composedPath = composedPath.slice(0, composedPath.indexOf(this.rootElement));
|
|
39993
|
+
const prevent = this.options.prevent;
|
|
39994
|
+
if (!!composedPath.find(
|
|
39995
|
+
(node2) => node2 instanceof HTMLElement && (typeof prevent === "function" && prevent?.(node2) || node2.hasAttribute?.("data-lenis-prevent") || isTouch && node2.hasAttribute?.("data-lenis-prevent-touch") || isWheel && node2.hasAttribute?.("data-lenis-prevent-wheel"))
|
|
39996
|
+
))
|
|
39997
|
+
return;
|
|
39998
|
+
if (this.isStopped || this.isLocked) {
|
|
39999
|
+
event.preventDefault();
|
|
40000
|
+
return;
|
|
40001
|
+
}
|
|
40002
|
+
const isSmooth = this.options.syncTouch && isTouch || this.options.smoothWheel && isWheel;
|
|
40003
|
+
if (!isSmooth) {
|
|
40004
|
+
this.isScrolling = "native";
|
|
40005
|
+
this.animate.stop();
|
|
40006
|
+
event.lenisStopPropagation = true;
|
|
40007
|
+
return;
|
|
40008
|
+
}
|
|
40009
|
+
let delta = deltaY;
|
|
40010
|
+
if (this.options.gestureOrientation === "both") {
|
|
40011
|
+
delta = Math.abs(deltaY) > Math.abs(deltaX) ? deltaY : deltaX;
|
|
40012
|
+
} else if (this.options.gestureOrientation === "horizontal") {
|
|
40013
|
+
delta = deltaX;
|
|
40014
|
+
}
|
|
40015
|
+
if (!this.options.overscroll || this.options.infinite || this.options.wrapper !== window && (this.animatedScroll > 0 && this.animatedScroll < this.limit || this.animatedScroll === 0 && deltaY > 0 || this.animatedScroll === this.limit && deltaY < 0)) {
|
|
40016
|
+
event.lenisStopPropagation = true;
|
|
40017
|
+
}
|
|
40018
|
+
event.preventDefault();
|
|
40019
|
+
const isSyncTouch = isTouch && this.options.syncTouch;
|
|
40020
|
+
const isTouchEnd = isTouch && event.type === "touchend";
|
|
40021
|
+
const hasTouchInertia = isTouchEnd && Math.abs(delta) > 5;
|
|
40022
|
+
if (hasTouchInertia) {
|
|
40023
|
+
delta = this.velocity * this.options.touchInertiaMultiplier;
|
|
40024
|
+
}
|
|
40025
|
+
this.scrollTo(this.targetScroll + delta, {
|
|
40026
|
+
programmatic: false,
|
|
40027
|
+
...isSyncTouch ? {
|
|
40028
|
+
lerp: hasTouchInertia ? this.options.syncTouchLerp : 1
|
|
40029
|
+
// immediate: !hasTouchInertia,
|
|
40030
|
+
} : {
|
|
40031
|
+
lerp: this.options.lerp,
|
|
40032
|
+
duration: this.options.duration,
|
|
40033
|
+
easing: this.options.easing
|
|
40034
|
+
}
|
|
40035
|
+
});
|
|
40036
|
+
};
|
|
40037
|
+
/**
|
|
40038
|
+
* Force lenis to recalculate the dimensions
|
|
40039
|
+
*/
|
|
40040
|
+
resize() {
|
|
40041
|
+
this.dimensions.resize();
|
|
40042
|
+
this.animatedScroll = this.targetScroll = this.actualScroll;
|
|
40043
|
+
this.emit();
|
|
40044
|
+
}
|
|
40045
|
+
emit() {
|
|
40046
|
+
this.emitter.emit("scroll", this);
|
|
40047
|
+
}
|
|
40048
|
+
onNativeScroll = () => {
|
|
40049
|
+
if (this._resetVelocityTimeout !== null) {
|
|
40050
|
+
clearTimeout(this._resetVelocityTimeout);
|
|
40051
|
+
this._resetVelocityTimeout = null;
|
|
40052
|
+
}
|
|
40053
|
+
if (this._preventNextNativeScrollEvent) {
|
|
40054
|
+
this._preventNextNativeScrollEvent = false;
|
|
40055
|
+
return;
|
|
40056
|
+
}
|
|
40057
|
+
if (this.isScrolling === false || this.isScrolling === "native") {
|
|
40058
|
+
const lastScroll = this.animatedScroll;
|
|
40059
|
+
this.animatedScroll = this.targetScroll = this.actualScroll;
|
|
40060
|
+
this.lastVelocity = this.velocity;
|
|
40061
|
+
this.velocity = this.animatedScroll - lastScroll;
|
|
40062
|
+
this.direction = Math.sign(
|
|
40063
|
+
this.animatedScroll - lastScroll
|
|
40064
|
+
);
|
|
40065
|
+
if (!this.isStopped) {
|
|
40066
|
+
this.isScrolling = "native";
|
|
40067
|
+
}
|
|
40068
|
+
this.emit();
|
|
40069
|
+
if (this.velocity !== 0) {
|
|
40070
|
+
this._resetVelocityTimeout = setTimeout(() => {
|
|
40071
|
+
this.lastVelocity = this.velocity;
|
|
40072
|
+
this.velocity = 0;
|
|
40073
|
+
this.isScrolling = false;
|
|
40074
|
+
this.emit();
|
|
40075
|
+
}, 400);
|
|
40076
|
+
}
|
|
40077
|
+
}
|
|
40078
|
+
};
|
|
40079
|
+
reset() {
|
|
40080
|
+
this.isLocked = false;
|
|
40081
|
+
this.isScrolling = false;
|
|
40082
|
+
this.animatedScroll = this.targetScroll = this.actualScroll;
|
|
40083
|
+
this.lastVelocity = this.velocity = 0;
|
|
40084
|
+
this.animate.stop();
|
|
40085
|
+
}
|
|
40086
|
+
/**
|
|
40087
|
+
* Start lenis scroll after it has been stopped
|
|
40088
|
+
*/
|
|
40089
|
+
start() {
|
|
40090
|
+
if (!this.isStopped) return;
|
|
40091
|
+
this.reset();
|
|
40092
|
+
this.isStopped = false;
|
|
40093
|
+
}
|
|
40094
|
+
/**
|
|
40095
|
+
* Stop lenis scroll
|
|
40096
|
+
*/
|
|
40097
|
+
stop() {
|
|
40098
|
+
if (this.isStopped) return;
|
|
40099
|
+
this.reset();
|
|
40100
|
+
this.isStopped = true;
|
|
40101
|
+
}
|
|
40102
|
+
/**
|
|
40103
|
+
* RequestAnimationFrame for lenis
|
|
40104
|
+
*
|
|
40105
|
+
* @param time The time in ms from an external clock like `requestAnimationFrame` or Tempus
|
|
40106
|
+
*/
|
|
40107
|
+
raf = (time) => {
|
|
40108
|
+
const deltaTime = time - (this.time || time);
|
|
40109
|
+
this.time = time;
|
|
40110
|
+
this.animate.advance(deltaTime * 1e-3);
|
|
40111
|
+
if (this.options.autoRaf) {
|
|
40112
|
+
this.__rafID = requestAnimationFrame(this.raf);
|
|
40113
|
+
}
|
|
40114
|
+
};
|
|
40115
|
+
/**
|
|
40116
|
+
* Scroll to a target value
|
|
40117
|
+
*
|
|
40118
|
+
* @param target The target value to scroll to
|
|
40119
|
+
* @param options The options for the scroll
|
|
40120
|
+
*
|
|
40121
|
+
* @example
|
|
40122
|
+
* lenis.scrollTo(100, {
|
|
40123
|
+
* offset: 100,
|
|
40124
|
+
* duration: 1,
|
|
40125
|
+
* easing: (t) => 1 - Math.cos((t * Math.PI) / 2),
|
|
40126
|
+
* lerp: 0.1,
|
|
40127
|
+
* onStart: () => {
|
|
40128
|
+
* console.log('onStart')
|
|
40129
|
+
* },
|
|
40130
|
+
* onComplete: () => {
|
|
40131
|
+
* console.log('onComplete')
|
|
40132
|
+
* },
|
|
40133
|
+
* })
|
|
40134
|
+
*/
|
|
40135
|
+
scrollTo(target, {
|
|
40136
|
+
offset = 0,
|
|
40137
|
+
immediate = false,
|
|
40138
|
+
lock = false,
|
|
40139
|
+
duration = this.options.duration,
|
|
40140
|
+
easing = this.options.easing,
|
|
40141
|
+
lerp: lerp2 = this.options.lerp,
|
|
40142
|
+
onStart,
|
|
40143
|
+
onComplete,
|
|
40144
|
+
force = false,
|
|
40145
|
+
// scroll even if stopped
|
|
40146
|
+
programmatic = true,
|
|
40147
|
+
// called from outside of the class
|
|
40148
|
+
userData
|
|
40149
|
+
} = {}) {
|
|
40150
|
+
if ((this.isStopped || this.isLocked) && !force) return;
|
|
40151
|
+
if (typeof target === "string" && ["top", "left", "start"].includes(target)) {
|
|
40152
|
+
target = 0;
|
|
40153
|
+
} else if (typeof target === "string" && ["bottom", "right", "end"].includes(target)) {
|
|
40154
|
+
target = this.limit;
|
|
40155
|
+
} else {
|
|
40156
|
+
let node2;
|
|
40157
|
+
if (typeof target === "string") {
|
|
40158
|
+
node2 = document.querySelector(target);
|
|
40159
|
+
} else if (target instanceof HTMLElement && target?.nodeType) {
|
|
40160
|
+
node2 = target;
|
|
40161
|
+
}
|
|
40162
|
+
if (node2) {
|
|
40163
|
+
if (this.options.wrapper !== window) {
|
|
40164
|
+
const wrapperRect = this.rootElement.getBoundingClientRect();
|
|
40165
|
+
offset -= this.isHorizontal ? wrapperRect.left : wrapperRect.top;
|
|
40166
|
+
}
|
|
40167
|
+
const rect = node2.getBoundingClientRect();
|
|
40168
|
+
target = (this.isHorizontal ? rect.left : rect.top) + this.animatedScroll;
|
|
40169
|
+
}
|
|
40170
|
+
}
|
|
40171
|
+
if (typeof target !== "number") return;
|
|
40172
|
+
target += offset;
|
|
40173
|
+
target = Math.round(target);
|
|
40174
|
+
if (this.options.infinite) {
|
|
40175
|
+
if (programmatic) {
|
|
40176
|
+
this.targetScroll = this.animatedScroll = this.scroll;
|
|
40177
|
+
}
|
|
40178
|
+
} else {
|
|
40179
|
+
target = clamp2(0, target, this.limit);
|
|
40180
|
+
}
|
|
40181
|
+
if (target === this.targetScroll) {
|
|
40182
|
+
onStart?.(this);
|
|
40183
|
+
onComplete?.(this);
|
|
40184
|
+
return;
|
|
40185
|
+
}
|
|
40186
|
+
this.userData = userData ?? {};
|
|
40187
|
+
if (immediate) {
|
|
40188
|
+
this.animatedScroll = this.targetScroll = target;
|
|
40189
|
+
this.setScroll(this.scroll);
|
|
40190
|
+
this.reset();
|
|
40191
|
+
this.preventNextNativeScrollEvent();
|
|
40192
|
+
this.emit();
|
|
40193
|
+
onComplete?.(this);
|
|
40194
|
+
this.userData = {};
|
|
40195
|
+
requestAnimationFrame(() => {
|
|
40196
|
+
this.dispatchScrollendEvent();
|
|
40197
|
+
});
|
|
40198
|
+
return;
|
|
40199
|
+
}
|
|
40200
|
+
if (!programmatic) {
|
|
40201
|
+
this.targetScroll = target;
|
|
40202
|
+
}
|
|
40203
|
+
this.animate.fromTo(this.animatedScroll, target, {
|
|
40204
|
+
duration,
|
|
40205
|
+
easing,
|
|
40206
|
+
lerp: lerp2,
|
|
40207
|
+
onStart: () => {
|
|
40208
|
+
if (lock) this.isLocked = true;
|
|
40209
|
+
this.isScrolling = "smooth";
|
|
40210
|
+
onStart?.(this);
|
|
40211
|
+
},
|
|
40212
|
+
onUpdate: (value2, completed) => {
|
|
40213
|
+
this.isScrolling = "smooth";
|
|
40214
|
+
this.lastVelocity = this.velocity;
|
|
40215
|
+
this.velocity = value2 - this.animatedScroll;
|
|
40216
|
+
this.direction = Math.sign(this.velocity);
|
|
40217
|
+
this.animatedScroll = value2;
|
|
40218
|
+
this.setScroll(this.scroll);
|
|
40219
|
+
if (programmatic) {
|
|
40220
|
+
this.targetScroll = value2;
|
|
40221
|
+
}
|
|
40222
|
+
if (!completed) this.emit();
|
|
40223
|
+
if (completed) {
|
|
40224
|
+
this.reset();
|
|
40225
|
+
this.emit();
|
|
40226
|
+
onComplete?.(this);
|
|
40227
|
+
this.userData = {};
|
|
40228
|
+
requestAnimationFrame(() => {
|
|
40229
|
+
this.dispatchScrollendEvent();
|
|
40230
|
+
});
|
|
40231
|
+
this.preventNextNativeScrollEvent();
|
|
40232
|
+
}
|
|
40233
|
+
}
|
|
40234
|
+
});
|
|
40235
|
+
}
|
|
40236
|
+
preventNextNativeScrollEvent() {
|
|
40237
|
+
this._preventNextNativeScrollEvent = true;
|
|
40238
|
+
requestAnimationFrame(() => {
|
|
40239
|
+
this._preventNextNativeScrollEvent = false;
|
|
40240
|
+
});
|
|
40241
|
+
}
|
|
40242
|
+
/**
|
|
40243
|
+
* The root element on which lenis is instanced
|
|
40244
|
+
*/
|
|
40245
|
+
get rootElement() {
|
|
40246
|
+
return this.options.wrapper === window ? document.documentElement : this.options.wrapper;
|
|
40247
|
+
}
|
|
40248
|
+
/**
|
|
40249
|
+
* The limit which is the maximum scroll value
|
|
40250
|
+
*/
|
|
40251
|
+
get limit() {
|
|
40252
|
+
if (this.options.__experimental__naiveDimensions) {
|
|
40253
|
+
if (this.isHorizontal) {
|
|
40254
|
+
return this.rootElement.scrollWidth - this.rootElement.clientWidth;
|
|
40255
|
+
} else {
|
|
40256
|
+
return this.rootElement.scrollHeight - this.rootElement.clientHeight;
|
|
40257
|
+
}
|
|
40258
|
+
} else {
|
|
40259
|
+
return this.dimensions.limit[this.isHorizontal ? "x" : "y"];
|
|
40260
|
+
}
|
|
40261
|
+
}
|
|
40262
|
+
/**
|
|
40263
|
+
* Whether or not the scroll is horizontal
|
|
40264
|
+
*/
|
|
40265
|
+
get isHorizontal() {
|
|
40266
|
+
return this.options.orientation === "horizontal";
|
|
40267
|
+
}
|
|
40268
|
+
/**
|
|
40269
|
+
* The actual scroll value
|
|
40270
|
+
*/
|
|
40271
|
+
get actualScroll() {
|
|
40272
|
+
const wrapper = this.options.wrapper;
|
|
40273
|
+
return this.isHorizontal ? wrapper.scrollX ?? wrapper.scrollLeft : wrapper.scrollY ?? wrapper.scrollTop;
|
|
40274
|
+
}
|
|
40275
|
+
/**
|
|
40276
|
+
* The current scroll value
|
|
40277
|
+
*/
|
|
40278
|
+
get scroll() {
|
|
40279
|
+
return this.options.infinite ? modulo(this.animatedScroll, this.limit) : this.animatedScroll;
|
|
40280
|
+
}
|
|
40281
|
+
/**
|
|
40282
|
+
* The progress of the scroll relative to the limit
|
|
40283
|
+
*/
|
|
40284
|
+
get progress() {
|
|
40285
|
+
return this.limit === 0 ? 1 : this.scroll / this.limit;
|
|
40286
|
+
}
|
|
40287
|
+
/**
|
|
40288
|
+
* Current scroll state
|
|
40289
|
+
*/
|
|
40290
|
+
get isScrolling() {
|
|
40291
|
+
return this._isScrolling;
|
|
40292
|
+
}
|
|
40293
|
+
set isScrolling(value2) {
|
|
40294
|
+
if (this._isScrolling !== value2) {
|
|
40295
|
+
this._isScrolling = value2;
|
|
40296
|
+
this.updateClassName();
|
|
40297
|
+
}
|
|
40298
|
+
}
|
|
40299
|
+
/**
|
|
40300
|
+
* Check if lenis is stopped
|
|
40301
|
+
*/
|
|
40302
|
+
get isStopped() {
|
|
40303
|
+
return this._isStopped;
|
|
40304
|
+
}
|
|
40305
|
+
set isStopped(value2) {
|
|
40306
|
+
if (this._isStopped !== value2) {
|
|
40307
|
+
this._isStopped = value2;
|
|
40308
|
+
this.updateClassName();
|
|
40309
|
+
}
|
|
40310
|
+
}
|
|
40311
|
+
/**
|
|
40312
|
+
* Check if lenis is locked
|
|
40313
|
+
*/
|
|
40314
|
+
get isLocked() {
|
|
40315
|
+
return this._isLocked;
|
|
40316
|
+
}
|
|
40317
|
+
set isLocked(value2) {
|
|
40318
|
+
if (this._isLocked !== value2) {
|
|
40319
|
+
this._isLocked = value2;
|
|
40320
|
+
this.updateClassName();
|
|
40321
|
+
}
|
|
40322
|
+
}
|
|
40323
|
+
/**
|
|
40324
|
+
* Check if lenis is smooth scrolling
|
|
40325
|
+
*/
|
|
40326
|
+
get isSmooth() {
|
|
40327
|
+
return this.isScrolling === "smooth";
|
|
40328
|
+
}
|
|
40329
|
+
/**
|
|
40330
|
+
* The class name applied to the wrapper element
|
|
40331
|
+
*/
|
|
40332
|
+
get className() {
|
|
40333
|
+
let className = "lenis";
|
|
40334
|
+
if (this.isStopped) className += " lenis-stopped";
|
|
40335
|
+
if (this.isLocked) className += " lenis-locked";
|
|
40336
|
+
if (this.isScrolling) className += " lenis-scrolling";
|
|
40337
|
+
if (this.isScrolling === "smooth") className += " lenis-smooth";
|
|
40338
|
+
return className;
|
|
40339
|
+
}
|
|
40340
|
+
updateClassName() {
|
|
40341
|
+
this.cleanUpClassName();
|
|
40342
|
+
this.rootElement.className = `${this.rootElement.className} ${this.className}`.trim();
|
|
40343
|
+
}
|
|
40344
|
+
cleanUpClassName() {
|
|
40345
|
+
this.rootElement.className = this.rootElement.className.replace(/lenis(-\w+)?/g, "").trim();
|
|
40346
|
+
}
|
|
40347
|
+
};
|
|
40348
|
+
|
|
39427
40349
|
// ts/domtools.plugins.ts
|
|
39428
40350
|
var import_sweet_scroll = __toESM(require_sweet_scroll(), 1);
|
|
39429
40351
|
var lik = {
|
|
@@ -39432,6 +40354,143 @@ var lik = {
|
|
|
39432
40354
|
FastMap: FastMap2
|
|
39433
40355
|
};
|
|
39434
40356
|
|
|
40357
|
+
// ts/domtools.classes.scroller.ts
|
|
40358
|
+
var Scroller = class {
|
|
40359
|
+
constructor(domtoolsInstanceArg) {
|
|
40360
|
+
// Array to store scroll callback functions.
|
|
40361
|
+
this.scrollCallbacks = [];
|
|
40362
|
+
// Lenis instance (if activated) or null.
|
|
40363
|
+
this.lenisInstance = null;
|
|
40364
|
+
// Bound handlers to allow removal from event listeners.
|
|
40365
|
+
this.handleNativeScroll = (event) => {
|
|
40366
|
+
this.executeScrollCallbacks();
|
|
40367
|
+
};
|
|
40368
|
+
this.handleLenisScroll = (info) => {
|
|
40369
|
+
this.executeScrollCallbacks();
|
|
40370
|
+
};
|
|
40371
|
+
this.sweetScroller = new import_sweet_scroll.default({});
|
|
40372
|
+
this.domtoolsInstance = domtoolsInstanceArg;
|
|
40373
|
+
this.attachNativeScrollListener();
|
|
40374
|
+
}
|
|
40375
|
+
/**
|
|
40376
|
+
* Scrolls to a given element with options.
|
|
40377
|
+
*/
|
|
40378
|
+
async scrollToElement(elementArg, optionsArg) {
|
|
40379
|
+
this.sweetScroller.toElement(elementArg, optionsArg);
|
|
40380
|
+
await dist_ts_exports2.delayFor(optionsArg.duration);
|
|
40381
|
+
}
|
|
40382
|
+
/**
|
|
40383
|
+
* Detects whether native smooth scrolling is enabled.
|
|
40384
|
+
*/
|
|
40385
|
+
async detectNativeSmoothScroll() {
|
|
40386
|
+
const done = dist_ts_exports.defer();
|
|
40387
|
+
const sampleSize = 100;
|
|
40388
|
+
const acceptableDeltaDifference = 3;
|
|
40389
|
+
const minimumSmoothRatio = 0.75;
|
|
40390
|
+
const eventDeltas = [];
|
|
40391
|
+
function onWheel(event) {
|
|
40392
|
+
eventDeltas.push(event.deltaY);
|
|
40393
|
+
if (eventDeltas.length >= sampleSize) {
|
|
40394
|
+
window.removeEventListener("wheel", onWheel);
|
|
40395
|
+
analyzeEvents();
|
|
40396
|
+
}
|
|
40397
|
+
}
|
|
40398
|
+
function analyzeEvents() {
|
|
40399
|
+
const totalDiffs = eventDeltas.length - 1;
|
|
40400
|
+
let smallDiffCount = 0;
|
|
40401
|
+
for (let i5 = 0; i5 < totalDiffs; i5++) {
|
|
40402
|
+
const diff = Math.abs(eventDeltas[i5 + 1] - eventDeltas[i5]);
|
|
40403
|
+
if (diff <= acceptableDeltaDifference) {
|
|
40404
|
+
smallDiffCount++;
|
|
40405
|
+
}
|
|
40406
|
+
}
|
|
40407
|
+
const smoothRatio = smallDiffCount / totalDiffs;
|
|
40408
|
+
if (smoothRatio >= minimumSmoothRatio) {
|
|
40409
|
+
console.log("Smooth scrolling detected.");
|
|
40410
|
+
done.resolve(true);
|
|
40411
|
+
} else {
|
|
40412
|
+
console.log("Smooth scrolling NOT detected.");
|
|
40413
|
+
done.resolve(false);
|
|
40414
|
+
}
|
|
40415
|
+
}
|
|
40416
|
+
window.addEventListener("wheel", onWheel);
|
|
40417
|
+
return done.promise;
|
|
40418
|
+
}
|
|
40419
|
+
/**
|
|
40420
|
+
* Enables Lenis scrolling.
|
|
40421
|
+
* If optionsArg.disableOnNativeSmoothScroll is true and native smooth scrolling is detected,
|
|
40422
|
+
* Lenis will be destroyed immediately.
|
|
40423
|
+
*/
|
|
40424
|
+
async enableLenisScroll(optionsArg) {
|
|
40425
|
+
const lenis = new Lenis({
|
|
40426
|
+
autoRaf: true
|
|
40427
|
+
});
|
|
40428
|
+
if (optionsArg?.disableOnNativeSmoothScroll) {
|
|
40429
|
+
if (await this.detectNativeSmoothScroll()) {
|
|
40430
|
+
lenis.destroy();
|
|
40431
|
+
return;
|
|
40432
|
+
}
|
|
40433
|
+
}
|
|
40434
|
+
this.lenisInstance = lenis;
|
|
40435
|
+
this.detachNativeScrollListener();
|
|
40436
|
+
this.attachLenisScrollListener();
|
|
40437
|
+
const originalDestroy = lenis.destroy.bind(lenis);
|
|
40438
|
+
lenis.destroy = () => {
|
|
40439
|
+
originalDestroy();
|
|
40440
|
+
this.detachLenisScrollListener();
|
|
40441
|
+
this.attachNativeScrollListener();
|
|
40442
|
+
this.lenisInstance = null;
|
|
40443
|
+
};
|
|
40444
|
+
}
|
|
40445
|
+
/**
|
|
40446
|
+
* Registers a callback to be executed on scroll.
|
|
40447
|
+
* @param callback A function to execute on each scroll event.
|
|
40448
|
+
*/
|
|
40449
|
+
onScroll(callback) {
|
|
40450
|
+
this.scrollCallbacks.push(callback);
|
|
40451
|
+
}
|
|
40452
|
+
/**
|
|
40453
|
+
* Executes all registered scroll callbacks concurrently.
|
|
40454
|
+
*/
|
|
40455
|
+
executeScrollCallbacks() {
|
|
40456
|
+
this.scrollCallbacks.forEach((callback) => {
|
|
40457
|
+
try {
|
|
40458
|
+
callback();
|
|
40459
|
+
} catch (error) {
|
|
40460
|
+
console.error("Error in scroll callback:", error);
|
|
40461
|
+
}
|
|
40462
|
+
});
|
|
40463
|
+
}
|
|
40464
|
+
/**
|
|
40465
|
+
* Attaches the native scroll event listener.
|
|
40466
|
+
*/
|
|
40467
|
+
attachNativeScrollListener() {
|
|
40468
|
+
window.addEventListener("scroll", this.handleNativeScroll, { passive: true });
|
|
40469
|
+
}
|
|
40470
|
+
/**
|
|
40471
|
+
* Detaches the native scroll event listener.
|
|
40472
|
+
*/
|
|
40473
|
+
detachNativeScrollListener() {
|
|
40474
|
+
window.removeEventListener("scroll", this.handleNativeScroll);
|
|
40475
|
+
}
|
|
40476
|
+
/**
|
|
40477
|
+
* Attaches the Lenis scroll event listener.
|
|
40478
|
+
*/
|
|
40479
|
+
attachLenisScrollListener() {
|
|
40480
|
+
if (this.lenisInstance) {
|
|
40481
|
+
this.lenisInstance.on("scroll", this.handleLenisScroll);
|
|
40482
|
+
}
|
|
40483
|
+
}
|
|
40484
|
+
/**
|
|
40485
|
+
* Detaches the Lenis scroll event listener.
|
|
40486
|
+
*/
|
|
40487
|
+
detachLenisScrollListener() {
|
|
40488
|
+
if (this.lenisInstance) {
|
|
40489
|
+
this.lenisInstance.off("scroll", this.handleLenisScroll);
|
|
40490
|
+
}
|
|
40491
|
+
}
|
|
40492
|
+
};
|
|
40493
|
+
|
|
39435
40494
|
// ts/domtools.classes.thememanager.ts
|
|
39436
40495
|
var ThemeManager = class {
|
|
39437
40496
|
constructor(domtoolsRefArg) {
|
|
@@ -39698,10 +40757,7 @@ var DomTools2 = class _DomTools {
|
|
|
39698
40757
|
smarturl: dist_ts_exports22
|
|
39699
40758
|
};
|
|
39700
40759
|
this.deesComms = new dist_ts_exports16.DeesComms();
|
|
39701
|
-
this.scroller = new
|
|
39702
|
-
/* some options */
|
|
39703
|
-
});
|
|
39704
|
-
// TODO: switch to scroller class
|
|
40760
|
+
this.scroller = new Scroller(this);
|
|
39705
40761
|
this.themeManager = new ThemeManager(this);
|
|
39706
40762
|
this.keyboard = new Keyboard(document.body);
|
|
39707
40763
|
this.domToolsReady = dist_ts_exports.defer();
|