Skip to content

Custom Scroll Progress #578

Closed Answered by tobimori
tobimori asked this question in Help
Discussion options

You must be logged in to vote

Managed to solve it like this:

    const count = this.instance?.slideNodes().length ?? 1
    el.style.transform = `translate3d(${el.clientWidth / count}px,0px,0px)`

    this.instance?.on('scroll', () => {
      if (!this.instance) return

      el.style.transform = `translate3d(${Math.min(
        el.clientWidth,
        Math.max(
          (this.instance.internalEngine().location.get() / count) * -1 + el.clientWidth / count,
          0
        )
      )}px,0px,0px)`
    })

Note that in this case, my progress is exactly the same width as one image.

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by tobimori
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
1 participant