Skip to content

Instantly share code, notes, and snippets.

View VinceVachon's full-sized avatar
🏠
Working from home

Vincent Vachon VinceVachon

🏠
Working from home
View GitHub Profile
@VinceVachon
VinceVachon / scrollToFixedPos
Created November 24, 2016 16:07
Fix an element on scroll until it reach a certain position in the page
function scrollToFixedPos() {
// containter to fix to and element to scroll
const $refElToFixTo = $('.ref-el-to-fix-to');
const $elToFix = $('.el-to-fix')
//$padding is 15% of window height to adapt the placement of the scrolling element
const $wHeight = $(window).innerHeight();
const $padding = $wHeight * 15 / 100;
@VinceVachon
VinceVachon / Mouse move parallax
Last active November 15, 2016 15:43
move element following mouse move based on center of the screen
// move element following mouse move based on center of the screen
const $elToMove = $('.element');
function mouseMoveAnim() {
let mouseFromCenterX = 0;
let mouseFromCenterY = 0;
let divMovX = 0;
let divMovY = 0;
let windowW = 0;