Swipe Navigation

From NimbleKit

Jump to: navigation, search


In the following code change this line to reflect where you want to go, and what animation (in this case it's set to PushRight) to use to get there:
NKMoveToPageAnimated("page-to-go-to.html","PushRight");
This code goes into the Head of the file:
<script>
function OnTouchStart(event)
{
   var touch = event.touches[0];
   initialTouchPosition = touch.pageX;
}

function OnTouchEnd(event)
{
   if (((lastPosition-initialTouchPosition)) > 300)
   {
      NKMoveToPageAnimated("page-to-go-to.html","PushRight");
   }
}

function OnTouchMove(event)
{
   var touch = event.touches[0];
   lastPosition = touch.pageX;   
}
</script>


This is what the Body tag needs to look like:
<body ontouchmove="OnTouchMove(event);"  ontouchstart="OnTouchStart(event);"ontouchend="OnTouchEnd(event);"]]>