• Resolved ferdistam

    (@ferdistam)


    I have made a paginated quiz on a test website and it isn’t quite working as I’d like to. Each time I press next or previous button during the quiz, the page scrolls a bit down so that the question aligns at the top of the page, which is mildly infuriating and doesn’t make a nice experience while taking the quiz. I’d like the page to stop scrolling when pressing a buton.

    The page I need help with: [log in to see the link]

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Support Dmytro – WPMU DEV Support

    (@wpmudevsupport16)

    Hello @ferdistam,

    I hope you’re doing great today!

    In order to disable auto-scrolling, please add the following PHP snippet as a must use plugin:

    <?php
    add_action('wp_footer', 'wpmudev_quiz_scroll_quest_fix', 9999);
    function wpmudev_quiz_scroll_quest_fix() {
    	global $post;
    	if ( is_a( $post, 'WP_Post' ) && !has_shortcode($post->post_content, 'forminator_quiz') ) {
    		return;
    	}
    	?>
             <script type="text/javascript">
             jQuery(document).ready(function($){
                setTimeout(function() {
                    $('.forminator-quiz').trigger('after.load.forminator');
                },100);
    
                $(document).on('after.load.forminator', function( e, formID ) {
                    var form_id = e.target.id;
                    jQuery('#'+form_id).find('.forminator-quiz-start').on('click', function(){
                        setTimeout(function(){
                            jQuery("html, body").stop();
                        },10);
                    });
                });
    
                jQuery( document ).on('forminator.front.pagination.move', function( e ) {
                    setTimeout(function(){
                        jQuery("html, body").stop();
                    },10);
                });
        });
        </script>
        <?php
    }

    – paste the code in your text editor, and save as a PHP file, for instance “forminator-quiz-scroll-fix.php”. Upload the saved file to /wp-content/mu-plugins/ directory on the server, and test the quiz again after refreshing the page.

    I hope this helps. Please let us know if you have any questions.

    Best Regards,
    Dmytro

    Thread Starter ferdistam

    (@ferdistam)

    Awesome. Thank you very much Dmytro. It worked!

Viewing 2 replies - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.