Skip to content

Instantly share code, notes, and snippets.

View j-quelly's full-sized avatar

Jamie Kelly j-quelly

View GitHub Profile
@j-quelly
j-quelly / scrollTo.js
Last active February 5, 2016 01:44 — forked from james2doyle/scrollTo.js
a native scrollTo function in javascript that uses requestAnimationFrame and easing for animation
// get element Y position
function elmYPosition(eID) {
var elm = document.getElementById(eID),
y = elm.offsetTop - 65,
node = elm;
while (node.offsetParent && node.offsetParent != document.body) {
node = node.offsetParent;
y += node.offsetTop;
}
return y;