Forked from divimode-philipp/trigger-on-scroll-1.html
Created
September 30, 2022 08:36
-
-
Save stracker-phil/b8ba3cb93ed129ad631b2f9acc1fdf8e to your computer and use it in GitHub Desktop.
JS snippet for Popups for Divi / Divi Areas Pro to trigger a Popup after the user scrolled down to a certain point
This file contains hidden or 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> | |
(function ($) { | |
// TODO: Adjust the following to lines to your needs: | |
var popup = 'contact'; // Your Popup ID. | |
var distance = 500; // Scroll distance [pixel]. | |
$(window).on('scroll.popup_' + popup, function () { | |
// Check if the user scrolled far enough. | |
if ($(window).scrollTop() < distance) { | |
return; | |
} | |
// Remove the custom scroll event, so the Popup is | |
// only displayed once. | |
$(window).off('.popup_' + popup); | |
DiviArea.show(popup); | |
}); | |
})(jQuery); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment