anseki / plain-draggable

The simple and high performance library to allow HTML/SVG element to be dragged.
https://anseki.github.io/plain-draggable/
MIT License
773 stars 99 forks source link

How can I install the library by NPM and use it on a Electron Applcation? #73

Closed lucaslgr closed 3 years ago

lucaslgr commented 3 years ago

Firstly thanks for the library, It's awesome!

I've tried to install using this command below:

npm i plain-draggable

and in file.js of my .html file I've tried to use the library in this way:

const plainDraggrable = require('plain-draggable');

but it isn't working.

What is the best way to use it ?

anseki commented 3 years ago

Hi @lucaslgr, thank you for the comment. The NPM package is installed into node_modules directory normally. Therefore, you have to write this in the HTML file. (when the file exists at the same directory as the node_modules directory.)

<script src="node_modules/plain-draggable/plain-draggable.min.js"></script>

See document: https://anseki.github.io/plain-draggable/#usage

lucaslgr commented 3 years ago

Thanks a lot @anseki ! It's working for me, I thought that I could use :

const plainDraggrable = require('plain-draggable');

But I don't understand very much about Javascript for frontend development yet. You helped me a lot and your library is really wonderful!!

I'm trying to use it with the https://anseki.github.io/leader-line/ for make a academic project of my school

lucaslgr commented 3 years ago

Could I ask you another question?

How I could make zoom in parent of draggable elements, a similar in what did you do in the first example of this page? https://anseki.github.io/plain-draggable/#options

anseki commented 3 years ago

Of course you can import it via require also. The node_modules is specification of Node.js and NPM, then you had better learn those.

Could you make new issue for another topic after closing this issue?

lucaslgr commented 3 years ago

Of course, I'll make a new issue for another questions, Thanks a lot again @anseki !