Created
November 27, 2016 21:54
-
-
Save mtairu/2e8a72f7d11299f90a28b81b1fdfc075 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
<script> | |
// Popup Window | |
var scrollTop = ''; | |
var newHeight = '100'; | |
$(window).bind('scroll', function() { | |
scrollTop = $( window ).scrollTop(); | |
newHeight = scrollTop + 100; | |
}); | |
$('.popup-trigger').click(function(e) { | |
e.stopPropagation(); | |
if(jQuery(window).width() < 767) { | |
$(this).after( $(this).nextAll('.popup:first') ); | |
$(this).nextAll('.popup:first').show().addClass('popup-mobile').css('top', 0); | |
$('html, body').animate({ | |
scrollTop: $(this).nextAll('.popup:first').offset().top | |
}, 500); | |
} else { | |
$('.popup').hide(); | |
$(this).nextAll('.popup:first').removeClass('popup-mobile').css('top', newHeight).toggle(); | |
}; | |
}); | |
$('html').click(function() { | |
$('.popup').hide(); | |
}); | |
$('.popup-btn-close').click(function(e){ | |
$(this).parent().hide(); | |
}); | |
$('.popup').click(function(e){ | |
e.stopPropagation(); | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment