Skip to content

iOS-iPAD ScrollView centerContent with maximumZoomScale and minimumZoomScale renders content with an offset on top on first render #16820

@kimulus

Description

@kimulus

Is this a bug report?

yes

Have you read the Contributing Guidelines?

yes

Environment

OS: macOS Sierra 10.12.6
Node: 7.7.1
Yarn: Not Found
npm: 4.1.2
Watchman: 4.7.0
Xcode: Xcode 9.0.1 Build version 9A1004
Android Studio: Not Found

Packages: (wanted => installed)
react: 16.0.0 => 16.0.0
react-native: 0.50.3 => 0.50.3

Steps to Reproduce

On a iOS IPAD :

  1. Create a ScrollView with following props : scrollEnabled centerContent maximumZoomScale={15} minimumZoomScale={0.01}
  2. Render inside the ScrollView a view that is as large as the screen and twice the device screen height.
    <View style={{ width: '100%', height: Dimensions.get('window').height * 2, backgroundColor: 'green' }} />

Expected Behavior

The scrollview renders the green view with no offset on top. So what we see is a screen entirely green.

Actual Behavior

The scrollview renders is content with a top offset that is half of the height of the screen. It's refreshed correctly as soon as you touch the screen. If we don't set the centerContent props, we don't get this bug. This occurs only on IPAD-IOS. On iPhone, we don't get this bug

Reproducible Demo

Start with basic App and render this code under iPAD.
Tested both on simulator and device : https://screencast.com/t/agiYJw1Ws
Red is the root view and green is the view rendered within the scrollview, that would as no scroll off set at all.

import {
  View,
  ScrollView,
  Dimensions
} from 'react-native';

export default class App extends Component<{}> {
  render() {
    return (
      <View style={{flex: 1, backgroundColor: '#FF0000'}}>
        <ScrollView scrollEnabled zoomScale={0.01} centerContent maximumZoomScale={15} minimumZoomScale={0.01}>
          <View style={{ width: '100%', height: Dimensions.get('window').height * 2, backgroundColor: 'green' }} />
        </ScrollView>
      </View>
    );
  }
}`

Metadata

Metadata

Assignees

No one assigned

    Labels

    Ran CommandsOne of our bots successfully processed a command.StaleThere has been a lack of activity on this issue and it may be closed soon.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions