KingSora / OverlayScrollbars

A javascript scrollbar plugin that hides the native scrollbars, provides custom styleable overlay scrollbars, and preserves the native functionality and feel.
https://kingsora.github.io/OverlayScrollbars
MIT License
3.84k stars 214 forks source link

scollbar not updated while using height transition #585

Closed ducheng1 closed 11 months ago

ducheng1 commented 11 months ago

When I use transition for a container to animate its change on height, the scrollbar just not updated and can't scroll anyway, until another container appears and change the parent element's height.

how this problem occured

image

codes

  <div
    :class="`regular-layout flex flex-col relative
      !collapsed ? 'opened' : ''
    `"
    :style="maxHeight && collapsed ? { height: maxHeight } : {}"
  />
.regular-layout {
  max-width: calc(100% - 32px);
  margin: 16px;
  color: var(--trim-text-color);
  transition: height 0.25s;
  overflow: hidden;
}

.opened {
  height: v-bind(elHeight);
}
KingSora commented 11 months ago

@ducheng1 Good day :)

You have to use the update.elementEvents option for the library to update itself when the transition is finished:

<OverlayScrollbarsComponent
  options={{ 
    update: { 
      elementEvents: [['img', 'load'], ['*', 'transitionend']] 
    } 
  }}
/>

This configuration describes that the plugin will update when an img element dispatched a load event and when any (*) element dispatched the transitionend event.

You can also use this options:

<OverlayScrollbarsComponent
  options={{ 
    update: { 
      elementEvents: [['img', 'load'], ['*', 'transitionstart transitionend']] 
    } 
  }}
/>

To register multiple events to a single selector.

ducheng1 commented 11 months ago

thanks a lot and have a good day😊

KingSora commented 11 months ago

@ducheng1 you're welcome :)