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 prevent successive state changes when user clicks 2 different links rapidly? #143

Open
EmreErdogan opened this issue Aug 5, 2017 · 1 comment

Comments

@EmreErdogan
Copy link

EmreErdogan commented Aug 5, 2017

Hello guys, have any of you seen this problem? When user clicks a link to page A and then clicks link to page B rapidly, both transitions happen at the same time and the user ends up on page B.

This also breaks down the history because when the user is on page B and presses back button then he is directed to page A instead of the initial page. A and B are not supposed to be successive pages in history.

I tried listening ionicNativeTransitions.beforeTransition, ionicNativeTransitions.success, and ionicNativeTransitions.error events to cancel a state change while there is another transition is active at that time period, but I couldn't succeed. Any ideas?

@EmreErdogan
Copy link
Author

The issue is definitely caused by ionic-native-transitions plugin. When I disable the plugin this double state change never happens. It should not be hard to prevent that behaviour. I keep trying.

An example approach that I tried which didn't work is:

window.transitionActive = false;
$rootScope.$on('ionicNativeTransitions.beforeTransition', function(event){
  // Transition is about to happen
  if(window.transitionActive){
    event.preventDefault();
    console.log(':: ionicNativeTransitions.beforeTransition => CANCELED');
    return;
  }
  window.transitionActive = true;
  console.log(':: ionicNativeTransitions.beforeTransition => ALLOWED');
});

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