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

Show previous card on left to right swipe #125

Open
AishwaryaSurana opened this issue Mar 4, 2018 · 0 comments
Open

Show previous card on left to right swipe #125

AishwaryaSurana opened this issue Mar 4, 2018 · 0 comments

Comments

@AishwaryaSurana
Copy link

Is it possible to show previous card on swiping from left to right. As even if I am decrementing the value for index always the next card is shown which is there at the next index of the array.

    handleYup(card) {
        console.log("yup",card)
        //Alert.alert("Card",card.id+"");
        this.setState({
            cardYup: true
        })

    }

    handleNope(card) {
        console.log("nope")
        //Alert.alert("Card", card.id + "");
        this.setState({
            cardNope: true
        })

    }

    cardRemoved(index) {
        if(this.state.cardYup){
            index=index-2;
            this.setState({
                cardYup:false
            })
        }
        else if (this.state.cardNope) {
            //index = index +1
            this.setState({
                cardNope: false
            })
        }
        console.log(`The index is ${index}`);
        Alert.alert("Index", index+"");

        let CARD_REFRESH_LIMIT = 1

        if (this.state.cards.length - index <= CARD_REFRESH_LIMIT) {
            console.log(`There are only ${this.state.cards.length - index - 1} cards left.`);

            if (!this.state.outOfCards) {
                //console.log(`Adding ${cards2.length} more cards`)
                Alert.alert("No Cards","No morecards present")

                this.setState({
                    outOfCards: true
                })
            }

        }

    }

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

1 participant