Swipe/Drag scroll with inertia?

Monkey Targets Forums/iOS/Swipe/Drag scroll with inertia?

CopperCircle(Posted 2012) [#1]
Hi, has anyone created a scroll function with inertia similar to the normal iOS scrolling. To scroll pages of text and allowing flicking which applies some inertia?

Thanks,


CopperCircle(Posted 2012) [#2]
I had a quick go and this works fairly well, just needs some tweaking:

		If drag = False 
			If TouchDown(0)
				drag = True
				dragStartY = TouchY(0)
				dragTime = Millisecs()/500.0
				dragScrollY = scrollY
			Endif
			If dragInertiaY<0 And scrollY>-4000
				dragInertiaY+=1
				scrollY = scrollY+(dragInertiaY)
			Endif		
			If dragInertiaY>0 And scrollY<0
				dragInertiaY-=1
				scrollY = scrollY+(dragInertiaY)
			Endif
		Else
			If TouchDown(0) = False
				If Millisecs()/500.0 < dragTime+0.5
					dragInertiaY=(dragCurrentY-dragStartY)/10
				EndIf
				drag = False
			Else
				dragCurrentY = TouchY(0)
			Endif
			
			dragAmountY = dragCurrentY - dragStartY
			scrollY = dragScrollY + dragAmountY
		Endif