Autoscroll jumping to wrong part of page

Hi!
I was wondering if anyone else has the issue where when a client selects the time for a booking, the page scrolls down too far. So where the client should see the details of the appointment before confirming, it scrolls too far, and only the confirmation button is visible.
Please see:
http://pistachioppc.com/jousi-id/ajanvaraus/
Many thanks in advance!

  • Bojan Radonic
    • Head of Support

    Hey there @gaippa,

    How are you doing today?

    I've check your site and I can see the problem, this should be related to your theme and the way elements are positioned on the page. We should be able to change the position where page lands once you click on time in the calendar.

    I've notified our developer for some help on this one and I'll post here as soon as I get a response :slight_smile:

    Cheers,
    Bojan

  • Bojan Radonic
    • Head of Support

    Hey again,

    A quick follow up :slight_smile:

    Can you please try adding the following to your theme function.php (Ideally you'd want this added in your child theme functions.php or as a mu-plugin so you can avoid losing the changes once you update the theme):

    function confirmation_position_change () {
        ?>
    <script>
    ;(function ($) {
    
        function do_stuff () {
            var head_height = $("#main-header").height() || 0,
                my_pos = ($(".appointments-confirmation-wrapper:first").offset() || {}).top || 1,
                scroll_pos = my_pos - (head_height+30)
            ;
            scroll_pos = scroll_pos <= 1 ? 1 : scroll_pos;
            $(window).scrollTop(scroll_pos);
        }
    
        $(document).ajaxSend(function(e, xhr, opts) {
            if (!opts.data) return true;
            if (!opts.data.match(/action=pre_confirmation\b/)) return true;
            xhr.success(do_stuff);
        });
    })(jQuery);
    </script>
        <?php
    }
    add_action('wp_footer', 'confirmation_position_change');

    Hope this helps :slight_smile:

    Cheers,
    Bojan

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.