These days have been dealing with the touch event, a variety of groping, combined with CSS3 did a similar spring-like sliding effect. When the finger is sliding, the element is captured by the target of the touches array, and the element in front of the current element is scaled, which is translate by the element with the index greater than the element.
This results in an overlapping effect that, when the finger is released, slides the whole through animate and restores the element state to the original.
JS code such as:
1$(function(){2 varStartx,starty,endx,endy,changex,changey,target,scroll,index;3 varInity=0,result=04document.getElementById ("Playcontentcontiner"). AddEventListener ("Touchstart", Touchstart,false)5document.getElementById ("Playcontentcontiner"). AddEventListener ("Touchmove", Touchmove,false)6document.getElementById ("Playcontentcontiner"). AddEventListener ("Touchend", Touchend,false)7 functionTouchstart (event) {8 //Event.preventdefault (); 9 varTouch=event.touches[0];Tenstartx=Touch.pagex; Onestarty=Touch.pagey; Ainity=result -Scroll=$ (window). scrolltop () - } the functionTouchMove (event) { - - varTouchs=event.touches[0]; -Target=event.touches[0].target +endx=Touchs.pagex; -endy=Touchs.pagey; +changex=endx-StartX Achangey=endy-Starty; atindex=$ (target) parents ("Li"). Index () -Translate = Changey * 0.8; - //Set Scaling Parameters - //$ ("#data"). Text ("index=" +index) -Scale = Math.max ((1-math.abs (changey/312)), 0.95) *100; Set the zoom ratio, relative to the sliding distance, and if you set a fixed value, the experience will be poor. - varoffset=$ ("#playContentContiner"). Children (). EQ (index-1). Offset (). Top in if(changey<0) {//swipe up - if(index>1) {//The first one without animations to if(Math.Abs (Result) <250) {//set easing, the larger the finger slip distance, the slower the element slip and the maximum sliding distance + Event.preventdefault (); - if(Math.Abs (Changey) <100){ theresult= (changey+inity)/2 *}Else if(Math.Abs (Changey) >=100&&changey<200){ $result= (changey+inity)/4Panax Notoginseng}Else if(Math.Abs (Changey) >=200&&changey<250){ -result= (changey+inity)/6 the}Else{ + return false A } the +$ ("#playContentContiner li:lt (" + (index-1) + ")"). CSS ({"width": scale+ "%", "margin": "0px Auto"})//element scaling before the target element - //element displacement after the target element $ //Alert ($ ("#playContentContiner div:lt (" +index+ ")). Length) $$ ("#playContentContiner li:gt (" + (index-2) + ")"). CSS ({"Z-index": "Ten", "-webkit-transform": "Translate3d (0," + (Result ) + "px,0)"}) -$ ("#playContentContiner"). Children (). EQ (index). addclass ("Upshadow") -}Else{ the return false - }Wuyi } the}Else{//Swipe down - if(index<$ ("#playContentContiner"). Children (). Length) { Wu if(Math.Abs (Result) <250){ - Event.preventdefault (); About if(Math.Abs (Changey) <100){ $result= (changey+inity)/2 -}Else if(Math.Abs (Changey) >=100&&changey<200){ -result= (changey+inity)/4 -}Else if(Math.Abs (Changey) >=200&&changey<250){ Aresult= (changey+inity)/6 +}Else{ the return false - } $ the$ ("#playContentContiner li:gt (" + (index-1) + ")"). CSS ({"width": scale+ "%", "margin": "0px Auto", "Z-index": "0"}) the$ ("#playContentContiner li:lt (" +index+ ")). CSS ({" Z-index ":" Ten ","-webkit-transform ":" Translate3d (0, "+ (Translate) + "px,0)"}) the$ ("#playContentContiner"). Children (). EQ (index). addclass ("Downshadow") the}Else{ - return false in } the } the } About } the functionTouchend (event) { the //Event.preventdefault (); the if(changey<0){ +$ (' body '). Animate ({scrolltop:-changey+$ (' body '). ScrollTop ()},500); -$ ("#playContentContiner li:lt (" +index+ ")). CSS ({" width ":" 100% "," Z-index ":" 0 "}) the Bayi$ ("#playContentContiner li:gt (" + (index-2) + ")"). CSS ({"-webkit-transform": "Translate3d (0,0,0)")}) the the$ ("#playContentContiner"). Children (). EQ (index). Removeclass ("Upshadow") -Result=0 -}Else{ the$ (' body '). Animate ({scrolltop:-changey+$ (' body '). ScrollTop ()},500); the$ ("#playContentContiner li:gt (" + (index-1) + ")"). CSS ({"width": "100%", "Z-index": "0"}) the$ ("#playContentContiner li:lt (" + (index+1) + ")"). CSS ({"Z-index": "Ten", "-webkit-transform": "Translate3d (0,0,0)")}) the$ ("#playContentContiner"). Children (). EQ (index). Removeclass ("Downshadow") - the } the } the})
Mobile phone sliding effect exploration