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

bug: $ionicConfig.views.swipeBackEnabled can't be changed #3470

Closed
yankustefan opened this issue Apr 4, 2015 · 12 comments
Closed

bug: $ionicConfig.views.swipeBackEnabled can't be changed #3470

yankustefan opened this issue Apr 4, 2015 · 12 comments
Assignees

Comments

@yankustefan
Copy link

Type: feat

Platform: ios 8 webview

Is it possible to disable "swipe to go back" on specific views?

I would like to disable it on forms, where I have implemented a confirmation before closing/moving away from the view.

See also Ionic forum thread: #18808

@yankustefan yankustefan changed the title Disable "swipe to go back" on specific views feat: Disable "swipe to go back" on specific views Apr 4, 2015
@felquis
Copy link

felquis commented Apr 6, 2015

Do you tried using $ionicHistory.nextViewOptions? http://ionicframework.com/docs/api/service/$ionicHistory/

$ionicHistory.nextViewOptions({
  disableBack: true
});

I'm sure that with historyRoot: true swipe to go back doesn't works, but with disableBack: true I'm not sure.

@samu
Copy link

samu commented Apr 12, 2015

👍
I tried what @felquis suggested, but it didn't work.

@perrygovier
Copy link
Contributor

You should be able to disable it in the state's controller. Something like:

.controller('MyCtrl', function($scope, $ionicConfig) {
  $scope.$on('$ionicView.enter', function(){
    $ionicConfig.views.swipeBackEnabled(false);
  })
  $scope.$on('$ionicView.leave', function(){
    $ionicConfig.views.swipeBackEnabled(true);
  })
});

Does that do the trick?

@perrygovier perrygovier added navigation needs: reply the issue needs a response from the user labels Apr 14, 2015
@yankustefan
Copy link
Author

@perrygovier Thank your for your feedback.

I added to the controller of the according state/view.
Both functions are firing, either on enter and leave as expected.

However I still can swipe to leave the state/view.

I tested on 1.0.0-rc.0 and 1.0.0-rc.3

@Ionitron Ionitron removed the needs: reply the issue needs a response from the user label Apr 15, 2015
@mhartington
Copy link
Member

@perrygovier This maybe along the same lines as #3281, where change the config value in the controller did nothing.

If thats the case, this would be a bug and not a feature. Passing this to @adamdbradley

@mhartington mhartington changed the title feat: Disable "swipe to go back" on specific views bug: $ionicConfig.views.swipeBackEnabled can't be changed Apr 15, 2015
@yankustefan
Copy link
Author

Hi @adamdbradley

Thank you for your work on this issue.
I upgraded to 1.0.0-rc.4 and the code below still does not prevent "swipe to go back".
(tested in Ionic View)

.controller('MyCtrl', function($scope, $ionicConfig) {
  $scope.$on('$ionicView.enter', function(){
    $ionicConfig.views.swipeBackEnabled(false);
  })
  $scope.$on('$ionicView.leave', function(){
    $ionicConfig.views.swipeBackEnabled(true);
  })
});

@onchainguy-eth
Copy link

@yankustefan neither works in rc.5 :-(

@onchainguy-eth
Copy link

Ah @yankustefan simply use can-swipe-back="false" on your ion-view element

@marcelfalliere
Copy link

+1 @yankustefan

I have the following code (that I believe should be the default on iOS, but whatever) :

$scope.$watch(function () { return $ionicSideMenuDelegate.isOpenRight(); }, function (isOpen) {
  if (isOpen){
    $ionicConfig.views.swipeBackEnabled(false);
  } else {
    $ionicConfig.views.swipeBackEnabled(true);
  }
});

Not working :'(

The problem I have is the following :

  • platform : iOS
  • ionic version v1.1.0
  • ionic app with a ion-side-menu side="right" and a ion-nav-view
  • users navigate to a sub route (let's say from route "foo" to route "foo.bar" in the ion-nav-view)
  • users opens the right side-menu
  • users swipes from left ro right
  • Bug : the right menu closes AND the view navigates back

Is that clear enough ? I can make a video since it's pretty specific, if necessary.

Regards

Also pinging @adamdbradley

@fengsong97
Copy link

following is not work

.controller('MyCtrl', function($scope, $ionicConfig) {
$scope.$on('$ionicView.enter', function(){
$ionicConfig.views.swipeBackEnabled(false);
})
$scope.$on('$ionicView.leave', function(){
$ionicConfig.views.swipeBackEnabled(true);
})
});

@camilobaezcamba
Copy link

@seb0zz Have you tried programmatically?
Like this: can-swipe-back="canSwipe()"
$scope.canSwipe = function(){ return true; }

@ionitron-bot
Copy link

ionitron-bot bot commented Sep 3, 2018

Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Ionic, please create a new issue and ensure the template is fully filled out.

@ionitron-bot ionitron-bot bot locked and limited conversation to collaborators Sep 3, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests