iPad touch and swipe for menus

iPad touch and swipe for menus
touch and swipe menus

With the advent of touch technology web developers have had a hard time developing interactivity for these devices such as iPad and android tablets and with so many makeshift API's it is hard to find a good platform to run off of. Well we are all in luck I have taken the time to develop touch javascript functionality from the ground up -- this means less code less headaches and allot more function.

To view this script in action go to http://www.omarscott.com/touches/index.php from your tablet, preferably an Ipad but works on some android devices as well.

Experience :
Intermidiate Javascript (jQuery), Intermediate HTML, Experienced CCS skills, or just being a copy and paste coder will suffice.

Meat and Potatoes :
Our goal here is to develop a navigational menu for a tablet web site, to see this in action from your tablet you could click this link http://www.omarscott.com/touches/index.php . This is not a tutorial just an introduction to the project -- you will have to go through and implement the source to really get working with this. Now lets get started.

Click here to see this code in action ""video input""

I will not really dive into the html - the code I am using here is from my current iPad portfolio site and all source files are here for you to download. The code I have written for this site has all been included in the source files (with heavy comments) so in this text I will only cover the meat and potatoes, where in contrast the sample files have my full site code including video, populated scrolls and contact forms etc. My site has light PHP and I used jQuery to build all touch functionality.

The nav here is a very simple development but needs some explaining. Since tablets do not translate mouse events at 100% -- creating touch menu items is imperative if you want to have a touch functioning website that incorporates user swipes and touches. I have created som javascript code that will run some logic when a user touches, moves and end interaction on a menu item.

The menu HTML
Just created a standard html menu



The CSS
Here we have basic CSS elements with a webkit transition to be sure that my button will animate to another state on touch and page load.



The jQuery
Again the source files will have alot more comments and sript -- this here is just a light breakdown of the scroller.
Here we create touchstart, touchmove and touchend events that will run a function that will take argument of the event name (this) so the could run its logic.



more JQuery
On touch start we prevent default behaviors, all we do here is set our css background by letting the gogo argument accept (this) that was passed in our initial event touchsart. We also prevent default behavior of the users touch.



more JQuery
on touch move we run a little math to figure where the user fingers are on the tough navigation element and screen. the logic basically says on that if the users touches outside the widths and heights of the menu elements then animate that button to its orignal state and if not then -------------



more JQuery

On touch end Here we are saying when the user lift their finger return the button to its orignal state. I am also running logic here for a clicked variable which gets set from the touchstart to 2 and in touchmove to 1 -- basically what this is saying is that is the user did move their finger then they must want to navigate to that url.



In Closing
I did not go in depth here on the site but if you download the source files all the information you need as well as details are placed within the code itself. Happy coding and this blog is open for comments. I will help out as much as I can.

Source Files: 

Other blogs

Touch swipe for web
The project here is to develop a tablet touch and swipe functioning web site, to...
touch and swipe menus
With the advent of touch technology web developers have had a hard time...
web and app development design
Mobile web and app design changes the surface of commercial design as the web did...
a digital presentation
The Kicker A mock up, a flash movie and a powerpoint file walk to into a meeting...
Spiderman Flash tutorial
Inception To kick off their launch on broadway the folks over at Spiderman were...
web or native app
Picture this, you work for a company that sells computer parts and you decided that...
Rc custom race truck
I decided to build this RC truck, because I’ve yet to see an on-road truck in the...