Drag & Drop with Javascript in 4 minutes

Sdílet
Vložit
  • čas přidán 26. 08. 2024
  • Learn how to build draggable elements with Javascript in a few simple steps.
    Source Code: codepen.io/den...
    Instructor: / dennisivy11 / / dennis-ivanov
    💬 Follow Appwrite on social media & join our Discord community.
    • Twitter: / appwrite
    • Discord: appwrite.io/di...
    • LinkedIn: / appwrite

Komentáře • 42

  • @Appwrite
    @Appwrite  Před 28 dny

    Draggable stick notes app video tutorial here: czcams.com/video/yBThHM2pBbE/video.htmlfeature=shared

  • @zaanly
    @zaanly Před 4 měsíci +5

    It's great to see you back on CZcams, Dennis. Your Django tutorials were truly missed. I even tried contacting you through LinkedIn but didn't hear back. Looking forward to your new Django content! ✨

    • @Appwrite
      @Appwrite  Před 4 měsíci +1

      Hey, sorry, it's tough for me to get back to all messages. I'll take a look now and will see if I can find it. Appreciate your patience and support :) - Dennis Ivy

  • @artipeo816
    @artipeo816 Před 4 měsíci +10

    This is really under rated

    • @Appwrite
      @Appwrite  Před 4 měsíci

      Thank you 🙏 - Dennis Ivy

  • @iantimmis651
    @iantimmis651 Před 4 měsíci +18

    This channels name and logo make it feel like its a company trying to sell me something. I thought this was going to be an ad for some JS lib.

    • @Appwrite
      @Appwrite  Před 4 měsíci +5

      Nope, just awesome tools, cool projects and a awesome Backend as a service platform if you want it. - Dennis Ivy

  • @dkfailor
    @dkfailor Před 7 dny

    Nice tutorial and easy to understand. But shouldn't you use defer or async instead of putting code between the closing body tag and closing html tag? I could be wrong but I don't believe that is recommended as standard practice.

  • @SamehMustafa007
    @SamehMustafa007 Před 4 měsíci

    So nice tutorial video I like your direct explanation without a lots lablabla 👌your earn +1 subscribers

  • @luis96xd
    @luis96xd Před 4 měsíci

    Excellent video, nice explanation!

  • @imagineiffcom
    @imagineiffcom Před 4 měsíci +1

    I did this using jquery ui for an NBA team's contest page many years ago. Doing this with pure javascript is very interesting and gives a lot more control.

    • @Appwrite
      @Appwrite  Před 4 měsíci +1

      Yea when it’s this simple, just JS is clean. However, I’m working on the full notes app (as I mention in the beginning) and honestly, a framework like react really does come in handy when the code gets more complicated. - Dennis Ivy

  • @garasipemula
    @garasipemula Před 4 měsíci +1

    I like it, keep it up ❤

  • @prateekyadav797
    @prateekyadav797 Před 4 měsíci

    How can you stop the card from going over the borders of the viewport. I used
    ((card.offsetTop + card.clientHeight)

  • @everchanging19
    @everchanging19 Před 4 měsíci

    Love it thankyou

  • @gerryramosftw
    @gerryramosftw Před 4 měsíci

    subscribed. this was great!

  • @mrchineduOfficial
    @mrchineduOfficial Před 4 měsíci

    This is new to me, how did you come up with all the calculations? where can I learnt this. Thank you

    • @Appwrite
      @Appwrite  Před 4 měsíci +1

      I made a quick video explaining this, see if this helps :) x.com/appwrite/status/1783310348453544198

  • @alexdin1565
    @alexdin1565 Před 4 měsíci

    hi dennis we missed your django tutorials please if you have some times make videos in your channel

    • @Appwrite
      @Appwrite  Před 4 měsíci

      Soon, very soon Alex :) - Dennis Ivy

  • @TreeLuvBurdpu
    @TreeLuvBurdpu Před 4 měsíci

    It gets a bit more interesting when you want to allow touch-move.

    • @Appwrite
      @Appwrite  Před 4 měsíci +1

      True, a topic worth covering for sure - Dennis ivy

  • @user-lc7pn8zp8f
    @user-lc7pn8zp8f Před 4 měsíci

    Thanks for video 👍 phoneview the same with touchstart events ?

    • @Appwrite
      @Appwrite  Před 4 měsíci

      I believe it would require a little more configuration to handle touch events. Something I'll have to take a minute and look at. - Dennis Ivy

  • @atl_tube
    @atl_tube Před 3 měsíci

    How do you generate a new picture for dragging and dropping?

    • @Appwrite
      @Appwrite  Před 3 měsíci +1

      That will be shown in the full "notes app" tutorial. Currently a work in progress. - Dennis Ivy

  • @darsico
    @darsico Před 4 měsíci

    how to keep it persistent using appwrite?

    • @Appwrite
      @Appwrite  Před 4 měsíci

      It's just a matter of updating the note on mouse up. The method I use is to just stringify the X & Y coordinationsa and store then in a attribute called "position". You'll see this in my upcomming video where I build out the entire notes app. Example:
      Save like this:
      JSON.stringify({x:47, y, 98})
      Use like this:
      const position = JSON.parse(note.position)
      console.log(note.x)
      console.log(note.y)

  • @AWM_2023
    @AWM_2023 Před 4 měsíci +2

    A bit too fast. And in 2024 we cannot refrain ourselves from excellence, so the css should be optimal, changing the cursor to draggable and dragging during the move. Thanks for the video and I hope you improve and grow a lot 💪🏼 congratulations! I’m rooting for you.

    • @Appwrite
      @Appwrite  Před 4 měsíci +2

      My assumption is that you are referring to the draggable attribute, correct? While both ways work I found that draggable has some drawbacks, but really it's just a preference at this point. Both ways work fine :)
      Appreciate the support 🙏 - Dennis Ivy

    • @walkastray007
      @walkastray007 Před 4 měsíci

      @@Appwrite Hey! I found a way to make it a little bit more "appealing" that makes it clear when it's getting dragged.
      in the mouseDown function you can put the following code anywhere inside.
      card.style.cursor = "move";
      and in the mouseUp function you can put the following code inside
      card.style.cursor = "pointer";
      When you hover over the card, it will be pointer. On mouseDown it changes it to the "move" pointer which is two bidirectional arrows (hard to explain easy to see) and on mouseUp it changes it back. Super straight forward and hope it helps!

  • @ashishsatavase8031
    @ashishsatavase8031 Před 4 měsíci

    how do i do this in react or next ??

    • @Appwrite
      @Appwrite  Před 4 měsíci

      That will be in the full tutorial ;)

  • @kumargupta7149
    @kumargupta7149 Před 4 měsíci

    Hi Dennis

    • @Appwrite
      @Appwrite  Před 4 měsíci

      Hey! 👋 - Dennis Ivy

  • @user-of6ls2ng5l
    @user-of6ls2ng5l Před 4 měsíci

    Thanks for the link to the code (no)

    • @Appwrite
      @Appwrite  Před 4 měsíci

      I’ll add that in a bit

    • @Appwrite
      @Appwrite  Před 4 měsíci

      codepen.io/dennisivy/pen/VwNEPvY

  • @d.minkov
    @d.minkov Před 4 měsíci

    You don't need those events.. there is already an event for drag in JavaScript 😂

    • @Appwrite
      @Appwrite  Před 4 měsíci +1

      You can accomplish the same thing in many different ways 😁And btw, the events you are referring to are good for drag and drop when it comes to sorting, ordering and placing items in a specific predestined position. This method gives more flexibility- Dennis Ivy

    • @renaissancewoman5373
      @renaissancewoman5373 Před 13 dny

      @@Appwrite what if I needed the draggable item to be an image instead of "card"?