Git Product home page Git Product logo

react-native-swiper's People

Contributors

manjiz avatar

Stargazers

 avatar

Watchers

 avatar

Forkers

qiuziz

react-native-swiper's Issues

onIndexChanged not working

When I use Taro.Swiper on my project, I found the Swiper component's onChange callback does not working at React Native Platform.

onLayout repeated triggered

I see the the code below in your index.js

onLayout = (event: LayoutChangeEvent) => {
    const { loop } = this.props
    const {
      index,
      total,
      dir,
      width,
      height,
    } = this.state
    const { width: layoutWidth, height: layoutHeight } = event.nativeEvent.layout    // <== here
    // const layoutWidth = Math.round(event.nativeEvent.layout.width)
    // const layoutHeight = Math.round(event.nativeEvent.layout.height)
    let offsetWouldBeSet: Partial<Offset> = this.realtimeOffset = {}
    const stateWouldBeSet: any = { width: layoutWidth, height: layoutHeight }

    if (total > 1) {
      let actualIndex = index
      loop && actualIndex++
      offsetWouldBeSet = getOffset(dir, actualIndex, layoutWidth, layoutHeight)
    }

    // only update the offset in state if needed, updating offset while swiping
    // causes some bad jumping / stuttering
    if (layoutWidth !== width || layoutHeight !== height) {
      stateWouldBeSet.offset = offsetWouldBeSet
    }

    this.setState(stateWouldBeSet)
  }

then I found that onLayout method triggered every few milliseconds , and it lead to a huge lag .
if I enable the 2 row below

  // const layoutWidth = Math.round(event.nativeEvent.layout.width)
    // const layoutHeight = Math.round(event.nativeEvent.layout.height)

this problem will be resolved .

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.