Giter Club home page Giter Club logo

Comments (10)

maxx-coffee avatar maxx-coffee commented on July 2, 2024 3

Hopefully this helps if someone comes across this issue. I used https://github.com/yamill/react-native-orientation to add an event when orientation changes. I then get the dimensions and change the state to those dimensions re-rendering screen.

from react-native-swiper.

jamealg avatar jamealg commented on July 2, 2024 1

@esutton You don't need to modify react-native-swiper directly. The Swiper component will listen for changes to the width prop so using react-native-orientation's orientation change event, you can pass the updated Dimensions.get('window').width.

from react-native-swiper.

mkascel avatar mkascel commented on July 2, 2024

I'm seeing this also, the inspector shows that the calculated width is always 375 regardless of content or orientation. If I take away the Swiper element, the content expands as expected. Any ideas? Wonder if this is related to the fact that this is interpreted/rendered as an <index> element rather than Swiper or some other expected element...

screen shot 2015-07-19 at 16 28 10

from react-native-swiper.

mkascel avatar mkascel commented on July 2, 2024

Not quite sure what the automaticallyAdjustContentInsets property does per the docs, I tried setting this to true thinking it might affect layout but no luck.

from react-native-swiper.

rt2zz avatar rt2zz commented on July 2, 2024

the swiper take in a width and height parameter which can make it work in landscape, but it bugs out if a transition occurs.

from react-native-swiper.

esutton avatar esutton commented on July 2, 2024

Thanks @joshualcoffee

It sounds like the best solution may be to modify react-native-swiper to include react-native-orientation.

https://github.com/yamill/react-native-orientation

from react-native-swiper.

cosivox avatar cosivox commented on July 2, 2024

@joshualcoffee Could you please explain how did you do that?

from react-native-swiper.

maxx-coffee avatar maxx-coffee commented on July 2, 2024

@cosivox Sure thing!

This has not been tested but you should be able to get the idea from the example. This would be the internal slide component that you would include for each item in your slider.

In my code I found setting the view to be absolute and setting left, right, top, and bottom to 0 achieved the result I wanted.

import React, {Component} from 'react'
import Orientation from 'react-native-orientation'
const {
  View,
  Dimensions
} from 'react-native'
let window = Dimensions.get('window')
class Foo extend Component {
  constructor(_){
    super(_)
    this._orientationDidChange = this._orientationDidChange.bind(this)
    this.state = {
      width: window.width,
      height: window.height
    }
  }

  _orientationDidChange(orientation) {
    let window = Dimensions.get('window')
    this.setState({
      width: window.width,
      height: window.height
    })
  }

  componentDidMount() {
    Orientation.addOrientationListener(this._orientationDidChange);
  }

  render(){
    <View style={{width: this.state.width, height: this.state.height, position: 'absolute', left: 0, top:0, right: 0, bottom: 0}}>
  }
}

from react-native-swiper.

khrykin avatar khrykin commented on July 2, 2024

Setting width prop to Dimensions.get('window').width solved problem for me

from react-native-swiper.

sankar9659 avatar sankar9659 commented on July 2, 2024

@khrykin Does it working for you with vertical and horizontal mode?
Could you send your code?

from react-native-swiper.

Related Issues (20)

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.