Thursday, February 2, 2017

API to the rescue

I love when I am trying to solve a problem and find out that the problem has already been solved.

Today I was trying to place a cursor into an Element but I was having an issue when the Element was scrolled off the page.

So I created a function `function scrollIntoView(element) { ... }` and I decided to see if anyone else had a solution for this.

It turns out the Element class has a function called ... wait for it ... Element.scrollIntoView

And it is supported by every browsers!!!

I must have done something great for this kind of karma.

Monday, May 16, 2016

Idempotence

Something that returns the same result when run multiple times as it does when run once on any input.

http://www.restapitutorial.com/lessons/idempotency.html

Sunday, October 18, 2015

punctuation on left when direction: rtl

When using direction: rtl the puctuation is on the left instead of the right.
http://stackoverflow.com/a/20799360/806777

<div style='direction: rtl;'>Hi!</div>

!Hi

Tuesday, June 9, 2015

Tab to Search

http://www.opensearch.org/

calculate height of a truncated element in JS

http://stackoverflow.com/a/12752716/806777

...
// get current height
currentHeight = $box.height();

// get height with auto applied
autoHeight = $box.css('height', 'auto').height();

// reset height and revert to original if current and auto are equal
$box.css('height', currentHeight);
...