mirror of
				https://github.com/flynx/ImageGrid.git
				synced 2025-10-31 03:10:07 +00:00 
			
		
		
		
	some refactoring...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
		
							parent
							
								
									7cdf21c2e3
								
							
						
					
					
						commit
						d2362bd116
					
				| @ -804,9 +804,11 @@ function exportImageTo(gid, path, im_name, size){ | |||||||
| 	return (function(src, dest){ | 	return (function(src, dest){ | ||||||
| 		return copyFile(src, dest) | 		return copyFile(src, dest) | ||||||
| 			.done(function(){ | 			.done(function(){ | ||||||
|  | 				// XXX do we actually need this???
 | ||||||
| 				console.log(src, 'done.') | 				console.log(src, 'done.') | ||||||
| 			}) | 			}) | ||||||
| 			.fail(function(err){ | 			.fail(function(err){ | ||||||
|  | 				// XXX do we actually need this???
 | ||||||
| 				console.warn(src, 'err:', err) | 				console.warn(src, 'err:', err) | ||||||
| 			}) | 			}) | ||||||
| 	})(src, dest) | 	})(src, dest) | ||||||
| @ -824,8 +826,7 @@ function exportImagesTo(path, im_name, dir_name, size){ | |||||||
| 	dir_name = dir_name == null ? 'fav' : dir_name | 	dir_name = dir_name == null ? 'fav' : dir_name | ||||||
| 	size = size == null ? 1000 : size | 	size = size == null ? 1000 : size | ||||||
| 
 | 
 | ||||||
| 	// starting point...
 | 	var res = $.Deferred() | ||||||
| 	//var deferred = $.Deferred().resolve()
 |  | ||||||
| 
 | 
 | ||||||
| 	var base_path = path | 	var base_path = path | ||||||
| 	path = normalizePath(path) | 	path = normalizePath(path) | ||||||
| @ -842,7 +843,6 @@ function exportImagesTo(path, im_name, dir_name, size){ | |||||||
| 	selection.sort(imageOrderCmp) | 	selection.sort(imageOrderCmp) | ||||||
| 	var z = (('10e' + (selection.length + '').length) * 1 + '').slice(2) | 	var z = (('10e' + (selection.length + '').length) * 1 + '').slice(2) | ||||||
| 
 | 
 | ||||||
| 	var res = $.Deferred() |  | ||||||
| 	var pool = makeDefferedPool() | 	var pool = makeDefferedPool() | ||||||
| 		.depleted(function(){ | 		.depleted(function(){ | ||||||
| 			showStatusQ('Export: done.') | 			showStatusQ('Export: done.') | ||||||
| @ -865,7 +865,6 @@ function exportImagesTo(path, im_name, dir_name, size){ | |||||||
| 			var o = selection.indexOf(gid) + '' | 			var o = selection.indexOf(gid) + '' | ||||||
| 			dest = dest.replace('%i', (z + o).slice(o.length)) | 			dest = dest.replace('%i', (z + o).slice(o.length)) | ||||||
| 
 | 
 | ||||||
| 			//exportImageTo(gid, path, dest, size)
 |  | ||||||
| 			pool.enqueue(null, exportImageTo, [gid, path, dest, size]) | 			pool.enqueue(null, exportImageTo, [gid, path, dest, size]) | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -11,6 +11,14 @@ | |||||||
| 
 | 
 | ||||||
| var POOL_SIZE = 64 | var POOL_SIZE = 64 | ||||||
| 
 | 
 | ||||||
|  | var DEFAULT_TRANSITION_DURATION = 200 | ||||||
|  | 
 | ||||||
|  | // XXX this affects only the innertial part, not setCurrentPage...
 | ||||||
|  | var USE_TRANSITIONS_FOR_ANIMATION = false | ||||||
|  | 
 | ||||||
|  | var USE_TRANSFORM = true | ||||||
|  | var USE_3D_TRANSFORM = true | ||||||
|  | 
 | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| /*********************************************************************/ | /*********************************************************************/ | ||||||
| @ -326,8 +334,6 @@ var getElementShift = makeCSSVendorAttrGetter( | |||||||
| 		}) | 		}) | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| var DEFAULT_TRANSITION_DURATION = 200 |  | ||||||
| 
 |  | ||||||
| var getElementTransitionDuration = makeCSSVendorAttrGetter( | var getElementTransitionDuration = makeCSSVendorAttrGetter( | ||||||
| 		'transitionDuration',  | 		'transitionDuration',  | ||||||
| 		DEFAULT_TRANSITION_DURATION,  | 		DEFAULT_TRANSITION_DURATION,  | ||||||
| @ -335,9 +341,6 @@ var getElementTransitionDuration = makeCSSVendorAttrGetter( | |||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| var USE_TRANSFORM = true |  | ||||||
| var USE_3D_TRANSFORM = true |  | ||||||
| 
 |  | ||||||
| // NOTE: at this point this works only on the X axis...
 | // NOTE: at this point this works only on the X axis...
 | ||||||
| function setElementTransform(elem, offset, scale, duration){ | function setElementTransform(elem, offset, scale, duration){ | ||||||
| 	elem = $(elem) | 	elem = $(elem) | ||||||
| @ -398,9 +401,6 @@ function setElementTransform(elem, offset, scale, duration){ | |||||||
| } | } | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| // XXX this affects only the innertial part, not setCurrentPage...
 |  | ||||||
| var USE_TRANSITIONS_FOR_ANIMATION = false |  | ||||||
| 
 |  | ||||||
| // XXX make this a drop-in replacement for setElementTransform...
 | // XXX make this a drop-in replacement for setElementTransform...
 | ||||||
| // XXX cleanup, still flacky...
 | // XXX cleanup, still flacky...
 | ||||||
| function animateElementTo(elem, to, duration, easing, speed, use_transitions){ | function animateElementTo(elem, to, duration, easing, speed, use_transitions){ | ||||||
| @ -462,12 +462,12 @@ function animateElementTo(elem, to, duration, easing, speed, use_transitions){ | |||||||
| 			} | 			} | ||||||
| 
 | 
 | ||||||
| 			// do an intermediate step...
 | 			// do an intermediate step...
 | ||||||
| 			// XXX do propper easing...
 | 			// XXX do proper easing...
 | ||||||
| 			// XXX sometimes results in jumping around...
 | 			// XXX sometimes results in jumping around...
 | ||||||
| 			// 		...result of jumping over the to position...
 | 			// 		...result of jumping over the to position...
 | ||||||
| 			if(speed != null){ | 			if(speed != null){ | ||||||
| 
 | 
 | ||||||
| 				// XXX the folowing two blocks are the same...
 | 				// XXX the following two blocks are the same...
 | ||||||
| 				// XXX looks a bit too complex, revise...
 | 				// XXX looks a bit too complex, revise...
 | ||||||
| 				if(Math.abs(dist.top) >= 1){ | 				if(Math.abs(dist.top) >= 1){ | ||||||
| 					dy = ((t - start) * speed.y) | 					dy = ((t - start) * speed.y) | ||||||
| @ -498,7 +498,7 @@ function animateElementTo(elem, to, duration, easing, speed, use_transitions){ | |||||||
| 					} | 					} | ||||||
| 				} | 				} | ||||||
| 
 | 
 | ||||||
| 			// XXX this is a staright forward linear function...
 | 			// XXX this is a straight forward linear function...
 | ||||||
| 			} else { | 			} else { | ||||||
| 				var r = (t - start) / duration | 				var r = (t - start) / duration | ||||||
| 				cur.top = Math.round(from.top + (dist.top * r)) | 				cur.top = Math.round(from.top + (dist.top * r)) | ||||||
| @ -743,6 +743,8 @@ function makeDeferredsQ(first){ | |||||||
| // 			Drop the queued workers.
 | // 			Drop the queued workers.
 | ||||||
| // 			NOTE: this will not stop the already running workers.
 | // 			NOTE: this will not stop the already running workers.
 | ||||||
| //
 | //
 | ||||||
|  | // 		.isRunning()
 | ||||||
|  | //
 | ||||||
| // 		.progress(func)
 | // 		.progress(func)
 | ||||||
| // 			Register a progress handler.
 | // 			Register a progress handler.
 | ||||||
| // 			The handler is called after each worker is done and will get
 | // 			The handler is called after each worker is done and will get
 | ||||||
| @ -880,6 +882,10 @@ function makeDefferedPool(size){ | |||||||
| 		this.queue.splice(0, this.queue.length) | 		this.queue.splice(0, this.queue.length) | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
|  | 	Pool.isRunning = function(){ | ||||||
|  | 		return this.pool.len() > 0 | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
| 
 | 
 | ||||||
| 	// Register a queue depleted handler...
 | 	// Register a queue depleted handler...
 | ||||||
| 	//
 | 	//
 | ||||||
| @ -979,13 +985,13 @@ Object.get = function(obj, name, dfl){ | |||||||
| 	return val | 	return val | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | 
 | ||||||
| // like .length but for sparse arrays will return the element count...
 | // like .length but for sparse arrays will return the element count...
 | ||||||
| Array.prototype.len = function(){ | Array.prototype.len = function(){ | ||||||
| 	return this.filter(function(){ return true }).length | 	return this.filter(function(){ return true }).length | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| 
 |  | ||||||
| // convert JS arguments to Array...
 | // convert JS arguments to Array...
 | ||||||
| function args2array(args){ | function args2array(args){ | ||||||
| 	return Array.apply(null, args) | 	return Array.apply(null, args) | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user