Easy Drag n Drop with JavaScript - how to code tutorial

Поділитися
Вставка
  • Опубліковано 11 січ 2025

КОМЕНТАРІ • 114

  • @TheCompleteGuitarist
    @TheCompleteGuitarist 4 роки тому

    I started javascript 20 years ago and NONE of this was easy without writing a massive amount of code. I'm getting back into this after being out of the game for about 12 years and so much has changed. I'm not saying it's ridiculously easy compared to back then but I am more impressed by the CSS here than anything, but at least the code (js) is way more succinct.
    Thanks for sharing this. It's my first step into something that I think will be very useful for me as a language teacher :)

    • @geemanrocks5314
      @geemanrocks5314 4 роки тому

      I like the video , but having a hard time , I will keep at it.

  • @donaldbradbury1100
    @donaldbradbury1100 4 роки тому +1

    Thank you for this post. This is almost complete as to what I needed. It was a wonderful introduction to the world of drag and drop on the web. I will incorporate this into my electron app with node. Again, thank you.

  • @davidmorrow1393
    @davidmorrow1393 4 роки тому +1

    Impressed at CSS mastery. Drag and drop seem so simple.

  • @riceboom360
    @riceboom360 3 роки тому

    This video is the best. I like this video because he really does to teach something, other similar videos just call a script from somewhere else. Nothing help for coding.

  • @mrrose3796
    @mrrose3796 3 роки тому

    I got it to work eventually. I had to change the last "this" in the nested for with the list looping variable

  • @alis9389
    @alis9389 3 роки тому +1

    thank you thats exactly what i needed. thank you so much

  • @stevensmith5626
    @stevensmith5626 Рік тому

    Fantastic! Keep up the good work

  • @ryanwoods3333
    @ryanwoods3333 3 роки тому +1

    great video mate. love these

  • @billalhossain2179
    @billalhossain2179 2 роки тому

    Very Helpful. Thanks for the video

  • @skolotoi4588
    @skolotoi4588 2 роки тому +2

    Thanks a lot, Tyler!! 🤟

  • @mehmeteminsaym7179
    @mehmeteminsaym7179 3 роки тому

    Very very nice. an educational video. Thanks.

  • @rostyklukavyi7828
    @rostyklukavyi7828 3 роки тому

    as far as I know, 'this' keyword had a different context inside of settimeout() because of this it didn't work. Thanks for the video, it was helpful!

  • @keduslejiyared8701
    @keduslejiyared8701 4 роки тому +1

    I never knew your videos were both very educating and easily understandable 🙌🏽😁. Thank you for this amazing video.

  • @bernardoapelt
    @bernardoapelt 5 років тому +6

    Thanks a lot for posting and take your time , it really help!

    • @TylerPotts
      @TylerPotts  5 років тому +1

      I'm happy it helps that's the aim! To build a community for new web developers to learn and grow.

  • @erikkostic8271
    @erikkostic8271 3 роки тому +1

    I liked that video very much. Thank you

  • @glenndivinagracia3645
    @glenndivinagracia3645 4 роки тому

    Very helpful. Thanks for walking us through with the explanations.

  • @h0ckeyd
    @h0ckeyd 4 роки тому

    Pretty awesome stuff! I've got an LP wall display in my front room (I know, pretty hipster) and lockdown's got me lacking ideas so using your tutorial as a basis, I've created a virtual version by replacing the text of each div with an image (the LP cover). Cheers for the help!

  • @karlduckett
    @karlduckett 5 років тому +2

    Great content! I took a little break from coding but back now :) I have a few of your videos to catch up on!

    • @TylerPotts
      @TylerPotts  5 років тому +2

      Haha awesome I hope you enjoy! Thank you!

  • @tetteishahday-annang3120
    @tetteishahday-annang3120 5 років тому +2

    Thanks taking your time to make these awesome videos 💙

    • @TylerPotts
      @TylerPotts  5 років тому +2

      Thanks man, I appreciate the comment and I will always take time to make videos! 😁

    • @tetteishahday-annang3120
      @tetteishahday-annang3120 5 років тому

      @@TylerPotts Great... 💙

  • @JH-hr6fw
    @JH-hr6fw 4 роки тому

    Sick video brother! loved it. Also you did an excellent job at explaining so thank you very much

  • @agiksetiawan3227
    @agiksetiawan3227 4 роки тому

    Thanks for share this tutorial. Helpfull

  • @ilovepishang
    @ilovepishang 2 роки тому

    Thanks for the video, just curious - why do we need to put the loop for lists inside the list_items loop? I moved it outside so it's not nested loop and it works, maybe I'm missing something so any pointer will be greatly appreciated!

  • @nykfeng
    @nykfeng 3 роки тому +1

    Thank you so much for the video! I have one question. How do you target the element at dragging state? In the intro section of the video, your item box has a red border, but you didn't show this step in the detailed video. I would appreciate it if you can let me know how that was done. Thank you!

    • @TylerPotts
      @TylerPotts  3 роки тому +1

      Ah, sorry. I didn't realise I missed that step. There is an event called "drag" you would use to then apply the border while the element is being dragged then you remove the border on the "drop" event. I hope this helps.

    • @nykfeng
      @nykfeng 3 роки тому

      @@TylerPotts Ahhh Thank you! That works. May I ask you one more question? Do you by any chance know how to change the ghosted style while an item was dragged? I tried to change opacity, background, those didn't work. I searched around, didn't find a solution. Maybe that's browser default behavior?

  • @osloren5614
    @osloren5614 4 роки тому +1

    Oh! realy easy. Thanks a lot

  • @durangodave
    @durangodave 4 роки тому

    Hi, i learned that with different size boxs the only way to D n D the larger box is to use css resize and then resize it the same size or smaller than the other boxes, they it can be D n D . Now can you do a video please of how to save the data to the DB so that users can save their positions then it can be loaded at login using PHP ... Thanks...

  • @pablohernandez4305
    @pablohernandez4305 4 роки тому

    Thanks for this video, great tutorial

  • @juniord_osbel
    @juniord_osbel 4 роки тому

    Thanks a lot!! Good job!!

  • @Draftpull_programming
    @Draftpull_programming 2 роки тому

    thanks alot for your effort

  • @ellenfogarty5449
    @ellenfogarty5449 4 роки тому

    Thanks for the video. What colour theme are you using for VS Code? It's so nice!

  • @theexposer9483
    @theexposer9483 2 роки тому

    What sort of drag and drop is this where we start things with writing lines of code?

  • @erenenadream
    @erenenadream 4 роки тому +1

    Which theme do you use ? Your syntax looks great

    • @TylerPotts
      @TylerPotts  4 роки тому +1

      I think this was Material theme using the material icon theme!

  • @iSkvort
    @iSkvort 2 роки тому

    Do you know how exactly this magic with timeout works? I mean we have event loop, tasks queue and tasks to render page, do you know what happens when? I understand only that timeout with 0 will put the task in the queue but what happens next?

  • @ronidey7100
    @ronidey7100 4 роки тому

    Great tutorial👍
    Thanx!!

  • @fxstreamer238
    @fxstreamer238 5 років тому +1

    how did you remove the forbidden sign when you drag with cursor?

  • @kevinrauer
    @kevinrauer 5 років тому +1

    Very very nice.. Thanks for a nice and simple walk through!! How about a expansion to a Tree type interface??

    • @TylerPotts
      @TylerPotts  5 років тому

      Sounds good I'll look into it!!

  • @No-pn4uu
    @No-pn4uu 4 роки тому

    I’m trying to create an app with a kanban board in it. So the user has to login first to access the board, but when I try to redirect user from login page to his kanban board, drag and drop does not work( but if i start kanban html on its own without first logging in, it works). Does it have to do something with these timeouts? How do I fix this?

  • @codercoder7270
    @codercoder7270 4 роки тому

    What about positioning and sorting ?

  • @arnavdixit1397
    @arnavdixit1397 4 роки тому

    How would you make it sort?
    As in if i move list item 1 and drop it. Now if i take it back to the first list column, it goes to the end again. I'd like it to sort/return to it's default state again. Any help?

  • @terje-andreriis55
    @terje-andreriis55 3 роки тому

    how to get the position where the item was placed ?

  • @iftekharrahman8100
    @iftekharrahman8100 4 роки тому +1

    Hi, is that draggable on mobile devices?

  • @Shakespeare1612
    @Shakespeare1612 3 роки тому

    Good tutorial, but... This is my 8th video on drag and drop and I have still not seen the functionality that I need. I seems like it would be a common thing. I need the drop zones to act like SLOTS. They should be able to accept one drop only and then reject further drops. I have learned that "cancelDefault()" can make a normally un-droppable element droppable, but then how to you cancel the cancel, that is, restore the default, UNDROPPABLE behavior one a drop zone has gotten an item. I am making a Tic Tac Toe game. once a game board slot has received either an X or an O, I need to to refuse any further drops, and ideally, have the hovering piece returned to it's start position.

  • @qili3970
    @qili3970 4 роки тому

    this is awesome!!!

  • @MrBeastFan_Gyak
    @MrBeastFan_Gyak 3 роки тому

    thx for video man !!!!!!!!!!

  • @AjayKumar-wk8kn
    @AjayKumar-wk8kn 4 роки тому

    Thanks for the video. I am trying to implement the scenario. After drag and drop, when i click on the dragged element, I have to display a popup message with some details, but event listener for click is not working.

  • @hassainehassen5700
    @hassainehassen5700 4 роки тому

    Thanks , and i need to add 3 more column in second row can you please help me ?

  • @tiendungnguyen158
    @tiendungnguyen158 4 роки тому

    how to change position 2 elements which both in a colume?

  • @HllAydn16
    @HllAydn16 5 років тому

    Thank's for good video

  • @Rezafarhangian
    @Rezafarhangian 2 роки тому

    great💙💙💙💙

  • @SeluHadu
    @SeluHadu 5 років тому +2

    I had to watch 5 videos to check if UA-cam was messing up the video or the video is blurry. BTW good video.

    • @TylerPotts
      @TylerPotts  5 років тому

      I think UA-cam messed up the processing for the first 3 minutes but thanks man!

  • @tsaiandy221
    @tsaiandy221 4 роки тому

    I think requestanimationframe is more functional instead of settimeout

  • @dnxsol
    @dnxsol 4 роки тому +1

    what happened to the Video on making this dynamic?

    • @mozzie_camper
      @mozzie_camper 4 роки тому

      I really need just that but with a dynamic database. I've set up the database but i just don't know how I can Display these list items from my database -.-
      Anyone that can help me? I would pay a small amount if you show me how I can do that.

  • @DenniS-qr3nn
    @DenniS-qr3nn 4 роки тому +1

    great !! thx~

  • @bikramchettri9405
    @bikramchettri9405 5 років тому +2

    Thanks for this.

    • @TylerPotts
      @TylerPotts  5 років тому +1

      Anytime, I enjoy doing it.

    • @bikramchettri9405
      @bikramchettri9405 5 років тому +2

      @@TylerPotts Thanks man. Awesome tutorial.

    • @bikramchettri9405
      @bikramchettri9405 5 років тому +1

      @@TylerPotts Hey thanks for the tutorial can you please explain date object in javascript and then show how to create a datepicker?

    • @TylerPotts
      @TylerPotts  5 років тому +1

      Nice idea. I will look into this for you. :D

    • @TylerPotts
      @TylerPotts  5 років тому

      This should hopefully be tomorrows video if everything goes to plan. :D

  • @JasonMSTRD
    @JasonMSTRD 4 роки тому

    How would you delete?

  • @alphasiera1757
    @alphasiera1757 4 роки тому

    noob question, what if I want to make a website and I want to drag a photo to a box but the photo will remain after being drop. Another thing, can I do that using only html or css or I really need java

  • @VedPrakash-zh1dd
    @VedPrakash-zh1dd 5 років тому +1

    The card always drops on the bottom only.

  • @md.belalhossain
    @md.belalhossain 3 роки тому +1

    Thanks

  • @Gwhizzman1
    @Gwhizzman1 4 роки тому

    I haven't coded a day in my life, but I'm conceptualizing something like this for a business application I need to start due to a job loss. How do I go about using this in Dreamweaver?

    • @BHFJohnny
      @BHFJohnny 4 роки тому

      I suggest you don't actually use Dreamweaver to code. I never heard or seen anyone using it professionally (maybe I'm just unlucky). Don't be scared by Visual Studio Code. It's really good, solid.
      If you haven't coded a day in your life, don't start with advanced Javascript. Start with easy stuff. At least do a crash course on HTML and CSS, let it sink in, then start basic Javascript, then step up. It's essential to build fundamentals.
      I wish you all good and thank you for considering joining this great world of developing.

  • @VedPrakash-zh1dd
    @VedPrakash-zh1dd 5 років тому +1

    When we drag up the box, this is not working. Please fix this problem...

  • @anirudhkumaran83
    @anirudhkumaran83 5 років тому +1

    any solution or suggestion for making clone drag and drop

    • @TylerPotts
      @TylerPotts  5 років тому +1

      I am not sure what you are asking?

  • @danneytee
    @danneytee 3 роки тому

    hi buddy, how can i remove a child element of draggable item after the dropend executed successfully?

    • @TylerPotts
      @TylerPotts  3 роки тому

      You should get a reference to the child object maybe a class then reference the parentNode.querySelector the child then remove it in dragend event listenre. Sorry if this doesn't make too much sense it's hard to explain over text.

  • @xoxo2880808
    @xoxo2880808 3 роки тому

    thanks a lot!!!

  • @bhupiiidx8406
    @bhupiiidx8406 4 роки тому

    How to create 4 box and box 1 contents can be dropabble in 2 and 3 but not 4, box 2 will be 1 and 4, box 3 will be 1 and 2, box 4 will be 1 and 3

  • @TheOnlyGrimz
    @TheOnlyGrimz 5 років тому

    Code available for download?

  • @dmytro629
    @dmytro629 4 роки тому +1

    Wow!!!

  • @pavovera5244
    @pavovera5244 4 роки тому

    why the variable draggedItem is defined null ?
    anybody help me please??

  • @mcotechtv4180
    @mcotechtv4180 4 роки тому

    but how add items

  • @xiaokourou
    @xiaokourou 4 роки тому

    Great!

  • @yasmineaboudrar4932
    @yasmineaboudrar4932 5 років тому +1

    Thank's a lot

    • @farooqnadaf3950
      @farooqnadaf3950 4 роки тому

      Hi I want to know can we print dragged text only please reply

  • @oscaraberg758
    @oscaraberg758 4 роки тому

    did you ever made the trello clone?

    • @TylerPotts
      @TylerPotts  4 роки тому

      Unfortunately, I did not but, it is something I may do in the near future.

  • @mrrose3796
    @mrrose3796 3 роки тому

    It did not work; I get the message: "Uncaught TypeError: this.append is not a function
    at HTMLDivElement." from the google console

  • @lemur4074
    @lemur4074 4 роки тому

    But how to save?

  • @Matthitjah
    @Matthitjah 5 років тому +3

    First 3 minutes are super blurry

    • @TylerPotts
      @TylerPotts  5 років тому +3

      I thought that was just me 😬 looks fine before I uploaded to UA-cam... Must have messed up during processing... I'll try to fix it.

    • @Matthitjah
      @Matthitjah 5 років тому +1

      @@TylerPotts Appreciate that

  • @davivify
    @davivify 3 роки тому

    I'm going to recommend that you do some practice videos before doing the one you post for public consumption.

  • @qwerty_codes1548
    @qwerty_codes1548 Рік тому

    it does not work

  • @مشاهدةممتعة-ي2ق
    @مشاهدةممتعة-ي2ق 3 роки тому +1

    I am a beginner. And until now I don't understand "This" 😑