Skip to content

Instantly share code, notes, and snippets.

@mtairu
Created November 27, 2016 21:54
Show Gist options
  • Save mtairu/2e8a72f7d11299f90a28b81b1fdfc075 to your computer and use it in GitHub Desktop.
Save mtairu/2e8a72f7d11299f90a28b81b1fdfc075 to your computer and use it in GitHub Desktop.
<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