Skip to content

Commit

Permalink
fix: type definition (#39)
Browse files Browse the repository at this point in the history
  • Loading branch information
huynamboz authored Aug 8, 2024
1 parent 6575e33 commit 4bab046
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 32 deletions.
2 changes: 1 addition & 1 deletion dist/declarations/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { App, DirectiveBinding } from 'vue';
import type { App, DirectiveBinding } from 'vue';
interface ICustomBinding extends DirectiveBinding {
value: {
startScroll?: (e: MouseEvent) => void;
Expand Down
53 changes: 28 additions & 25 deletions dist/vue-drag-scroller.es.js
Original file line number Diff line number Diff line change
@@ -1,42 +1,45 @@
const g = "drag-scroller-disable", w = /* @__PURE__ */ (() => {
const s = /* @__PURE__ */ new WeakMap();
const D = "drag-scroller-disable", w = /* @__PURE__ */ (() => {
const n = /* @__PURE__ */ new WeakMap();
return {
mounted(r, l) {
mounted(r, a) {
let o = !1;
const { onlyX: n, onlyY: i, disablechild: E } = l.modifiers, e = l.value ?? {}, p = new Event("scrollStart", { bubbles: !0 }), b = new Event("scrollMoving", { bubbles: !0 }), D = new Event("scrollEnd", { bubbles: !0 });
e.hideScrollbar === !0 && (r.style.overflow = "hidden");
const L = (t) => {
const { onlyX: l, onlyY: c, disablechild: E } = a.modifiers, t = a.value ?? {}, p = new Event("scrollStart", { bubbles: !0 }), L = new Event("scrollMoving", { bubbles: !0 }), b = new Event("scrollEnd", { bubbles: !0 });
t.hideScrollbar === !0 && (r.style.overflow = "hidden");
const g = (e) => {
if (E)
return t === r;
for (; t && t.parentNode; ) {
if (t && (t != null && t.hasAttribute(g)))
return e === r;
for (; e && e.parentNode; ) {
if (e && (e != null && e.hasAttribute(D)))
return !1;
if (t === r)
if (e === r)
return !0;
t = t.parentNode;
e = e.parentNode;
}
return !1;
}, c = (t) => {
o = L(t.target), r.dispatchEvent(p), o && (e != null && e.startScroll) && typeof (e == null ? void 0 : e.startScroll) == "function" && e.startScroll(t);
}, f = (t) => {
r.dispatchEvent(D), o && (e != null && e.endScroll) && typeof (e == null ? void 0 : e.endScroll) == "function" && e.endScroll(t), o = !1;
}, u = (t) => {
var S;
}, d = (e) => {
o = g(e.target), r.dispatchEvent(p), o && (t != null && t.startScroll) && typeof (t == null ? void 0 : t.startScroll) == "function" && t.startScroll(e);
}, u = (e) => {
r.dispatchEvent(b), o && (t != null && t.endScroll) && typeof (t == null ? void 0 : t.endScroll) == "function" && t.endScroll(e), o = !1;
}, v = (e) => {
if (!o) return !1;
r.dispatchEvent(b), e != null && e.onScrolling && typeof (e == null ? void 0 : e.onScrolling) == "function" && e.onScrolling(t), t.stopPropagation && t.stopPropagation(), t.preventDefault && t.preventDefault(), (S = window.getSelection()) == null || S.removeAllRanges(), t.cancelBubble = !0, t.returnValue = !1;
const a = (e == null ? void 0 : e.speed) || 1, d = e.reverseDirection ? t.movementX * a : -t.movementX * a, v = e.reverseDirection ? t.movementY * a : -t.movementY * a;
n ? r.scrollLeft += d : (i || (r.scrollLeft += d), r.scrollTop += v);
r.dispatchEvent(L), t != null && t.onScrolling && typeof (t == null ? void 0 : t.onScrolling) == "function" && t.onScrolling(e);
const s = (t == null ? void 0 : t.speed) || 1, i = t.reverseDirection ? e.movementX * s : -e.movementX * s, S = t.reverseDirection ? e.movementY * s : -e.movementY * s;
return l ? r.scrollLeft += i : (c || (r.scrollLeft += i), r.scrollTop += S), f(e), !1;
};
s.set(r, { dragStart: c, dragEnd: f, drag: u }), r.addEventListener("pointerdown", c), addEventListener("pointerup", f), addEventListener("pointermove", u);
function f(e) {
var s;
(e == null ? void 0 : e.target) instanceof HTMLImageElement && e.preventDefault && e.preventDefault(), (s = window.getSelection()) == null || s.removeAllRanges();
}
n.set(r, { dragStart: d, dragEnd: u, drag: v, preventSelection: f }), r.addEventListener("pointerdown", d), r.addEventListener("dragstart", f), addEventListener("pointerup", u), addEventListener("pointermove", v);
},
unmounted(r) {
const { dragStart: l, dragEnd: o, drag: n } = s.get(r);
r.removeEventListener("pointerdown", l), removeEventListener("pointerup", o), removeEventListener("pointermove", n);
const { dragStart: a, dragEnd: o, drag: l, preventSelection: c } = n.get(r);
r.removeEventListener("pointerdown", a), r.removeEventListener("dragstart", c), removeEventListener("pointerup", o), removeEventListener("pointermove", l);
}
};
})(), h = {
install(s) {
s.directive("drag-scroller", w);
install(n) {
n.directive("drag-scroller", w);
}
};
export {
Expand Down
2 changes: 1 addition & 1 deletion dist/vue-drag-scroller.umd.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion example/main.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import './assets/main.css'
import { createApp } from 'vue'
import VueDragScroller from "../src"
import VueDragScroller from "vue-drag-scroller"
import App from './App.vue'

const app = createApp(App)
Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
{
"name": "vue-drag-scroller",
"version": "1.8.4",
"version": "1.8.5",
"type": "module",
"license": "MIT",
"description": "A vue directive that helps you scroll in a more natural way.",
"module": "dist/vue-drag-scroller.es.js",
"main": "dist/vue-drag-scroller.js",
"types": "src/types.d.ts",
"types": "dist/declarations/index.d.ts",
"exports": {
".": {
"import": "./dist/vue-drag-scroller.es.js",
"require": "./dist/vue-drag-scroller.js",
"types": "./src/types.d.ts"
"types": "./dist/declarations/index.d.ts"
},
"./package.json": "./package.json",
"./dist/*": "./dist/*",
"./src/types.d.ts": "./src/types.d.ts"
"./dist/declarations/index.d.ts": "./dist/declarations/index.d.ts"
},
"scripts": {
"dev": "vite --mode app",
Expand Down

0 comments on commit 4bab046

Please sign in to comment.