meteor-factory / react-native-tinder-swipe-cards

Tinder-like swipe cards for your React Native app
MIT License
1.13k stars 301 forks source link

Stack render broken? #84

Open sarahkadar opened 7 years ago

sarahkadar commented 7 years ago

I am not sure what I am doing wrong.

Without stack, looking good: 2017-04-18 00 34 12

With stack, all messed up: 2017-04-18 00 36 32

Code is at https://github.com/KTamas/imdbinder/blob/master/Tinder.js

esganzerla commented 7 years ago

I'm not really sure why the renderStack function had these values inside, so I'm not making a PR, but I found that if you change the lines 331-335 (SwipeCards.js) to:

      let offsetX = "50%"
      let lastOffsetX = this.props.stackOffsetX;

      let offsetY = "50%"
      let lastOffsetY = this.props.stackOffsetY;

it was originally:

      let offsetX = this.props.stackOffsetX * cards.length - i * this.props.stackOffsetX;
      let lastOffsetX = this.props.stackOffsetX;

      let offsetY = this.props.stackOffsetY * cards.length - i * this.props.stackOffsetY;
      let lastOffsetY = this.props.stackOffsetY;

I believe it will work just fine. still scaling as well

sarahkadar commented 7 years ago

@esganzerla thanks, this fixes it! sort of. don't look very stack-ey anymore.

Though now I have yep/nope shown somehow reversed... and maybe is simply not working...

pbassut commented 7 years ago

@esganzerla That's exactly what gives the stacky look of it. Every card available gets slightly shifted to the lower-right.

sarahkadar commented 7 years ago

I figured out what I messed up: some default styles of create-react-native-app mess with it. so completely my fault.

pbassut commented 7 years ago

@KTamas mind sharing what that was?

sarahkadar commented 7 years ago

the default CRNA App.js has this:

const styles = StyleSheet.create({
  container: {
    flex: 1,
    backgroundColor: '#fff',
    alignItems: 'center',
    justifyContent: 'center',
  },
});

alignItems: center and justifyContent: center messes up react-native-tinder-swipe-cards.

pbassut commented 7 years ago

Right. I'm not using CRNA tho.

sarahkadar commented 7 years ago

Yeah. The default app.js add this style to the main container and that breaks things so it's not really a CRNA but more like a stylesheet issue I guess.

YannzizTay commented 7 years ago

@KTamas you need to set the stackOffsetX and you will be good try out stackOffsetX={2}