wait-till-i.com wait-till-i.com

Quick solution: getting the mouse position on an element regardless of positioning

As I was upgrading an older codebase of mine that used layerX and layerY I looked into a very succinct way of finding the current mouse position on any element regardless of its position, scrolling, padding, margin and such and I found this to work for me, so maybe it is good for you, too. const getposition = ev => { let x = ev.clientX; let y = ev.clientY; let pos = ev.target.getBoundingClientRect(); // the bitwise shift |0 rounds...

wait-till-i.com wait-till-i.com

Fun with browsers: how to get an image into the current page

Having been a web developer for as long as I have can get you tainted. You always assume things to break in one way or another or some clever new web API not getting the support it needs for ages. As it turns out, the speed with which browsers adapt to standards has become increasingly faster. That’s why it is important to keep up to date and give yourself simple challenges to see if tasks that in the past were a huge hassle have now...

wait-till-i.com wait-till-i.com

JavaScript Jabber Podcast episode “Edge on Chromium”

Devchat.tv today released the 404th episode of “JavaScript Jabber”, a podcast where a panel of experts asks guests about a certain topic. In this episode (which can be found, despite the number), they had Zoher Ghadyali and me as their guests and we answered lots of questions about the move of Edge to Chromium and what that means for developers. You can read the notes and listen to the podcast on their web site or listen to it...

wait-till-i.com wait-till-i.com

“Tweet this page” bookmarklet

I like tweeting about pages I read in the following format: "Headline" https://example.com Most “share this” buttons add a lot of cruft and if there is none, it is annoying having to copy the text first and then the URL into Twitter. With this bookmarklet, you can highlight some text, click the bookmarklet and get a tweet window in a new tab: javascript:(function(){ n = getSelection().anchorNode; t = n.nodeType = 3 ?...