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

Previous button go previous twice and not only one time #131

Open
NoetKevin opened this issue Apr 8, 2024 · 0 comments
Open

Previous button go previous twice and not only one time #131

NoetKevin opened this issue Apr 8, 2024 · 0 comments

Comments

@NoetKevin
Copy link

Hi,
There an issue when I click on button previous I go previous twice and not only one time.

I've check the code and the issue is here :
prev(): void {
this.$emit('prev')

  const container = this.$refs.container as Element
  const left = container.getBoundingClientRect().left
  const x = left + (container.clientWidth * -this.displacement) - delta
  const element = this.findPrevSlot(x)

  if (element) {
    const width = element.getBoundingClientRect().left - left
    this.scrollToLeft(container.scrollLeft + width)
    return
  }

  const width = container.clientWidth * this.displacement
  this.scrollToLeft(container.scrollLeft - width)
},

You have to change
if (element) {
const width = element.getBoundingClientRect().left - left
this.scrollToLeft(container.scrollLeft + width)
return
}
by
if (element) {
const width = element.getBoundingClientRect().left - left
if (width > delta) {
this.scrollToLeft(container.scrollLeft + width)
return
}
}

Best regards

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

1 participant