Spying on a Chinese Spy Balloon / / No Comments Thanks to some impressive detective work the New York Times has worked out the provenance of the notorious Chinese spy balloon which enraged many Americans back in February. In Tracking the Chinese Spy Balloon From Space you can follow the path the balloon took on an interactive map, as it journeyed from China, across the Pacific Ocean and across the United States during January and February of Maps Mania… more → Posted in: Interactive Maps Tagged with: balloon, Chinese, Spying
How to Control CSS Animations with JavaScript / / No Comments When it comes to animations on the web, developers need to measure the animation’s requirements with the right technology — CSS or JavaScript. Many animations are manageable with CSS but JavaScript will always provide more control. With document.getAnimations, however, you can use JavaScript to manage CSS animations! The document.getAnimations method returns an array of CSSAnimation objects. CSSAnimation provides a host of information about the animation: playState, timeline, effect, and events like onfinish. You can then modify those objects to adjust animations: // Make all CSS animations on the page twice as fast document.getAnimations().forEach((animation) ={ animation.playbackRate... more → Posted in: JavaScript Tagged with: animations, Control, JavaScript
JavaScript print Events / / No Comments Media queries provide a great way to programmatically change behavior depending on viewing state. We can target styles to device, pixel ratio, screen size, and even print. That said, it’s also nice to have JavaScript events that also allow us to change behavior. Did you know you’re provided events both before and after printing? I’ve always used @media print in stylesheets to control print display, but JavaScript provides beforeprint and afterprint events: function toggleImages(hide = false) { document.querySelectorAll('img').forEach(img ={ img.style.display = hide ? 'none' : ''; }); } // Hide images to save toner/ink during printing window.addEventListener('beforeprint',... more → Posted in: JavaScript Tagged with: events, JavaScript, print
What do you call an American with a Brain? / / No Comments Q: What do you call a person from Maine with a brain?A: A Maineiac.Q: What do you call a person from California with a brain?A: Lost!Q: What do you call a person from Arkansas with a brain?A: A Yo’allI asked the Stanford Alpaca AI what you would call a resident of each US ‘with a brain’. I was hoping for some good ‘dad joke’ type answers. For example I asked Alpaca “What do you call a Texan Maps Mania… more → Posted in: Interactive Maps Tagged with: American, Brain, call
Detect Browser Bars Visibility with JavaScript / / No Comments It’s one thing to know about what’s in the browser document, it’s another to have insight as to the user’s browser itself. We’ve gotten past detecting which browser the user is using, and we’re now into knowing what pieces of the browser UI users are seeing. Browsers provide window.personalbar, window.locationbar, and window.menubar properties, with the shape of { visible : /*boolean*/} as its value: if(window.personalbar.visible || window.locationbar.visible || window.menubar.visible) { console.log("Please hide your personal, location, and menubar for maximum screen space"); } What would you use these properties for? Maybe providing a warning to users... more → Posted in: JavaScript Tagged with: Bars, browser, Detect, JavaScript, visibility
The City of Women Subway Map / / No Comments Barcelona, like New York and London, now has a reimagined subway map designed to celebrate and recognise the lives of some of the city’s most remarkable women. The Barcelona City of Women subway map highlights the extraordinary contribution of women to the Catalan capital. On the Ciutat de Dones map every station on Barcelona’s metro network and all the stops on the city’s railway network has Maps Mania… more → Posted in: Interactive Maps Tagged with: City, Subway, Women
Detect the Content Type in the Clipboard / / No Comments A user’s clipboard is a “catch all” between the operating system and the apps employed on it. When you use a web browser, you can highlight text or right-click an image and select “Copy Image”. That made me think about how developers can detect what is in the clipboard. You can retrieve the contents of the user’s clipboard using the navigator.clipboard API. This API requires user permission as the clipboard could contain sensitive data. You can employ the following JavaScript to get permission to use the clipboard API: const result = await navigator.permissions.query({name: "clipboard-write"}); if (result.state === "granted" || result.state === "prompt") {... more → Posted in: JavaScript Tagged with: Clipboard, Content, Detect, type
The Map of Home Heating / / No Comments The Washington Post has been exploring how Americans heat their homes. Their are four main energy sources used by Americans to heat their homes: electricity, natural gas, propane and fuel oil. Which one is used is mainly determined by geographical and historical reasons.In How Americans Heat Their Homes the Post has produced a map which shows that fuel oil (in red) is the most used source of home Maps Mania… more → Posted in: Interactive Maps Tagged with: Heating, home