
The project here is to develop a tablet touch and swipe functioning web site, to see this in action from your tablet you could click this link http://www.omarscott.com/omarstuff/touch/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.
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 :
Click here to see this code in action ""video input""
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.
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 scrolling is launching off of a div called scroller. The scroller div will house the scrollable items and its width will be set by javascript after javascript reads in all .scrollitem widths on a page. Scroller2 was implemented only to fix positioning bugs i experienced with scrollitems. The scroller div was given a css property of overflow hidden so that the browser would not make its entire width visible.
The HTML
The CSS
The jQuery
Again the source files will have alot more comments and sript -- this here is just a light
breakdown of the scroller.
more JQuery
On touch start we prevent default behaviors,
get the origin where the user touched and begin our css translate3d
more JQuery
on touch move we run a little math to figure where to move our scroller
then pass that variable in to our css property so translate3d will move with our user's finger.
more JQuery
On touch end
A lot is going down here so it would hard to go ahead and explain, but thank God for source files -- no? basically run logic to figure out how long our user's finger was on the screen as well as how many pixels the user's finger swiped across the screen. We are also going through scrollitems in an array to see where the user is then based on finger swipe go to the previous slide or the next one, a greater explanation of this lies in the comments for this source file.
Finally we run a transition on scroller to go to the appropriate scroller once the user lift their finger.
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.