UNPKG

mmjs-core

Version:
2 lines (1 loc) 506 B
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("vue");function c(l,s){const{initialValue:v=1,max:r=4,min:h=.5,step:u=.1,callback:n}=s??{},e=t.ref(v);function a(o){o.deltaY>0?e.value-=u:e.value+=u,e.value=Math.min(Math.max(e.value,h),r),n==null||n(o,e.value)}t.onMounted(()=>{l.value.addEventListener("wheel",a,{passive:!1})});function i(){l.value.removeEventListener("wheel",a)}return t.onScopeDispose(()=>{i()}),{wheel:e,removeEvent:i}}exports.useWheel=c;