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.78k stars 214 forks source link

Unexpected behavior with height transition on the handle #587

Closed matusbossak closed 9 months ago

matusbossak commented 10 months ago

Describe the bug The bug only occurs when a height transition is applied to the handle element, as shown in the videos below. The handle functions properly when the height transition is not used. Other transitions, such as opacity or background-color, don't seem to trigger this bug.

E.g.:

.os-scrollbar-handle {
    transition: opacity 0.5s ease, background-color 0.5s, height 0.5s ease;
}

OverlayScrollbar code:

const { OverlayScrollbars, ClickScrollPlugin } = OverlayScrollbarsGlobal;
OverlayScrollbars.plugin(ClickScrollPlugin);
OverlayScrollbars(document.querySelector(element), {
  update: {
    elementEvents: [['*', "transitionstart transitionend"]],
  },
  overflow: {
    x: "hidden",
  },
  scrollbars: {
    autoHide: "leave",
    autoHideDelay: 1000,
    clickScroll: true,
  },
});

Element that is expanding in the videos below is using CSS grid-template-rows (value being changed: 0 -> 1 and vice-versa) transition.

Examples With the height transition: https://github.com/KingSora/OverlayScrollbars/assets/126194708/4e4243d1-b84b-42de-b24d-3849355771ba

Without the height transition: https://github.com/KingSora/OverlayScrollbars/assets/126194708/049b773f-86a9-4e04-88ad-42a190291557

Environment

Thanks.

KingSora commented 10 months ago

Good day @matusbossak :)

That happens because the handle size calculation is sometimes dependent on the handle and track elements. Because of the transition the handle size is not instantly the correct value you also get an incorrect result for the calculated values.

I'll fix this behavior in the next release which should come soon

matusbossak commented 10 months ago

Hello,

thank you for your prompt response; it certainly makes perfect sense. I appreciate it! :)

KingSora commented 10 months ago

@matusbossak I'm having a bit of a problem here...

You see, its possible to set the min-height and max-height of the scrollbar handle via CSS and it will be respected when calculating the final values. This behavior is intended and will be supported going forward. The problem here is that this is the exact reason why I'm measuring the scrollbar handle and track.

So to be honest I'm not very sure about how to solve this case right now - Do you have any idea?

matusbossak commented 10 months ago

@matusbossak I'm having a bit of a problem here...

You see, its possible to set the min-height and max-height of the scrollbar handle via CSS and it will be respected when calculating the final values. This behavior is intended and will be supported going forward. The problem here is that this is the exact reason why I'm measuring the scrollbar handle and track.

So to be honest I'm not very sure about how to solve this case right now - Do you have any idea?

I sent you an e-mail.

KingSora commented 10 months ago

@matusbossak I've replied yesterday but I got an notification today that my answer mail couldn't be delivered to you because it was rejected by your email provider.

I've now replied again, but it will probably fail again..

KingSora commented 10 months ago

@matusbossak I believe I've found a suitable solution :)

It will be included in the next release

KingSora commented 9 months ago

@matusbossak I've released v2.4.5 which should fix this issue :)

matusbossak commented 9 months ago

I confirm that the behavior has been fixed! 👍🏻