-
Notifications
You must be signed in to change notification settings - Fork 60
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support for Vuejs / Nuxtjs #7
Comments
Tip: To make this library compatible with Vuejs or any other virtual DOM framework, you just need to expose an If you can do that, I can create a fork of it and create a Vuejs plugin. Interesting library! |
The second option would be to use a Here's the way I did it: ( If you know any better way then it would be great 👍🏻 )
|
hi @ayushsharma82 , thank you so much for your idea, let me try to find if there's another better way. If not, I will use your way, will let you know when it done so you can wrap it with Vue :) |
@ayushsharma82 that's perfect in my Nuxt app - thank you! I simply added it at the end of the |
Hey, I was wondering if provided code/patch -which is working great - could be improved performant-wise ? Even the library itself does not seem very reactive-friendly. None of the event listeners added (and they're a lot) are removed when navigating. Would love to know a way to tackle this issue in a reactive library in general... |
Fiddling with the code I found this to be quite useful as well if like me you use Page Transitions in Nuxt, I'm observing title attribute changes which in my case means URL Changes. const observeURLChanges = (function () {
const MutationObserver = window.MutationObserver || window.WebKitMutationObserver;
return function (obj, callback) {
if (!obj || obj.nodeType !== 1) {
return;
}
if (MutationObserver) {
// define a new observer
const mutationObserver = new MutationObserver(callback);
// Lets listen also for page changes
// have the observer observe foo for changes in children
mutationObserver.observe(obj, {
attributes: true,
childList: true,
subtree: true,
});
return mutationObserver;
} else if (window.addEventListener) {
obj.addEventListener("DOMNodeInserted", callback, false);
obj.addEventListener("DOMNodeRemoved", callback, false);
}
};
})();
const resetHoverEffect = () => {
circleMove_mouseLeaveHover();
movement();
};
observeURLChanges(document.getElementsByTagName("title")[0], () => {
resetHoverEffect();
}); |
Good job @saint-james-fr thank you. |
For Nuxt3 you can create a plugin file into the plugins folder (e.g: magic-mouse.ts) like this: export default defineNuxtPlugin(nuxtApp => { |
Needs support for virtual DOM frameworks.
It works on initialization but when the DOM changes, this library doesn't work. The cursor will not expand on dynamically added HTML tags.
The text was updated successfully, but these errors were encountered: