0
$(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.

Raj Dave
  • 1
  • 1
  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. – Community May 02 '23 at 14:56

0 Answers0