DuDigital/react-native-zoomable-view

If the InitialOffset prop is set, the zoomableView "jumps" on the first pan...

AVGHz opened this issue · 0 comments

AVGHz commented

As we had to render some pictures with different initial offsets for our project, we noticed that on the first pan the pictures are being repositioned to 0,0;
Our solution was to initialise the lastX and lastY to the props on mount; we patched the module locally for our project;
Maybe this will help somebody;

we inserted this in line 85 of ReactNativeZoomableView.tsx, just before componentDidUpdate

componentDidMount() {
    if(typeof(this.props.initialOffsetX)!=='undefined') {
        this.setState({
            lastX: this.props.initialOffsetX
        })
    }
    if(typeof(this.props.initialOffsetY)!=='undefined') {
        this.setState({
            lastY: this.props.initialOffsetY
        })
    }
}