chore: complete update
This commit is contained in:
40
resources/js/modules/wheel-boost/index.js
Normal file
40
resources/js/modules/wheel-boost/index.js
Normal file
@@ -0,0 +1,40 @@
|
||||
// modules/wheel-boost/index.js
|
||||
import { registerFrameTask, unregisterFrameTask } from '../../core/frameloop.js';
|
||||
|
||||
/*
|
||||
let velocity = 0;
|
||||
let taskId = 'wheel-boost';
|
||||
let damping = 0.85;
|
||||
let boost = 1.2;
|
||||
let enabled = true;
|
||||
|
||||
export function init(config = {}) {
|
||||
damping = typeof config.damping === 'number' ? config.damping : 0.85;
|
||||
boost = typeof config.boost === 'number' ? config.boost : 1.2;
|
||||
enabled = config.enabled !== false;
|
||||
|
||||
if (!enabled) return;
|
||||
|
||||
window.addEventListener('wheel', onWheel, { passive: false });
|
||||
|
||||
registerFrameTask(taskId, () => {
|
||||
if (Math.abs(velocity) > 0.1) {
|
||||
window.scrollBy(0, velocity);
|
||||
velocity *= damping;
|
||||
} else {
|
||||
velocity = 0;
|
||||
}
|
||||
}, { autoStart: true });
|
||||
}
|
||||
|
||||
function onWheel(e) {
|
||||
velocity += e.deltaY * boost;
|
||||
e.preventDefault(); // verhindert das native Scrollen
|
||||
}
|
||||
|
||||
export function destroy() {
|
||||
window.removeEventListener('wheel', onWheel);
|
||||
unregisterFrameTask(taskId);
|
||||
velocity = 0;
|
||||
}
|
||||
*/
|
||||
Reference in New Issue
Block a user