litegraph.js icon indicating copy to clipboard operation
litegraph.js copied to clipboard

Mouse events errors after last version

Open mikeandtherest opened this issue 4 years ago • 9 comments

I'm using the library in an Angular project, and it started to throw errors at mouse move / click, after the recent changes. Specifically this from the screenshot below, caused by clientX_rel and clientX_rel inside function LGraphCanvas.prototype.adjustMouseEvent, which are not declared nor initialized (litegraph.js line 7483).

image


I was able to fix it by just adding these two lines at the beginning of the function:

        var clientX_rel = 0;
        var clientY_rel = 0;

mikeandtherest avatar Nov 13 '21 16:11 mikeandtherest

We should avoid using undeclared variables, angular is right,i create a pull request in here

https://github.com/jagenjo/litegraph.js/pull/273

gausszhou avatar Nov 13 '21 16:11 gausszhou

By the way : I think this library can separate core library and node library. others distribute their own node library, just like a plugin.

I want to use it like this :

import MyNodePlugin from "MyNodePlugin"
LiteGraph.use(MyNodePlugin)

gausszhou avatar Nov 13 '21 16:11 gausszhou

#273

Thanks for the fix The change that caused the issue is my fault, in my browsers the console was not showing that up and I missed it.

atlasan avatar Nov 13 '21 17:11 atlasan

By the way : I think this library can separate core library and node library. others distribute their own node library, just like a plugin.

I want to use it like this :

import MyNodePlugin from "MyNodePlugin"
LiteGraph.use(MyNodePlugin)

@gausszhou The first part of this I already did in the fork called litegraph.core.js (https://github.com/mikeandtherest/litegraph.core.js). You might want to check it out.

I might also do at some point a separate library for a nodes / node plugin system, if the project I'm currently working on would require it.

mikeandtherest avatar Nov 13 '21 18:11 mikeandtherest

Hi @mikeandtherest and @gausszhou!

Separating nodes and plugins it's a nice thing to do. They could be shared easily between different projects. Sharing nodes could be amazing.

@gausszhou, you are right, undeclared variables aren't meat to be as others issues, especially in productions. We should not auto update, and make better use of releases and versions.

@mikeandtherest, can I ask what are you working on? What differs in your only core version?

atlasan avatar Nov 14 '21 11:11 atlasan

@atlasan The project is just a SaaS idea for a tool that would allow others to build web apps easier. So far there is no difference between litegraph.js and litegraph.core.js, except that in the core version I removed all the predefined nodes. I had to do that since the main library doesn't have a "barebone" version of the js file.

mikeandtherest avatar Nov 14 '21 11:11 mikeandtherest

By the way : I think this library can separate core library and node library. others distribute their own node library, just like a plugin. I want to use it like this :

import MyNodePlugin from "MyNodePlugin"
LiteGraph.use(MyNodePlugin)

@gausszhou The first part of this I already did in the fork called litegraph.core.js (https://github.com/mikeandtherest/litegraph.core.js). You might want to check it out.

I might also do at some point a separate library for a nodes / node plugin system, if the project I'm currently working on would require it.

@mikeandtherest Yes, I found your code repository, which aroused my thoughts.

Maybe I will fork this, and then make the transformation of monorepo and esbuild.

But I don't know much about the history of litegraph.js, exapmle, some of the csharp code is not necessary for me.

I will spend some time to do these tasks in the near

gausszhou avatar Nov 14 '21 11:11 gausszhou

@mikeandtherest there is now a litegraph-mini.js which only contains core and basic nodes (like events, and logic).

jagenjo avatar Nov 15 '21 10:11 jagenjo

@jagenjo Awesome, thanks. For my use case however, having a zero-nodes version is still preferable.

mikeandtherest avatar Nov 15 '21 11:11 mikeandtherest