mirror of
				https://github.com/flynx/PortableMag.git
				synced 2025-10-31 12:00:11 +00:00 
			
		
		
		
	added animation step threshold...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
		
							parent
							
								
									dbea22817a
								
							
						
					
					
						commit
						bba739562c
					
				| @ -178,6 +178,7 @@ function handleScrollRelease(evt, data){ | |||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| var USE_TRANSITIONS_FOR_ANIMATION = false | var USE_TRANSITIONS_FOR_ANIMATION = false | ||||||
|  | var MIN_STEP = 24 | ||||||
| 
 | 
 | ||||||
| var animationFrame = function(){ | var animationFrame = function(){ | ||||||
|   return (window.requestAnimationFrame |   return (window.requestAnimationFrame | ||||||
| @ -189,6 +190,7 @@ var animationFrame = function(){ | |||||||
| }() | }() | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  | // XXX make this interruptable...
 | ||||||
| function animateElementTo(elem, to, duration, easing){ | function animateElementTo(elem, to, duration, easing){ | ||||||
| 	// use transition for animation...
 | 	// use transition for animation...
 | ||||||
| 	if(USE_TRANSITIONS_FOR_ANIMATION){ | 	if(USE_TRANSITIONS_FOR_ANIMATION){ | ||||||
| @ -212,6 +214,7 @@ function animateElementTo(elem, to, duration, easing){ | |||||||
| 			top: to.top - from.top, | 			top: to.top - from.top, | ||||||
| 			left: to.left - from.left, | 			left: to.left - from.left, | ||||||
| 		} | 		} | ||||||
|  | 		var prev_t = now | ||||||
| 
 | 
 | ||||||
| 		function animate(t){ | 		function animate(t){ | ||||||
| 			/* | 			/* | ||||||
| @ -220,9 +223,11 @@ function animateElementTo(elem, to, duration, easing){ | |||||||
| 				return | 				return | ||||||
| 			} | 			} | ||||||
| 			*/ | 			*/ | ||||||
| 
 | 			// try and not render things too often...
 | ||||||
|  | 			if(t - prev_t > MIN_STEP){ | ||||||
| 				// set position for current step...
 | 				// set position for current step...
 | ||||||
| 				if(t < then){ | 				if(t < then){ | ||||||
|  | 					prev_t = t | ||||||
| 					var rem = then - t | 					var rem = then - t | ||||||
| 					var r = rem/duration | 					var r = rem/duration | ||||||
| 
 | 
 | ||||||
| @ -240,6 +245,7 @@ function animateElementTo(elem, to, duration, easing){ | |||||||
| 					setElementTransform(elem, to) | 					setElementTransform(elem, to) | ||||||
| 					return | 					return | ||||||
| 				} | 				} | ||||||
|  | 			} | ||||||
| 			// sched next frame...
 | 			// sched next frame...
 | ||||||
| 			animationFrame(animate) | 			animationFrame(animate) | ||||||
| 		} | 		} | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user