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
const throttle = (func, ms) => { | |
let isThrottled = false; | |
return (...args) => { | |
if (!isThrottled) { | |
func(...args); | |
isThrottled = true; | |
setTimeout(() => { |
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
function togglePopup() { | |
var scrollPosition; | |
$(document).on("click", '[data-id="show-popup"]', function(e) { | |
e.preventDefault(); | |
var popup = '[data-id="popup"]'; | |
scrollPosition = $('body').scrollTop() === 0 |
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
function axelerateBackground(bgWrapperHeight) { | |
var $bgWrapper = $('.bg_wrapper'); //parallax block inside body with position fixed and css background | |
$(document).on('scroll', function() { | |
var dHeight = $(document).height(), | |
wHeight = $(window).height(), | |
imgHeight = bgWrapperHeight ? bgWrapperHeight : $bgWrapper.height(), //height of parallax block | |
coeff = (imgHeight - wHeight) / (dHeight - wHeight); //coefficient to avoid empty spaces on background | |
var shift = -1 * ($(window).scrollTop() * coeff); //size of shift on the top |