ionic-framework icon indicating copy to clipboard operation
ionic-framework copied to clipboard

[FEATURE] Swipe-To-Go-Back, iOS7-Style / Interactive View Transitions

Open sidneys opened this issue 12 years ago • 34 comments

The new iOS7 navigation paradigm requires that users can always swipe to navigate backwards - in UIKit, this feature is called "Interactive Transitions".

This has been excellently implemented in - only a few days old - "Framework 7" by the iDangerous guys:

Demo (Swipe from the left Screen Border): http://www.idangero.us/framework7/#.UxRzo_RdXQw

Source: https://github.com/nolimits4web/Framework7/blob/master/src/js/views.js

This would be the last gap to close to make Ionic non distinguishable from native on newer iOS7 based devices. :-) Please integrate it to the the Ionic framework.

sidneys avatar Mar 03 '14 12:03 sidneys

/agree

uniring avatar Mar 03 '14 12:03 uniring

Opened #721 to do first

ajoslin avatar Mar 04 '14 15:03 ajoslin

All for this!

CoenWarmer avatar Mar 04 '14 19:03 CoenWarmer

+1

cutzenfriend avatar Mar 23 '14 15:03 cutzenfriend

+1

kamote avatar Mar 27 '14 23:03 kamote

+1

antonshevchenko avatar May 09 '14 21:05 antonshevchenko

Coming soon ... :tm:

ajoslin avatar May 09 '14 21:05 ajoslin

+1... is it really coming soon? this would be huge. all our testing shows users immediately trying to swipe first to get back to the main screen from side menus.

ianlyons avatar May 10 '14 01:05 ianlyons

We're working on it right now - it requires a refactor of the whole nav system.

ajoslin avatar May 10 '14 02:05 ajoslin

+1

rajatrocks avatar May 28 '14 07:05 rajatrocks

+1

ctaepper avatar Jun 17 '14 11:06 ctaepper

hi What is the latest situation :)

EmreMengukan avatar Jul 21 '14 11:07 EmreMengukan

Moving feature requests from GH Issues to Trello. Please continue the discussion and vote for this and other issues that are important to you here: https://trello.com/c/DFBLfHRz/16-swipe-to-go-back-ios7-style-interactive-view-transitions

perrygovier avatar Jul 28 '14 20:07 perrygovier

+1

nodkrot avatar Sep 21 '14 20:09 nodkrot

+1

hanford avatar Sep 23 '14 23:09 hanford

+1

jrutter avatar Sep 26 '14 14:09 jrutter

This can be coded with existing framework functionality

a) On ion-content - add something like on-swipe-right="swipe('plan', 'left')
That includes the direction AND the state I want to go to On some I have on-swipe-left as well.... depending upon what effect I want.....

<ion-content on-swipe-right="swipe('plan', 'left')">

b) In a controller somewhere

    $scope.swipe = function (new_location, direction) {

        if (direction == "right")
        {
           $scope.primary_view_animation_class = "ABC_slide-full";   // slide-in-right
        }
        else
        {
            $scope.primary_view_animation_class = "ABC_slide-full_left";  // slide-in-left
        }

        $location.path(new_location);
    }

(ABC being a namespace of your choice, but use one so it doesn't clash with the existing CSS)

c) We need to apply some CSS to the ion-nav-view....... however I could't get the ion-nav-view to take the transition CSS, so had to wrap it in a div (in my index.html file)

<div animation="{{primary_view_animation_class}}">
    <ion-nav-view>
    </ion-nav-view>
</div>

d) Copy the CSS for slide full - and use the .reverse version for the _left version (as the framework is trying to add the class reverse, but because history is all a bit contradictory to the user proposed swipe, we can't rely on that to ensure that when we are swiping left, the content scrolls the way the swipe is, so we have to use our own CSS here to avoid weirdness

(Don't forget your namespace you chose in A !)

Yes a bit of work - but hey - its possible :)

alexbainbridge avatar Sep 26 '14 15:09 alexbainbridge

I like the @alexbainbridge idea but its just easier if we use the $ionicNavBarDelegate.back(); method. Therefore, we don't need to be worry about the animations anymore. Something like this would work:

<ion-content on-swipe-right="swipe('right')">
.controller('myController', function($scope, $ionicNavBarDelegate)
 {
    $scope.swipe = function (direction) 
   {
        console.warn('Swipe:  ' + direction);
        $ionicNavBarDelegate.back();
    }
}

ardavank avatar Oct 17 '14 00:10 ardavank

The on-swipe-right code from @alexbainbridge doesn't do the right thing. This should only be triggered if the swipe is from the left edge of the screen. And the content needs to drag with the swipe. This can't be achieved easily currently and should be built-in to Ionic, as it needs to be done perfectly for apps to fit in on iOS.

bentomas avatar Nov 19 '14 19:11 bentomas

Since I have a view that has always a back state, I solved in this way

<ion-view view-title="Title " id="ElementId"></ion-view>

.controller("ElementController", ['$ionicHistory', '$ionicGesture', 
    function($ionicHistory, $ionicGesture) {

         $ionicGesture.on('dragright',function(event) {
                   $ionicHistory.goBack();
            }, angular.element(document.querySelector("#ElementId")));
}])

bonesmccoy avatar Dec 21 '14 10:12 bonesmccoy