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 does not work #4574

Closed
fredericfalliere opened this issue Oct 29, 2015 · 17 comments
Closed

bug: $ionicConfig.views.swipeBackEnabled does not work #4574

fredericfalliere opened this issue Oct 29, 2015 · 17 comments

Comments

@fredericfalliere
Copy link

Type: bug

Platform: ios 8 webview

ionic bundle version v1.1.0

Since #3470 is closed, I'm opening a new one.

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);
  }
});

This code simply disables the swipe to go back when the right side menu is opened. Why is this needed ? Because the user closes the side menu with a swipe (or a more slow drag and drop (btw that feature is awesome)) that also goes back in the history.

Unfortunately, $ionicConfig.views.swipeBackEnabled(true/false); is not working :'(

Some steps to reproduce :

  • platform : iOS
  • ionic version v1.1.0
  • ionic app with a ion-side-menu side="right" and a ion-nav-view
  • users navigates 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 slowly 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. I understand describing an animation/user-interaction bug is hard.

Regards

@fredericfalliere fredericfalliere changed the title bug : $ionicConfig.views.swipeBackEnabled does not work bug: bug : $ionicConfig.views.swipeBackEnabled does not work Oct 29, 2015
@fredericfalliere fredericfalliere changed the title bug: bug : $ionicConfig.views.swipeBackEnabled does not work bug: $ionicConfig.views.swipeBackEnabled does not work Oct 29, 2015
@fredericfalliere
Copy link
Author

anyone ? :'(

@yemaw
Copy link

yemaw commented Nov 16, 2015

Same here. The page transaction animation showing two times when swipe and go back. :"(
$ionicConfig.views.swipeBackEnabled not working

@johnmiroki
Copy link

$ionicConfigProvider.views.swipeBackEnabled(false) doesn't work for me either. Still can swipe back on iOS and will stuck in a blank page if the previous page is not cached and there is no way for me to go back or force but have to restart the app.

Edit: I think I am in the wrong thread. I was under the impression that I could use $ionicConfigProvider.views.swipeBackEnabled(false) to turn of the swipe back behavior in iOS. It turns out I was wrong and I should use $ionicConfig.views.swipeBackEnabled(false) in app.run() instead.

@khadirbaaoua
Copy link

Encountering the same issue. Can't disable swipBackEnabled in iOS. Tried all of the above but still experiencing the issue

@johnmiroki
Copy link

@khadirbaaoua if you have tried $ionicConfig.views.swipeBackEnabled(false) and it didn't work, there is a brutal fix you can try: find all swipeBackEnabled variables in ionic.bundle.js or ionic-angular.js and change its value to false

@khadirbaaoua
Copy link

Thanks for the trick. I managed to solve the issue. It had nothing to do with swipeBackEnabled (which actually works quite fine)

@khadirbaaoua
Copy link

Here's the line that was causing the issue on my side :

$ionicConfigProvider.views.forwardCache(true)

By commenting out that line, things finally work as expected

@johnmiroki
Copy link

@khadirbaaoua can't verify it on my side for now, but FWIW, I do have $ionicConfigProvider.views.forwardCache(true) in my project. Will test it later. Thanks!

@fredericfalliere
Copy link
Author

$ionicConfigProvider is in a .config(, isn't it ?

This works, as well as <ion-view can-swipe-back="false"> for a specific view.

My use case is a bit different : on the same view and depending on user actions, I want to disable the swipe to go back feature.

Unfortunately can-swipe-back does not take a model as parameter...

And or little friend $ionicConfig.views.swipeBackEnabled() inside a controller does not work either.

Even in 1.2.1

@sbatezat
Copy link

sbatezat commented Apr 4, 2016

@marcelfalliere Please find bellow a working workaround for this issue (at least on Ionic @1.2.4). I agree it should be the default behavior on iOS.

$scope.$watch(function () { return $ionicSideMenuDelegate.isOpenRight(); }, function (isOpen) {
    $ionicHistory.currentView().canSwipeBack = !isOpen;
});

@danbucholtz
Copy link
Contributor

Hi @marcelfalliere,

Dan from Ionic here. Is there anything you want changed in the framework for this issue? It seems like there are several different things being discussed here.

Please let me know what I can do to help you out. If you could provide a codepen of your issue, even better.

We appreciate you using Ionic.

Thanks,
Dan

@danbucholtz danbucholtz added the needs: reply the issue needs a response from the user label Apr 5, 2016
@sbatezat
Copy link

sbatezat commented Apr 5, 2016

Hi @danbucholtz,

There is no several different things being discussed by @marcelfalliere here. This thread has been polluted by other defect from others users, but the one from @marcelfalliere is clear enough. Just run an application with different screens on an iPhone with the ion-side-menu and you will see the defect he's describing. Alternatively, to have more details, read the first message from @marcelfalliere.

Thanks for your understanding
Sébastien

@danbucholtz
Copy link
Contributor

Cool - I am looking at the linked thread right now. This fix will be in the next Ionic 1.x release.

Thanks,
Dan

@jgw96 jgw96 removed the needs: reply the issue needs a response from the user label Apr 5, 2016
@fredericfalliere
Copy link
Author

@danbucholtz

thanks !

@sbatezat

indeed !

@danbucholtz
Copy link
Contributor

This is resolved in this commit.

@sbatezat
Copy link

sbatezat commented Apr 7, 2016

@danbucholtz From what I can see (I didn't tested your code, just read it), your commit is not resolving the main issue. You should add something like "$ionicSideMenuDelegate.isOpenRight()" on the following condition:

if ( !$ionicConfig.views.swipeBackEnabled() || ! ionic.Platform.isIOS() )

Thus, I think it should be

if ( !$ionicConfig.views.swipeBackEnabled() || ! ionic.Platform.isIOS() || $ionicSideMenuDelegate.isOpenRight())

EDIT: I also think you should not call initSwipeBack if you are not on an iOS phone, thus, the check ionic.Platform.isIOS will become useless on the above line.

EDIT2: Not tested, but should work: PR #6066

sbatezat added a commit to sbatezat/ionic that referenced this issue Apr 7, 2016
@danbucholtz
Copy link
Contributor

Hi @sbatezat, ahh, good catch. We were resolving multiple issues with that commit. I will make sure we account for the side menu being open. Thanks!

@ionitron-bot ionitron-bot bot locked and limited conversation to collaborators Sep 7, 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

7 participants