meta_pixel
Tapesearch Logo
Log in
Syntax - Tasty Web Development Treats

Hasty Treat - JavaScript’s Drag and Drop API

Syntax - Tasty Web Development Treats

Wes Bos

Tech News, News, Technology

4.91.2K Ratings

🗓️ 24 May 2021

⏱️ 29 minutes

🧾️ Download transcript

Summary

In this Hasty Treat, Scott and Wes talk about JavaScript’s drag and drop API — how it works, concerns, best practices, and more! .TECH Domains - Sponsor .TECH is taking the tech industry by storm. A domain that shows the world what you are all about! If you’re looking for a domain name for your startup, portfolio, or your own project like we did with uses.tech, check out .tech Domains. Syntax listeners can snap their .TECH Domains at 80% off on five-year registration by visiting go.tech/syntaxistech and using the coupon code “syntax5”. Sentry - Sponsor If you want to know what’s happening with your code, track errors and monitor performance with Sentry. Sentry’s Application Monitoring platform helps developers see performance issues, fix errors faster, and optimize their code health. Cut your time on error resolution from hours to minutes. It works with any language and integrates with dozens of other services. Syntax listeners new to Sentry can get two months for free by visiting Sentry.io and using the coupon code TASTYTREAT during sign up. Show Notes 04:45 - What is it? Drag and drop is really for desktop apps You can drag and drop anything from any browser to any browser The important thing here is that this is a set of browser standards that allow different apps to communicate 07:50 - How to implement Make an element draggable Listen on elements for drag events The events bubble up, so you can listen on the parent element as items are added/removed 09:06 - DataTransfer API You can store anything you want in it getData / setData API Reference strings 11:35 - Accepting drops When you dragOver, you need to preventDefault() Calling the preventDefault() method during both a dragEnter and dragOver event will indicate that a drop is allowed at that location 13:01 - Drop Image Set whatever you want 16:00 - Drop Effect What does it look like when you drop it? Does it go back? dataTransfer.effectAllowed e.dataTransfer.setDragImage(nothing, 0, 0); 18:02 - Security concerns 20:34 - Shortcomings: Edge cases out the WAZOO Margin caused dragout events Lots of if statements It’s up to you to do EVERYTHING CSS, classes, hover styles, etc. Accessibility Inaccessible by default, unless using mouse keys Have to announce everything Mobile 26:14 - Lbs Transmat API Links Figma Notion Missive Tweet us your tasty treats! Scott’s Instagram LevelUpTutorials Instagram Wes’ Instagram Wes’ Twitter Wes’ Facebook Scott’s Twitter Make sure to include @SyntaxFM in your tweets

Transcript

Click on a timestamp to play from that location

0:00.0

Monday Monday Monday open wide dev fans get ready to stuff your face with javascript CSS node module barbecue tips get work flows break dancing soft skills web development the hastiest the

0:13.5

Carrazius the tastiest web development treats coming in hot. Here is West

0:19.2

Barracuda boss and Scott L. Toro Lungo to Linsky

0:25.2

Welcome to syntax on this Monday hasty treat. We're going to be talking about

0:31.7

Javascripts a drag and drop API. Now this is something that West has done quite a bit of a deep dive into very recently and I myself

0:39.2

Am pretty unfamiliar beyond writing some tools using just like frame or motion those types of things in Javascript and react

0:47.2

So we're going to be talking all about the drag and drop API built into Javascript. My name is Scott Linsky

0:52.7

I'm a developer for Denver Colorado and with me as always is West. Hey, Mr. Dragon himself. Mr. Dragon is at your new nickname. Are you Mr. Dragon?

1:02.7

We should have like a comedy duo and

1:06.2

I would be dragon and you'd be dropped. Oh dragon and we'd be like like slapstick comedy. Yeah, it's got going around doing tours

1:15.7

And drop makes sense for me because I can drop to the ground and hit hit some dance moves, but I also drop things pretty regularly because I'm clumsy

1:24.7

This is a funny story one time I got kicked out of a

1:28.7

He kicked out of a club for being drunk when I had not had anything to drink because I dropped my license when the guy asked for it

1:36.2

He's like you you're out of here you're hammered and I was like I'm totally sober, man. He's like no, but I've been watching you. I'm like I'm just clumsy

1:43.7

I'm just goofy like you got a you're gonna

1:46.7

Analyze me for being goofy

1:48.7

That's a rough. Yeah

1:51.1

Well, let's talk about dragging and dropping, but before we do so let's take some time to talk about our sponsors and thank them

1:56.9

One of my sponsors today is century at century.io

1:59.9

They have for you today a coupon code of tasty treat all over case all one word where you'll get two months for free of century

2:05.7

Now, this is a service that we've been using for a very long time and one of the best features that we use in it

2:11.0

It's the performance tracking metrics so that we can see very clearly how each deploy that we've done has positively impacted our page loading times

...

Please login to see the full transcript.

Disclaimer: The podcast and artwork embedded on this page are from Wes Bos, and are the property of its owner and not affiliated with or endorsed by Tapesearch.

Generated transcripts are the property of Wes Bos and are distributed freely under the Fair Use doctrine. Transcripts generated by Tapesearch are not guaranteed to be accurate.

Copyright © Tapesearch 2026.