Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

We're moving the community! Starting July 7, the current community will be read-only for approx. 2 weeks. You can browse content, but posting will be temporarily unavailable. Learn more

Scrolling to the top of an open accordion on title click

Scrolling to the top of an open accordion on title click

ChrisSV613
Shopify Partner
2 0 0

Hey there,

I want to be able to scroll to the top of an open accordion on title click below is the block from  the Broadcast theme we are using, is this possible?

      <div class="accordion_wrapper" data-section-id="{{ section.id }}" data-section-type="faq" data-aos="hero" data-aos-anchor="{{ animation_anchor }}" data-aos-order="{{forloop.index}}" {{ block.shopify_attributes }}>     
        {%- for block in section.blocks -%}                      
        {%- assign title = block.settings.title -%}
        {%- assign text = block.settings.text -%}
        {%- if title != blank and text != blank -%}        
        <div class="accordion" data-accordion>
          <h4 class="accordion__title standard__rte font--3" data-focus-element tabindex="0" data-accordion-toggle data-block-id="{{ block.id }}-{{forloop.index}}">
            <i class="fa fa-regular fa-square-plus"></i>
            <i class="fa fa-regular fa-square-minus"></i>
            {{ title }}
          </h4>
          <div class="rte accordion__body standard__rte  font--3" data-accordion-body>{{ text }}</div>
        </div>
        {%- endif -%}
        {%- endfor -%}            
      </div>

 So that when I am clicking on an H4 Title it should scroll to the active accordion div

Replies 0 (0)