Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

291
Visualizações
Creating a custom Avada form autoscroll script

I'd like to have a autoscroll for our form (made with the Wordpress - Avada theme). When they answered a question, the next question appears underneath, but people don't see this directly in the viewport on mobile, so it should autoscroll.

You can find the form (with image buttons) on https://schadeoplossing.nl

This is what the form looks like

I had it working with the plugin: 'gravity forms'. I used this custom script.. perhaps this is a good start for the new script:

<script>function onNextCollapsibleBtnClick(e) 
{var $sectionBody = jQuery(this).closest('.collapsible-sections-collapsible-body');
if ($sectionBody.length) {$nextSection = $sectionBody.nextAll('.collapsible-sections-field:visible:first');
if ($nextSection.length) 
{// If section isn't open, trigger click to open it
if (!$nextSection.hasClass('collapsible-sections-open')) {$nextSection.trigger('click');

jQuery('body').on('click', '#choice_30_38_0', onNextCollapsibleBtnClick);
jQuery('body').on('click', '#choice_30_38_1', onNextCollapsibleBtnClick);
jQuery('body').on('click', '#choice_30_38_2', onNextCollapsibleBtnClick);
jQuery('body').on('click', '#choice_30_38_3', onNextCollapsibleBtnClick);
jQuery('body').on('click', '#choice_30_38_4', onNextCollapsibleBtnClick);
jQuery('body').on('click', '#choice_30_38_5', onNextCollapsibleBtnClick);
jQuery('body').on('click', '#choice_30_40_0', onNextCollapsibleBtnClick);
jQuery('body').on('click', '#choice_30_40_1', onNextCollapsibleBtnClick);
jQuery('body').on('click', '#choice_30_42_0', onNextCollapsibleBtnClick);
jQuery('body').on('click', '#choice_30_42_1', onNextCollapsibleBtnClick);
jQuery('body').on('click', '#choice_30_51_1', onNextCollapsibleBtnClick);
jQuery('body').on('click', '#choice_30_49_1', onNextCollapsibleBtnClick);
jQuery('body').on('click', '#choice_30_57_0', onNextCollapsibleBtnClick);
jQuery('body').on('click', '#choice_30_64_1', onNextCollapsibleBtnClick);
jQuery('body').on('click', '#volgende', onNextCollapsibleBtnClick);</script>

I know how html works pretty good.. but i don't know anything about scripting, so please be patient with me :-)

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

The function that is called to toggle visibility of an element on your form is window.fusionFormLogics.toggleField(). Therefore an easy way to scroll to an element that is made active is to just override that function with a scrollIntoView() call when an element is shown. We still want to run the original code, so we get this:

var toggleFieldOld=window.fusionFormLogics.toggleField;
window.fusionFormLogics.toggleField=function(o, i) {
  toggleFieldOld(o,i)
  o ? i[0].scrollIntoView({behavior:"smooth", block: "center"}:[]
}

When I tried this on your form it works, but the last block of elements is a bit big and all elements are shown at the same time. This means the toggleField function is called on all of them in sequence and we scroll to the last element that is shown. To fix this we can add a timer that only scrolls to the element if we haven't scrolled in the last 10 ms.

var toggleFieldOld=window.fusionFormLogics.toggleField;
var scrollTimer = 0;
window.fusionFormLogics.toggleField=function(o, i) {
  toggleFieldOld(o,i)
  o && scrollTimer < (Date.now() - 10) ? (
    i[0].scrollIntoView({behavior:"smooth", block: "center"}), 
    scrollTimer = Date.now()
  ):[]
}
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda