Skip to content

Instantly share code, notes, and snippets.

@iamklim
iamklim / togglePopup.js
Created May 13, 2019
Show popup without overflow:hidden, page jumping and toggling
View togglePopup.js
function togglePopup() {
var scrollPosition;
$(document).on("click", '[data-id="show-popup"]', function(e) {
e.preventDefault();
var popup = '[data-id="popup"]';
scrollPosition = $('body').scrollTop() === 0
View Simple parallax without empty spaces on background
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