Skip to content

cancel loop scroll still cause the index change #24

Open
@you06

Description

@you06

Suppose we have this requirement:

  • This is a loop scroll application.
  • It can only loop from the end to the start

Then I'm going to cancel the scroll event when it scroll from the start to the end. This is my beforeChange callback function.

beforeChange: function (el, prev, next) {
  console.log('brefore', prev, next)
  if (prev === 2 && next === 2) {
    return false
  }
  console.log('after', prev, next)
}

See JSFiddle demo: https://jsfiddle.net/z4Lvwhr6/

Once open, scroll up for twice, there will be there logs in the console:

brefore 2 2 // no scroll happened, still in page1
brefore 2 1 // scroll from page1 to page2
after 2 1

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