Skip to content

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

@NoetKevin

Description

@NoetKevin

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions