Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to render two “interactive.view” correctly? #291

Open
madeinquant opened this issue Aug 27, 2019 · 9 comments
Open

How to render two “interactive.view” correctly? #291

madeinquant opened this issue Aug 27, 2019 · 9 comments

Comments

@madeinquant
Copy link

Implementing an additional “interactive.view” in MapPanel.js, let’ say “panel A” and “panel B”. I expected to show them in mutual exclusively (A is shown and B is hidden, vice versa) when onPress is triggered. Unfortunately, not same as I expected. Initially, I render “panel A” before “panel B”, the “panel A” has shown but “panel B” is hidden. Even triggered onPress to change the position of “panel B” but it is still hidden. Please comment how to render two “interactive.view” correctly.

@gigin-flexott
Copy link

I have implemented the same feature using snapto method..

this.refs[interactable].snapTo({ index: 0 });

@madeinquant
Copy link
Author

@gigin-flexott would you explain in an example?

@gigin-flexott
Copy link

gigin-flexott commented Sep 10, 2019

Panel A

<Interactable.View
          verticalOnly={true}
          ref={'panelA'}
          animatedValueY={this._deltaY}
          animatedValueX={this._deltaX}
          snapPoints={[{ y: 0   }, { y: 1000 }]}
          initialPosition={{ x: 0, y: 1000 }}
        >

By default panelA has two snap points. Index 0 for showing and 1 for hiding

 <Interactable.View
          verticalOnly={true}
          ref={'panelB'}
          animatedValueY={this._deltaY}
          animatedValueX={this._deltaX}
          snapPoints={[{ y: 0   }, { y: 1000 }]}
          initialPosition={{ x: 0, y: 1000 }}
        > 

On press of button you can dynamically change the position of any panel by calling
this.refs['panelA'].snapTo({ index: 0 });

@madeinquant
Copy link
Author

@gigin-flexott Thank you.

@madeinquant
Copy link
Author

@gigin-flexott 'panelA' can be shown or be hidden. However, 'panelB' cannot be shown.

@gigin-flexott
Copy link

gigin-flexott commented Sep 10, 2019

from my above code..you can display panel A by calling

this.refs['panelA'].snapTo({ index: 0 })

and hide it by

this.refs['panelA'].snapTo({ index: 1 })

@madeinquant
Copy link
Author

@gigin-flexott Yes, 'panelA' can be hidden. However, 'panelB' cannot be shown or be hidden.

@gigin-flexott
Copy link

@madeinquant
this.refs['panelB'].snapTo({ index: 1 })
will make PanelB hidden

@madeinquant
Copy link
Author

@gigin-flexott panelA or panelB cannot be coexist. The first panel can only be shown (in this case, it is 'panelA'), 'panelB' cannot be shown. When I trigger the onPress function. I expected to show them in mutual exclusively (A is shown and B is hidden, vice versa). Unfortunately, it is not same as I expected.

 <Interactable.View
        verticalOnly={true}
        ref={ref => { panelA = ref; }}
        boundaries={{ top: -300 }}
        snapPoints={[{ y: 0   }, { y: 1000 }]}
         initialPosition={{ x: 0, y: 1000 }}
         animatedValueX={this._deltaX}
        animatedValueY={this._deltaY}>
--------------------------------------
 <Interactable.View
        verticalOnly={true}
        ref={ref => { panelB = ref }}
        boundaries={{ top: -300 }}
       snapPoints={[{ y: 0   }, { y: 1000 }]}
       initialPosition={{ x: 0, y: 1000 }}
        animatedValueX={this._deltaX}
        animatedValueY={this._deltaY}>
---------------------------------------
const onPressButton = () => {
    this.panelA.snapTo({ index: 1 });
    this.panelB.snapTo({ index: 0 });
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants