Building draggable Component with React and TypeScript

แชร์
ฝัง
  • เผยแพร่เมื่อ 3 ต.ค. 2024
  • Hey everyone, in this episode we are going to learn how to build a "draggable" component with React and TypeScript from scratch. This way we avoid using any library providing similar functionality because those libraries usually provide bunch of extra features we don't need and that can be very costly for our project size.
    Get the code on Github - github.com/div...
    Music - www.epidemicso...

ความคิดเห็น • 25

  • @DanishTroll87
    @DanishTroll87 10 หลายเดือนก่อน +1

    Great video, literally what i needed. Half the videos out there either complicate things or don't show a real life test at the end.

  • @alext5497
    @alext5497 ปีที่แล้ว +3

    thank you for doing this without an external lib, i couldnt' even get gpt to do it right.

  • @BigBahss
    @BigBahss ปีที่แล้ว +2

    Thanks for the video. Just wanted to say, the mouseleave event does not fire properly on firefox, but it does on chrome, so on firefox you can just keep dragging the box beyond the edges of the container to where it's completely hidden, and gets lost if you mouseup.

  • @adairoreyes1644
    @adairoreyes1644 2 ปีที่แล้ว +4

    Nice video! , I would love that you'd include some explanations about the math, It was rather hard to catch up at the end

    • @diveindev
      @diveindev  2 ปีที่แล้ว

      Thanks Adario, I appreciate the feedback, will try to make a separate one and dive into nuances.

  • @balintbruncsics6396
    @balintbruncsics6396 2 ปีที่แล้ว +1

    Dude, great work! Looking forward to the next video!

    • @diveindev
      @diveindev  2 ปีที่แล้ว

      Thanks a lot! I'm happy that it was useful.

  • @muhammadabdullahnabeel6039
    @muhammadabdullahnabeel6039 11 หลายเดือนก่อน

    Well coded and great work, however you should also guide about how to keep complete box in the container, as you have observed, sometimes when cursor move near the corners, the box is somewhat hidden.

  • @小柴亮威
    @小柴亮威 3 หลายเดือนก่อน

    Thanks for this great video! I get it how to draggable object!

  • @toshitsingh7270
    @toshitsingh7270 ปีที่แล้ว

    Thanks a lot, you explained everything perfectly ❤

  • @hector4like6gorilla
    @hector4like6gorilla ปีที่แล้ว +1

    thanks man!! you rock!

  • @mohammadjavadaghazadehfard7873
    @mohammadjavadaghazadehfard7873 ปีที่แล้ว

    Thanks, It was very cool.🌹 please make more videos like this. Good luck. 🙏

    • @diveindev
      @diveindev  ปีที่แล้ว

      Happy to hear that it helped 😀

  • @sangyoon9012
    @sangyoon9012 ปีที่แล้ว +1

    fantastic!!!

  • @thuannguyenvan5710
    @thuannguyenvan5710 10 หลายเดือนก่อน

    Nice video . Now I just want it to move along the Y axis, what should I do?

  • @Nagship
    @Nagship 3 หลายเดือนก่อน

    Can I apply position fixed inside this

  • @salvation6153
    @salvation6153 11 หลายเดือนก่อน

    great content, thank you )

  • @netsaosa4973
    @netsaosa4973 ปีที่แล้ว +1

    Thanks bro

  • @barmannphoto
    @barmannphoto 11 หลายเดือนก่อน

    Thank you! Curious why you used refs instead of React state to store the coordinates. Is there an advantage to this approach over using useState?

  • @springwind98
    @springwind98 ปีที่แล้ว

    Hi, great work! What approach would you chose if we want to make an array of component draggable?

  • @EricTsai-rj9vm
    @EricTsai-rj9vm ปีที่แล้ว

    thanks a lot

  • @merunus8556
    @merunus8556 2 ปีที่แล้ว

    Great tutorial, even though part with math calculations was a bit confisuing for me

    • @diveindev
      @diveindev  ปีที่แล้ว

      Hey! Thanks for the feedback, I will try make a similar case and give a bit more details behind the computations.

  • @fi1ipovv28
    @fi1ipovv28 ปีที่แล้ว

    Дякую! Цікаво скільки в тебе досвіду щоб так спокійно писати той код)

  • @a89529294
    @a89529294 ปีที่แล้ว

    🤴🤴