Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Update occupant style for desired effect
- occupants.forEach(function(occupant, index) {
- $(occupant).css({'right' : -10 * nudgeSine(occupantsMouseOffset[index] * 10) + 'px',
- 'top' : -10 * Math.abs(nudgeSine(occupantsMouseOffset[index] * 10)) + 'px',
- 'opacity' : 1 - Math.abs(nudgeSine(occupantsMouseOffset[index])) });
- });
- // Function to return 1 period of a sine wave
- function nudgeSine(x) {
- if (x < -3.14159 || x > 3.14159) {
- return 0;
- } else {
- return Math.sin(x);
- }
- }
Add Comment
Please, Sign In to add comment