|
|
|
|
|
by iamben
479 days ago
|
|
Haha, this is great fun. Scratching my own itch and making him turnaround when you scroll up: /* Add style */
#scrollBuddy.walkUp {
transform: rotate(-90deg) scaleX(-1);
}
/* Amend script */
var lastTop = 0;
function updateBuddyVerticalPosition(scrollPosition) {
// All as before but add the below before requestAnimationFrame
if (lastTop <= newTop && buddy.classList.contains('walkUp')) {
buddy.classList.remove('walkUp')
} else if (lastTop > newTop) {
buddy.classList.add('walkUp')
}
lastTop = newTop;
}
|
|