$(document).ready(function() {
var isModalShown = false;
$(document).bind('touchstart scroll', function() {
if ($(this).scrollTop() >= 400 && !isModalShown) {
$('#myModal').modal('show');
isModalShown = true;
}
});
function reposition() {
var modal = $(this),
dialog = modal.find('.modal-content');
modal.css('display', 'block');
dialog.css("margin-top", Math.max(0, ($(window).height() - dialog.height()) / 2));
}
$('.modal').on('show.bs.modal', reposition);
var closeBtn = $('#myModal .close');
closeBtn.on('click', function() {
$('#myModal').modal('hide');
});
$(window).on('resize', function() {
$('.modal:visible').each(reposition);
});
});
I have tried touchmove instead of touchstart but it also not working , I want to show a modal after user scrolls to 400px.