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.