This is a migrated thread and some comments may be shown as answers.

How to trigger the back button when swiping right

3 Answers 238 Views
General Discussion
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Yohann
Top achievements
Rank 1
Yohann asked on 20 Jul 2014, 06:43 PM
Hello,

I would like the user to be able to go back to the previous page when swiping right.

Please help on what is the best way to do it. I've been trying to do it myself with the "touch events" but can't get to something nice.

Thanks

3 Answers, 1 is accepted

Sort by
0
André
Top achievements
Rank 1
answered on 23 Jul 2014, 12:36 PM
What you can do, is create a window manager and when you change the screen add it to the manager stack.

With touch event, you can create something on each view who will trigger the back function in the manager.
Also, override the backbutton press event by doing this:

document.addEventListener("backbutton", function onBackKeyDown() {
//Call to the screen manager back function
},false);

For slide effect, you can enable the window you want by setting

$('#my_previous_window').css("Display","block");
and add position fixed at your current screen + 0 at each position values.

Then as your finger drag the view, move the view by animating is left position.

When x cursor position in touch event is greater than (screen width/2)
trigger back function in the manager.
else animate to reset position to original.

P.S: I'm not a super user and do not know all of telerik solution, but I think my solution could be good for what you want to do.





0
Accepted
Tina Stancheva
Telerik team
answered on 23 Jul 2014, 04:13 PM
Hello Yohann,

Other options you can try are:
  • If you're using jQueryMobile, you can follow the approach demonstrated in the Swipe to Navigate demo
  • If you're using Kendo Mobile, you can hook up to the swipe event and navigate to a previous/next View when the user swipes. You can take a look at this small example: http://jsbin.com/yijaz/2/edit. However, please note that you would have to keep track of the previous views in the app - for instance save the last view address before navigating away from it. 

I hope this information helps.

Regards, Tina Stancheva
Telerik
 

Visit the Telerik Verified Plugins Marketplace and get the custom Cordova plugin you need, already tweaked to work seamlessly with AppBuilder.

 

0
Yohann
Top achievements
Rank 1
answered on 24 Oct 2014, 05:34 PM
Much Better ! Thank you :)
Tags
General Discussion
Asked by
Yohann
Top achievements
Rank 1
Answers by
André
Top achievements
Rank 1
Tina Stancheva
Telerik team
Yohann
Top achievements
Rank 1
Share this question
or