• Hi,

    I have set pagination individually for each question of the quiz (but not globally). For some reason though, each time I click the “Next” button to go to the next question, the page automatically scrolls down. It’s as if there is a CSS anchor tag on each “Next” button in the quiz, and when I click on it, it takes me straight to that tag (the next button)- which is below the quiz questions, so I need to scroll up in order to see the questions each time.

    Thank You

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

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Harmonic Design

    (@harmonic_design)

    Hi Sim,
    thanks for creating this as a new thread and providing a link.

    The main issue here is that you have a sticky header. Because of this, it’s impossible to automatically calculate where the page should scroll to so that the header does not overlap it. Different sites have different headers and different sizes using different HTML and CSS etc.

    Luckily, there is a workaround. Some extra info below in case anyone else is interested in how this all works.

    The default scrolling hands all of the grunt work to the browser. Essentially we say “hey browser. Here is the next question, make sure it is visible in the window” and the browser does the rest. This is super lightweight and works 99% of the time.

    The old scrolling is called “Legacy Scrolling” and is the original method HD Quiz used to try and figure out where to scroll to. This method attempts to do all of the calculations ourselves and it is a nightmare to support and maintain (some themes scroll the body – as they should, and some degenerates have custom divs that scroll the main content). However, it is useful since we can define a custom “offset” to compensate for a large sticky header.

    The solution:
    First, enable Legacy Scrolling in the About / Options page. By default, this method sets a custom offset of 40px which is fine for the majority of users – but you have a large header. So we need to make a small change to HD Quiz to change this offset to something larger.

    (let me know if you have trouble with the following)

    Go to plugins -> plugin editor. On the top right is a dropdown where you can select HD Quiz. On the right sidebar, open the includes folder, then js, and finally open hdq_script.js. You are now editing the main script file!

    Scroll down to line 879 and you will see

    scrollTop: jQuery(".hdq_question:visible").offset().top - 40,

    change that 40 to something larger. Looking at your site, I think 110 should be a good number. Save and then make sure to clear your browser cache!

    Thread Starter Simcha Hochman

    (@sim183)

    You’re AMAZING! It worked like a charm. Thank you for your quick response, and thank you for being so clear in how to fix the issue.

    Thanks,
    Sim

    Plugin Author Harmonic Design

    (@harmonic_design)

    Excellet! Glad we were able to sort this out for you. If it’s not too much trouble, I’d appreciate it if you could leave a review for HD Quiz. No worries if you can’t though and let me know if you need help with anything moving forward.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Page auto scrolls down after clicking the Next button’ is closed to new replies.