Issue #351 (dataTransfer, JS Utilities, Media, Uncats)
Last week I covered a really simple introduction to the HTML Drag and Drop API, for those of you who have never used it before. The demo has the minimum code required to produce a drag and drop example. Let's take that a little further and incorporate the dataTransfer object, which has methods and properties that can be used in the midst of a drag and drop operation.
First, I can use the setData() method of the dataTransfer object, which I'll incorporate in the midst of my event listener when listening for a dragstart event (an event I didn't need to use in the previous demo). The relevant line looks something like this (where "e" is the event object):
As you can see, the setData() method takes two arguments: The data type and the data itself. In this case, the data is simply the innerHTML of the dragged element. This is the first step in transferring data: Setting the data, which happens when the element is initially dragged.
The next key line in my code will be using the getData() method. In this case, I'll use it when the drop event is triggered on my drop area element:
this.style.background = e.dataTransfer.getData('text/html')
The data that I'll be grabbing is text that represents a valid CSS color keyword, which will be inside each draggable element. The data could be a lot of things, but in this case I'm just using some text for demo purposes. And as you can see, the text sets the background color of the drop area element.
See the full working demo here
There's naturally a lot more code there, but it's fairly straightforward. I'm looping over the draggable boxes to add the event listeners to each one. The setData() and getData() methods are used within that loop to obtain and apply the color info.
Try dragging any of the boxes into the drop area to see the background of the drop area change. You can even try changing the HTML to use different colors (any valid CSS color value will work). As long as the color is valid, the background of the drop area element will change to that color.
And that's a basic way to use the dataTransfer object when working with the Drag and Drop API.
Now on to this week's tools!
Working From Home? Try Team.Video
Team.video makes it easier and faster for remote teams to work together by offering user friendly video meetings with agendas, collaborative notes, and emoji responses. No download required and it’s free to use. via Syndicate
Bit of an older project that I just discovered. A collection of customizable, accessible scripts for rich interface elements, built using progressive enhancement.
A simple progress bar with promises support.
Simple overlay instructions for your apps. Kind of like those 'app tour' plugins, but just a single overlay pointing stuff out.
Utility to recursively assign default properties.
A modern keyboard shortcut library written in Typescript.
Media Tools (SVG, Video, Audio, etc.)
The master package includes 88 HD videos, part of 15 modules – and course updates are free forever. promoted
Cutting-edge WebRTC video conferencing. The perfect choice for building multi-party video conferencing and real-time streaming apps.
Create animated GIFs in your browser from a screen recording. Client-side only, no data is uploaded.
A set of over 400 free MIT-licensed high-quality SVG icons for you to use in your web projects. Each icon is designed on a 24x24 grid and a 2px stroke.
Using a markdown file, create a video (with captions) from a chosen set of images, audio files and smaller video clips.
Seamless Pattern Generator
Create seamless, repeatable royalty free patterns for your website, or to download as SVG, JPEG or PNG.
Produce a podcast simply by typing the content and this app will convert it to speech.
Easily create 3D web experiences without coding. Build and iterate fast with production-ready results.
Self-hosted, super simple photo stream. Built with Ruby and seems to require either Netlify or Jekyll.
Premium designed icons for use in web, iOS, Android, and desktop apps. Support for SVG and web font.
Advanced React & GraphQL by Wes Bos is 50% Off!
The master package includes 68 HD videos, part of 10 modules – and course updates are free forever. promoted
Desktop application to efficiently search large packet captures and logs from Zeek (the network security monitoring tool).
Produces brandable ideas for domain names in a Twitter stream, based on actual domains that are for sale.
Chrome extension to help you research search volume, advertising cost per click, and related keywords inside Google search results – free and on-demand.
Add a PDF.js viewer with out-of-the-box annotation, PDF form fill, and signing. Based on Mozilla's PDF.js (for parsing and rendering PDFs).
Open source tools to easily build and maintain your event-driven architecture. All powered by the AsyncAPI specification, the industry standard for defining asynchronous APIs.
Allows you to make your website multilingual in minutes and to manage all your translations effortlessly.
Our Site Updates
An easy way to post updates to your website (e.g. via easy to install banners) and keep visitors informed.
An innovative, beautiful and professional font manager app for Mac, helping designers preview, install, sync, and manage their font files.
Remote user interviews and user tests made simple.
Extract Article Text
Lets you easily extract boilerplate-free text from news articles, blogs, press releases, and company pages with a single API request.
Drop‑in e‑commerce for any website with a single line of code. Serverless, real‑time, and API‑first.
A Tweet for Thought
When you're living in a tech bubble like many of us are, it's hard to believe there are people this naive
Send Me Your Tools!
Made something? Send links via Direct Message on Twitter @WebToolsWeekly (details here). No tutorials or articles, please. If you have any suggestions for improvement or corrections, feel free to reply to this email.
Before I Go...
This is amazing: Open and Shut lets you send messages in Morse code by repeatedly slamming your laptop shut. So if you've been kidnapped and forced to give up all your passwords or something...?
Thanks to all for subscribing and reading!