I forgot to mention I do have a 21 hour course on vanilla JS on Udemy if anyone is interested here is a $10 code. www.udemy.com/modern-javascript-from-the-beginning/?couponCode=KZbin10
@jolyonfavreau31606 жыл бұрын
bought it and have been working through it slowly. excellent course, full of easy to follow content.
@hossameldinshaheen53666 жыл бұрын
Are you will make react course i mean react front to back like angular not the course that you explain projects, please we need essential course with projects.
@slinco656 жыл бұрын
Working through it now - great course Brad! Anyone who wants to _really_ know javascript should take Brad's course ;-)
@dadev36686 жыл бұрын
Definitly a great course I just got past the ajax part and it's great I can finally do some kool apps with my laravel backends, I do have one request for once if you can get a chance to do a tailwind css course that would be great Thanks Brad
@albertgalvez25566 жыл бұрын
Got it and can't wait to go through it.
@MrThejhubs4 жыл бұрын
I gotta say, as far as content, this is one of the best tuts I've watched. You described the topic of the video (drap & drop & their listeners) on a basic level without going into every single other feature you were using (callbacks, timeouts, etc.). A simple thing, but my biggest complaints on other tutorial channels. I came here to learn drag and drop, and I did. Thank you, subbed.
@scorpionesp65103 жыл бұрын
Bruh, I love your teaching style, and how you are so clear and how you show how things work instead of just watching you code. Purchased a bunch of your courses to support and subscribed (yes aiming for a cookie here) but love your lessons and thanks!
@mohammadakbar326 жыл бұрын
i was looking for drag n drop! thanks Brad! God bless you and your family
@TraversyMedia6 жыл бұрын
Thank you brother
@mohammadakbar326 жыл бұрын
Traversy Media you deserve it bro!
@kariminic6 жыл бұрын
These new videos can be overwhelming, I am trying to stick to learning just a few web development languages that fit within my schedule but EVERY pop UP notification from Brad, are irresistible.. There is a new thing to learn or a word for motivation to upcoming developers..Thanks Brad, You the best.
@TraversyMedia6 жыл бұрын
I realize that. What I always suggest is having a core set of technologies that you REALLY dig into and learn through various resources BUT it does not hurt to watch and learn other things just to grasp the coding concepts, etc. A lot of time it will help you in just general logic and understanding in programming in general.
@kariminic6 жыл бұрын
Traversy Media Thanks a bunch, you always a source of my Motivation..
@raymondmichael49876 жыл бұрын
Great point Sam C
@arpanmukherjee46256 жыл бұрын
Love this channel....I have learnt Laravel, Vue.js, Building REST Service and what not....Best of the best.....
@argeelearner39786 жыл бұрын
Arpan Mukherjee Go Lavavel and vuejs!
@wesstephenson45336 жыл бұрын
I wish more people taught like you do. You not only make sure I understand, but you explain things in a way that I can't misunderstand. I love it!
@glenn_r_frank_author4 жыл бұрын
Thank you for such a complete tutorial for basics and beginners on this. I love how you took the time to show us the consolw events firing off .. really made it so much more understandable!
6 жыл бұрын
Hi. Thanks for an amazing tutorial as always! I would do two improvements to this code: 1. requestAnimationFrame() instead of setTimeout() 2. classList.add() & classList.remove() instead of manipulating className string Thanks again! Keep on doing amazing work!
@coced6 жыл бұрын
classList.toggle is pretty neat too
@icarofilho65243 жыл бұрын
I just used requestAnimationFrame and it works great thank you.
@Maxim95753 жыл бұрын
About rAF that function works on similar principles like setTimeout, but there is one thing which change everything. setTimeout based on queues executed codes (rude but it is), every setTimeout in running code is set at the end of such queue, and when queue will come to the next setTimeout, that setTimeout will be execute. rAF practically is same, but it will be invoked also like setTimeout but with one optimization thing, it's synchronization with HZ of your display. So rAF may be called faster than setTimeout or against slower, it all depends on your monitor mostly. You should see lecture about Event Loop or Jake Archibald: In The Loop.
@Navarragirl275 жыл бұрын
The one and only Brad, who can explain JS so well anyone can understand. Thank you very much :)
@jopeme_official3 жыл бұрын
Your videos don't get more helpful than this. Thank you so much for not only teaching us this but do it in a way that ANYONE can understand. Truly appreciate you, man!
@LordN3r3v4r6 жыл бұрын
domElement.classList.toggle('hovered'); Way easier to understand and the support is there (for IE), as long as you use just one parameter (the class name string). There are also .add(), .remove(), .contains() and .replace() methods for dealing with CSS classes. Nice video!
@juditzentai15174 жыл бұрын
This video is very helpful. I just want to mention that I used a different solution to see only 1 picture while being dragged, under the cursor and not on the original place. I simply added to the . hold in the CSS an opacity: 0% attribute. This way while the picture is being dragged, the original picture in the original place becomes invisible. This might not be the most elegant solution but you do not have to use setTimeout(). Anyway, you just shortened my home assignment a lot so thank you! :)
@theWanAndOnly4 жыл бұрын
man, javascript has advanced over the years. It's really intuitive and easy to do all these complex things now. Hooray for progress! And thanks for your tutorial btw, making it look effortless is not easy, you're doing it good man.
@limitless94835 жыл бұрын
As someone who hasn't started learning frameworks yet, this helps me a lot, will implement it in my js game, thanks brad.
@mihkelsiim7614 жыл бұрын
These console messages were really useful. It helped me a lot to understand when what is run.
@mn62106 жыл бұрын
Thanks for the free drag and drop tutorial. Whenever I need something related to programming language , first thing comes to my mind is this channel(traversy media). Your channel is in top of my list. I appreciate your work..
@khudoyorrakhmatov75303 жыл бұрын
The way Brad delivers content is next level. After having watched his videos for some time, I became a picky learner.
@hardikmodi82346 жыл бұрын
Whenever I think of implementing something in project, on the very next day sir Brad have Video on that. Really amazing. Thank you very much for your great efforts.
@Soumya21st6 жыл бұрын
Brad is a Javascript Rockstar in the youtube earth
@tonniewhiteley24976 жыл бұрын
You know I was on the train home yesterday dead tired and I went on KZbin to watch some chill videos and I saw that one and I got sooo excited that even after a whole day of work I had to watch this :D thanks Brad :)))
@kingundfaker5 жыл бұрын
14:08 You can mark the lines you want to copy and then shift+alt+arrow key to instantly copy&paste. Nice Guide on Drag & Drop! You helped me implenting this on my Dungeon & Dragons Browser Game :)
@TraversyMedia5 жыл бұрын
Thanks, yeah I learned that a bit after this video :)
@arturluisoliveira5 жыл бұрын
thanks brad, I've studied javascript in your channel for a while and recently at my first task end up in here again! hahaha. thanks for the knowledge, happy new year.
@K8Tech6 жыл бұрын
You struggle searching how to do something with your app... Brads got you. Thanks man!!!
@daalwada3 жыл бұрын
Basics of Kanban board 😅 Amazing work Brad! I am really glad there are developers like you who exist to contribute genuinely to teach people! Great tutorial 😊👍
@Jadraptor6 жыл бұрын
Thank you for doing these sorts of videos. It makes it easy for me to learn at my own speed. This was also not nearly as complex as I thought it would be. I have a new understanding for how to structure such things in vanilla.
@fogreyiz5 жыл бұрын
Excellent tutorial without unnecessary and complicated details.
@RufusVidS4 жыл бұрын
Terrific tutorial as usual. The only one comment I felt was missing was the fact that the .append() method removes the element from its prior container automatically (which is clear as you watch the elements in the Developer Tool window), but I remember wondering why there wasn't a remove() method to detach an element from the original container.
@expchrfir6 жыл бұрын
im doing my first js applicationa and you have some great content. not the first time this week im ending up with a video of yours. Cheers!
@YuriiKratser6 жыл бұрын
Didn't you create a great course "modern js ..." if it was you, you are super teacher!
@myhandle3703 жыл бұрын
Short video and straight to the point. Excellent!
@canimcanimnazlim3 жыл бұрын
i love the way you try to make us understand whats going on really :)
@TheFGrox6 жыл бұрын
You may even use the "add(string[])" and "remove(string[])" methods of the property "classList" of an HTML element to add or remove CSS classes from it. The code will be a little more readable at first glance doing so.
@LesAnimes5 жыл бұрын
Man come on!!! you make everything look extremely easy, you are the one, God bless you
@hollidaycursive3 жыл бұрын
I don't know if anyone else ran into this, but if you click on the background on accident instead of the image and drag, you are actually highlighting the div or divs. If you then grab the image while more than one div is highlighted, you will make the image disappear. Upon searching for the div in the inspector, you will find that it's invisible. To fix this, add "user-select: none;" to the "empty" class in your css and it will prevent this from happening!
@AdegbengaAgoroCrenet6 жыл бұрын
This is a great tutorial. I would traditionally implement this with a library but now I am definitely going to be doing pure Vanilla for these. Thanks Brad
@lucasa87104 жыл бұрын
this is the best video i have ever seen, i mean, the way you explain it is really amazing; sorry about my english.
@vitalikda5 жыл бұрын
Issue on Firefox: it requires the `dataTransfer.setData` function in the dragStart event. Something like this: function dragStart(e) { this.className += ' hold'; e.dataTransfer.setData('text', ''); setTimeout(() => (this.className = 'invisible'), 0); }
@Daniel-yn1hd5 жыл бұрын
thanks !
@FordExplorer-rm6ew5 жыл бұрын
I work on Firefox too and knew was going to run into same thing
@FordExplorer-rm6ew5 жыл бұрын
People like you are absolutely awesome @Vitaly thankg you
@milesnottage59005 жыл бұрын
Hi - great tutorial and thank you - but where is the 'invisible' class defined?
@sergegoujon80226 жыл бұрын
Worth mentioning that it's usually faster to grab an element with specific class by using .getElementsByClassName() instead of .querySelector().
@Oswee6 жыл бұрын
Select code and press Alt + Shift + Arrow Down. :) Would like to see the same stuff but with some table rows. Like re-ordering tasks by their number of priority (with actually changing number of priority/or order).
@gavincoulson39003 жыл бұрын
Brad I cannot tell you how much I appreciate your videos. Please keep making this amazing content. Love your channel and love your Udemy courses.
@yolo-mb4cy5 жыл бұрын
2 questions: 1. How did it work with setTimeout() 2. Why is it good to use const empty in the for loop?
@erayeroglu81756 жыл бұрын
Your pronounciation and expression is very clear, I can easily understand you. Thanks bro
@jamalabdullahi81556 жыл бұрын
Many thanks brad this is what I was trying to do this week
@patrickphilipot6 жыл бұрын
This code doesn't work anymore with Firefox 62.0. The dragstart event fires then no more event occur. Tested both on Windows and Mac OS X. The code works on Safari on Mac OS X. Works too with Chrome on Windows 10. Could be a Firefox bug ...
@patrickphilipot6 жыл бұрын
To make it work with Firefox, just add this line to the dragStart function: e.dataTransfer.setData('text/plain', "anything"); The changed function will be function dragStart(e) { e.dataTransfer.setData('text/plain', "anything"); this.className += ' hold'; setTimeout(() => (this.className = 'invisible'), 0); }
@leoniduvarov65656 жыл бұрын
I'll be using this for my final project at my internship. Thank you!
@zachbaird28516 жыл бұрын
I saw this on my KZbin dash and said "Yeeeeeees". Love the tutorials, Brad!
@quechon16 жыл бұрын
Im a python guy but with your videos i have learnt a lot thanks for the time youbput on this man
@birsingh53886 жыл бұрын
Just buy your Vanilla JavaScript course, I hope I will learn lots of new things from that udemy course. Thank you, Brad.
@AetherXIV3 жыл бұрын
your tutorial style is excellent. thank you so much man. clear and easy to follow
@VeeWebCode6 жыл бұрын
Sir, your tutorials are so awesome..
@TraversyMedia6 жыл бұрын
Thanks :)
@WinkkleBoss280236 жыл бұрын
Thank you, sir. because of you, I was able to learn HTML, CSS, js and bootstrap in my summer vacations. god bless you and your family.
@OldePugsy4 жыл бұрын
I have a question. How do you do this with multiple images?
@The_Daily_Shorts4 жыл бұрын
Did you get the solution?
@johnaspinall87732 жыл бұрын
Excellent video Brad, just what I was after! Could you explain the invisible and doubling box again where you used setTimeout? I couldnt see any visual difference?
@ItsUreBoy4466 жыл бұрын
Great video! Figured since this is JavaScript, I’d throw out a suggestion for a future video. I’m interested in a video showing the use of lazy loading images on a site with many of them, so that images below and even above of the viewport are temporarily removed to reduce browser strain
@cyt46384 жыл бұрын
Awesome tutorials for drag events in front-end design! Thank you Brad!
@misterz59084 жыл бұрын
Please Brad can you do more this kind of short and very useful courses !🙏 And Thanks a lot! We love you💕
@blacklotus16066 жыл бұрын
to be honest amazing tuts, i was looking for something like it..., and the console.log explanation was top notch.
@byedwardleung4 жыл бұрын
nice, might change this into a drag and drop game
@steveymcneckbeard6 жыл бұрын
Oh Brad you do make my day, thank you so much for all your hard work!
@Yiosho6 жыл бұрын
Wish I could've had this video some months back when I had to do this at my first job... In the end had to settle using jQuery. Really nice video, thank you!
@FordExplorer-rm6ew5 жыл бұрын
Seeing this in es5 would be cool. Hard to tell what I have to do to use this in production. Have re written most of it in es5 but, 12:00 *this* keyword binds to something different in es5 vs es6
@continental_drift6 жыл бұрын
Interesting and helpful, It works in Chrome, almost works in Edge and in Firefox the image disappears as soon as I begin to drag on it. Javascript is enabled in Firefox but Edge I can't find the supposed place to check it.
@shioli39276 жыл бұрын
Firefox does support HTML5 draggable. But it does not automatically figure out what´s the data to be moved. As chrome does. If you don´t tell it anything. You have to add let img = new Image(); img.src = "source.unsplash.com/random/150x150"; e.dataTransfer.setData("image", img); into dragStart(e)
@sucetonraisin5 жыл бұрын
@@shioli3927 I was struggling with this, thanks for sharing this information!
@iamOrchid4 жыл бұрын
Is this possible to do with multiple draggable elements aswell? i have tried to change the first 'const' to 'querySelectorAll' aswell and used the 'for loop' for it aswell, but whenever i drop it just displays '[object NodeList]' and the div i was trying to move gets placed back to its original place
@iamOrchid4 жыл бұрын
Not needed anymore, i've figured it out by fiddling around with it for about a day :)
@Perdanjam5 жыл бұрын
Does anyone know why preventDefault() on mouseover allows mousedrop to trigger? 15:08 Not sure why this works, nor why mouseover function is still triggering even after the preventDefault() is set
@nahabiz6 жыл бұрын
Great tutorial, as always, Brad. Could you do a part 2 where all the divs are filled but if you pick up an image from one div, and drop it on another filled div, the image from the first div replaces that from the second div. On drop, the image from the second div, would move to the now empty first div. I hope this make sense.
@eoussama6 жыл бұрын
You never fail to amaze Brad, splendid tutorial, god bless you and your family, keep up the hard work 👍.
@AndreSpeek6 жыл бұрын
Hey Brad... Another great tutorial, thank! Only thing I noticed that this doesn't work on a touchscreen or mobile... I tried to look for solutions but I just found lots of questions and no good answers so far... Do you know how to do this?
@DopEZTam3 жыл бұрын
have u found out yet
@sulpher96 жыл бұрын
Appreciate the explanation of what is going on - good stuff!
@n_fan3296 жыл бұрын
Brad Traversy !! I love you brother from the bottom of my heart, you really changed my life :)
@h0ckeyd4 жыл бұрын
This is awesome. If I wanted to add another picture, would I, for example just repeat this process?
@joduaxddddd6 жыл бұрын
I've been looking for this for the past few days
@carltongordon6 жыл бұрын
OMG thank you so much Brad, these Vanilla JS lessons are so inspiring. do you have a full course on Vanilla JS making little functions like these?
@TraversyMedia6 жыл бұрын
Yes I do www.udemy.com/modern-javascript-from-the-beginning/?couponCode=KZbin10
@carltongordon6 жыл бұрын
Thanks mill bro
@carltongordon6 жыл бұрын
Just got it
@xenialxerous24416 жыл бұрын
Hey Brad! I can't thank you enough for sharing your knowledge & helping others achieve their goals.. thank you so much. I wanna be one of your Patron in a near future!!
@dataenthusiast67214 жыл бұрын
If you're struggling to drag multiple images on multiple div boxes, it's better to use dataTransfer. Here is how it can be done: Assuming you have multiple images, you can use for(img of images){//dragStart event & dragEnd event}. You can then go on to write the event functions function dragStart(e){ e.preventDefault(); //set the id of the target image e.dataTransfer.setData('text', e.target.id); } function dragDrop(){ //Your codes } In your dragDrop function for the empty boxes, you can write function dragDrop(e){ e.preventDefault(); //get the id of the dragged image id = e.dataTransfer.getData('text'); //append the dragged image this.append(document.getElementById(id)); } It took me sometime to figure this out until I learned about how to use dataTransfer. Hope this is helpful.
@Mental19936 жыл бұрын
Amazing work once again. I also support you on Patreon. Never regret a single dollar spent.
@sasikantnair5 жыл бұрын
Thank you. People might not be familiar with 'this' method during beginner stages, so could've been better if this was accomplished without 'this'. The video was good. You're good at explaining things. Keep it up.
@gorki906 жыл бұрын
Great video. It's incredible how you keep doing videos explaining things I would need to look up in near future.
@gowthams83406 жыл бұрын
*Amazing Brad ! Hope more js videos coming*
@jatinraj49746 жыл бұрын
Love your work sir 😍 . Now I am 14year old and learned js and done few projects just because of you .You gave me love for coding thanks sir .😊
@TraversyMedia6 жыл бұрын
That is awesome. I wish I got started that young. Keep that up and you'll run circles around other devs when you're older
@PlotTwists6 жыл бұрын
you swapped your age numbers ... it's 21
@jatinraj49746 жыл бұрын
Male Man what to say ..haters come every where .You do your work I will do mine.Thanks 😊😊😊😊
@jatinraj49746 жыл бұрын
Traversy Media thanks for this advice sir 😊 love for code😋
@Chintmaster6 жыл бұрын
Found this channel today. Subbed.
@thewezzley5 жыл бұрын
Excellent video! Question. Do dragover, dragenter, dragleave, and drop come as a package? Do you have to have them all for the code to work? I looked at your code on codepen and commented out dragover and the dragenter, etc. Every time I did this, the drop would not work.
@mr.c74114 жыл бұрын
Best programming channel🙌
@Ash-em5pm6 жыл бұрын
You are awesome Brad, and i really missed your facecam, hope you are now all set up with your new office,expecting a new setup tour soon:)
@FunIsGoingOn6 жыл бұрын
Ash Klmepton Seems like he had to drag and drop so much stuff in real life that the idea of this tut was born 😂
@josuejure61272 жыл бұрын
Hi, could you explain to me why in that particular instance a for loop doesn't work?
@ShubhamDeol6 жыл бұрын
Can you please explain me, why you used prevent default in dragOver function?? In which cases we need to do this?
@kuvinci6 жыл бұрын
*Awesome!* I was struggling to do good drag&drop on es5 but it's so much easier on es6
@GuitarTabsYT6 жыл бұрын
Would empties.forEach(empty) { empty.addEventListener('dragover', dragOver); etc. etc. } be the same as for(const empty of empties)?
@TraversyMedia6 жыл бұрын
GuitarTabsYT you could do that yes but foreach is a high order function so it takes in a callback function as a parameter. The syntax you have is a little off but yes you should be able to use it because querySelectorAll returns a node list which can use high order array methods.
@500iq6foot86 жыл бұрын
If you have a list of items, would there be a way to drag and reorganize the list of items?
@vovaparkhomchuk6 жыл бұрын
You are the best Brad! Thank you very much. Every time I watch your videos, I learn something new, simple and (that is important) very interesting
@abdelabdel80896 жыл бұрын
I can not thank you enough man. You are saving my day almost everyday!
@derrickrussell91976 жыл бұрын
Greetings Brad, I'm following your video with a little game of thrones twist. I have the first box with a background image of Danny on her dragon and the other boxes include a background image of castles. I put a div with class pic2 - pic5 in each of the empty divs to get the pictures there. It works fine until the drop event. It appends that image under the castle image. Is there a method to replace the element instead of append? Thanks for all you do. Ps: You look like a guy that liked the music I did back in the day and has seen the boston beatdown video. I could be wrong though.
@edavids064 жыл бұрын
Exactly what I was looking for. Thanks, Brad, for save me one more time!
@hemaethossain49466 жыл бұрын
Love you Brad. You're a nice guy!
@michaeljfordham6 жыл бұрын
Really, really great video and in-depth explanation. Thanks for sharing Brad!
@ahmadhijazi55063 жыл бұрын
If I need to copy so when I drag it, it remains in the original box and also copied to the box I drag it to it, what should I do?? Please answer me...
@PlotTwists6 жыл бұрын
Nice video very clear and simple and strait to the point, keep up the good work
@shannonwing34505 жыл бұрын
Would be interested to see a tutorial on more interactive drag and drop type stuff. Like if you were to build a greeting card app with embellishments you could drag and drop on the card.