dragguble HTML element using JavaScript

preview_player
Показать описание
hi there
hope you all guys doing great

you may also find these videos useful

quote app using JavaScript

quiz app using JavaScript

file uploader progress bar using JavaScript

simple autocompletor using JavaScript

random password generator using JavaScript

alarm clock using JavaScript
Рекомендации по теме
Комментарии
Автор

tytytytytyty! omg this is literally what i have been looking for!!! you deserve your .... ate 💀

BunnyBunniee
Автор

Cool Video, I was thinking about doing a similar thing and this has been a great start and learning experience.
I found an issue that you can see in your video where once you set "chooseElement" to null you will have errors scrolling until you are holding another element.
This can be silenced by simply wrapping the part where you set the style of "chooseElement", with an IF statement checking if it has value.
but the core of the problem still exists. you have an event listener that is constantly getting the mouse X and Y coordinates.

To stop that you need to delete the listener on the mouseup event at the same time you set chooseElement to null.
To do that you need to switch from document.onmousemove to document.addeventlistener("mousemove", setCoordinates)
setCoordinates is a function with the exact same code as what used to be inside the arrow function. it needs to be somewhere else so that the listener remover can reference it.
document.removeEventListener("mousemove", setCoordinates)

this works perfectly and now nothing runs when it doesn't have to.

Jimmypl
Автор

7:35 to place the cursor inside the ball help me a lot, thank you so much hero :)

luca_argo
Автор

Thank you VERY much !
Can I just replace the 'color dots' with IMAGES ?
Thanks for your Help...

vmars
Автор

Try to never use var to declare a variable. Get into the habit of using "let" or "const" due to scope.

colindante
Автор

It doesn't work for me. I sued in on Microsoft edge and offline. And the results wa that I can't drag the divs at all!

gabryelhuneault
Автор

dragguable is spelled wrong from your title of the video, it's spelled draggable.

itzgametimevip
Автор

What I am not understanding is
"What causes these ''elements" to be 'draggable' ?
I see no such thing as draggable="true" ..
Thanks

vmars
visit shbcf.ru