Created
December 15, 2015 19:14
-
-
Save mimiflynn/cba18ba79e79dd340a26 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var velocity = function (el, header) { | |
var wWidth = $(window).width(), | |
spacing = $(header).height(), | |
offset = $(el).offset(); | |
// Create consistent velocity! | |
// Perfect velocity = 2550px per 3000milliseconds = .85 you know, since v = d/t | |
var current = window.pageYOffset; | |
// get current position | |
var movement = offset.top - spacing; | |
// set distance for movement from the top minus space for header | |
var distance = current - movement; | |
// get distance from current position | |
distance = Math.abs(distance); | |
// can't use negative numbers | |
var speed = distance / 1.105; | |
// 1.105 is the velocity! | |
return { | |
speed: speed, | |
movement: movement | |
}; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment