[SOLVED] How accordion scroll to top of active (open) accordion on click?

I wanted it when I opened the accordion it would roll along the toolbar.
Ex 1: Accordion closed


Ex 2: Accordion open when clicked, but does not roll content to the top


Ex 3: Accordion as it would be


Here is the fiddle I put together to exemplify
Accordion scroll test

Something like this https://jsfiddle.net/9s0ub16e/

1 Like

Great, this was what I was needing, it was not firing my accordionOpened event, due to having withdrawn the

transition-duration: 300ms;

had put

transition-duration: 0s;

But I got seven with 10ms and it works 100% now.

Thanks @nolimits4web


This is something I need.
Is there a way to do this in svelte?


I was able to adapt it with svelte. (Still learning).

f7.on('accordionOpened', (el) => {
  const openedItem = el;
  const offset = d7(openedItem).offset().top;
  const navHeight = 56;
  const toolbarHeight = 48;
  const scrollTop = d7(el).parents('.page-content').scrollTop();
  d7(el).parents('.page-content').scrollTop((offset - navHeight - toolbarHeight + scrollTop), 300);