Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Smooth scroll behavior broken with Chrome v102+ #138

Open
romrg opened this issue Jun 7, 2022 · 14 comments
Open

Smooth scroll behavior broken with Chrome v102+ #138

romrg opened this issue Jun 7, 2022 · 14 comments

Comments

@romrg
Copy link

romrg commented Jun 7, 2022

The perfect scrollbar element does not scroll to the expected offset with the 'smooth' behavior with the latest version of Chrome (v102). There is only a 1px change. It was working with previous versions.

See this jsfiddle: https://jsfiddle.net/5svurjg9/15/

@romrg romrg changed the title Smooth scroll behavior broken with Chrome v102 Smooth scroll behavior broken with Chrome v102+ Jun 7, 2022
@NicerDicerPro
Copy link

Any information or workarounds on this yet?
(Using the react wrapped component of this, having the exact same issue tho).

@Rotarepmi
Copy link

Same issue

@hjborger
Copy link

hjborger commented Jul 4, 2022

Same issue here, problem seen in recent version of Chrome and Safari

Problem seems to be in the update-geometry.js
If I disable element.scrollLeft / scrollTop it seems to work again.

  if (i.scrollbarXActive) {
    element.classList.add(cls.state.active('x'));
  } else {
    element.classList.remove(cls.state.active('x'));
    i.scrollbarXWidth = 0;
    i.scrollbarXLeft = 0;
//    element.scrollLeft = i.isRtl === true ? i.contentWidth : 0;
  }

  if (i.scrollbarYActive) {
    element.classList.add(cls.state.active('y'));
  } else {
    element.classList.remove(cls.state.active('y'));
    i.scrollbarYHeight = 0;
    i.scrollbarYTop = 0;
//    element.scrollTop = 0;
  }

@tibineagu
Copy link

tibineagu commented Jul 12, 2022

We've had this issue with chrome 102 as well.

Element.scroll with behaviour: 'smooth' in the options seems to be broken.

@ZeeshanAhmadKhalil
Copy link

ZeeshanAhmadKhalil commented Aug 9, 2022

Getting the same issue when using scroll-behavior: smooth !important; in css and I sus that it's due to the perfect scrollbar.

@ZeeshanAhmadKhalil
Copy link

Same issue here, problem seen in recent version of Chrome and Safari

Problem seems to be in the update-geometry.js If I disable element.scrollLeft / scrollTop it seems to work again.

  if (i.scrollbarXActive) {
    element.classList.add(cls.state.active('x'));
  } else {
    element.classList.remove(cls.state.active('x'));
    i.scrollbarXWidth = 0;
    i.scrollbarXLeft = 0;
//    element.scrollLeft = i.isRtl === true ? i.contentWidth : 0;
  }

  if (i.scrollbarYActive) {
    element.classList.add(cls.state.active('y'));
  } else {
    element.classList.remove(cls.state.active('y'));
    i.scrollbarYHeight = 0;
    i.scrollbarYTop = 0;
//    element.scrollTop = 0;
  }

Commented these two lines but getting the exact same issue.

@Marme7ad
Copy link

Marme7ad commented Sep 2, 2022

Same issue

@NicerDicerPro
Copy link

Any update on this?

1 similar comment
@zeffon
Copy link

zeffon commented Jun 28, 2023

Any update on this?

@danny-dang
Copy link

Pump!!

@Youhan
Copy link

Youhan commented Aug 12, 2023

I have the same issue using Chrome 115

@DominikGanic
Copy link

Any updates? Still broken.

@EliseiNicolae
Copy link

I had the same issue.

As a workaround I've used some js to make that smooth transition:

    scrollBy (offsetX, offsetY, duration = 0) {
      const startTime = performance.now()
      const startX = this.$el.scrollLeft
      const startY = this.$el.scrollTop

      if (duration === 0) {
        // Immediate jump to the new position
        this.$el.scrollLeft = startX + offsetX
        this.$el.scrollTop = startY + offsetY
        this.ps.update()
        return
      }

      const animateScroll = () => {
        const elapsedTime = performance.now() - startTime
        const fraction = Math.min(elapsedTime / duration, 1)
        const easeOutQuad = t => t * (2 - t)
        const fractionEased = easeOutQuad(fraction)

        const newScrollX = startX + fractionEased * offsetX
        const newScrollY = startY + fractionEased * offsetY

        this.$el.scrollLeft = newScrollX
        this.$el.scrollTop = newScrollY
        this.ps.update()

        if (fraction < 1) {
          requestAnimationFrame(animateScroll)
        } else {
          // Ensure final scroll position is set correctly
          this.$el.scrollLeft = startX + offsetX
          this.$el.scrollTop = startY + offsetY
          this.ps.update()
        }
      }

      requestAnimationFrame(animateScroll)
    },

where ps is:

this.ps = new PerfectScrollbar(this.$el, this.$props.options)

Hope this helps 🚀

@plashenkov
Copy link

Perfect scrollbar isn't perfect as it turned out 😂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests