Closed masterWeber closed 3 years ago
Does not give an error, the console is empty.
"dependencies": { "core-js": "^3.7.0", "vue": "^3.0.2", "vue-router": "^4.0.0-rc.2", "vuex": "^4.0.0-rc.1" },
Up up still many packages not supported in Vue 3 :disappointed:
Those who aren't interested in making their own Vue 3 dragscroll and would rather hack this one into Vue 3, here's how I adapted it to make it Vue 3 compliant:
Do not use main.js. Vue 3 changed how it registers directives, so this will not work until it is updated by the contributer/maintainer.
Vue 3 changed the directive hooks. In directive.js, change the export default to the following:
export default {
mounted: function (el, binding, vnode) {
init(el, binding, vnode)
},
updated: function (el, binding, vnode, oldVnode) {
// update the component only if the parameters change
if (JSON.stringify(binding.value) !== JSON.stringify(binding.oldValue)) {
init(el, binding, vnode)
}
},
unmounted: function (el, binding, vnode) {
const target = el
u.removeEventListeners(target, POINTER_START_EVENTS, target.md)
u.removeEventListeners(window, POINTER_END_EVENTS, target.mu)
u.removeEventListeners(window, POINTER_MOVE_EVENTS, target.mm)
}
}
In utils.js, change line 28:
vnode.el.dispatchEvent(event)
Then register your directive using the new convention.
import { dragscroll } from "vue-dragscroll";
const app = createApp({});
app.directive('dragscroll', dragscroll);
I'm only using dragscroll on html elements, not components, so there may be additional changes necessary to accomplish that.
@jameskirtland3 please make a PR
@donmbelembe Why is this ticket closed? It is still an issue an nobody created a PR it seems
I can confirm that @jameskirtland3's solution works perfectly
@ilearnio are you sure the latest version is not compatible with vue 3 ?
I installed the version from npm and it didn't work
actually the Demo(Doc) page is using vue 3 https://github.com/donmbelembe/vue-dragscroll/blob/02699f2b1753461c25d6b82a0b983b95848f4a5a/index.html#L661
@ilearnio
@donmbelembe The version I have installed using npm i -S vue-dragscroll
is 3.0.1
and it doesn't have Vue 3 support. You can see how I forked it over here https://github.com/ilearnio/vue-dragscroll/commit/e5e1f6b08edfa68defb32132f1d2a00e1b81fa97 in order to implement @jameskirtland3's solution on top of your latest master. Without that fix it wasn't seeing the directive. I am using vue-class-components
with Vue v3
src/directive.js is Vue 2 src/directive-next.js is Vue 3
you can do like import { dragscrollNext } from 'vue-dragscroll';
Thank you, for reporting this, I'll make vue 3 as the default this week end
@ilearnio
Oh, I see. Would be great, thanks!
Does not give an error, the console is empty.