@studiometa/js-toolkit
Version:
A set of useful little bits of JavaScript to boost your project! 🚀
35 lines (34 loc) • 819 B
JavaScript
import { useDrag } from "../services/index.js";
function withDrag(BaseClass, { target = (instance) => instance.$el, ...options } = {}) {
class WithDrag extends BaseClass {
/**
* Config.
*/
static config = {
...BaseClass.config,
emits: ["dragged"]
};
/**
* Class constructor.
*/
constructor(element) {
super(element);
this.$on("mounted", () => {
this.$services.register(
"dragged",
useDrag.bind(void 0, target.call(this, this), options)
);
this.$services.enable("dragged");
});
this.$on("destroyed", () => {
this.$services.disable("dragged");
this.$services.unregister("dragged");
});
}
}
return WithDrag;
}
export {
withDrag
};
//# sourceMappingURL=withDrag.js.map