mirror of
				https://github.com/flynx/ImageGrid.git
				synced 2025-10-31 03:10:07 +00:00 
			
		
		
		
	extendRibbon now is position-stable, now need to compensate for removal/addition...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
		
							parent
							
								
									a02b835127
								
							
						
					
					
						commit
						445980802d
					
				| @ -278,6 +278,7 @@ function updateImages(size){ | |||||||
| //
 | //
 | ||||||
| // NOTE: this will reload the current image elements...
 | // NOTE: this will reload the current image elements...
 | ||||||
| // NOTE: this is similar to extendRibbon(...) but different in interface...
 | // NOTE: this is similar to extendRibbon(...) but different in interface...
 | ||||||
|  | // XXX correctly align the result...
 | ||||||
| function loadImages(ref_gid, count, ribbon){ | function loadImages(ref_gid, count, ribbon){ | ||||||
| 	ribbon = $(ribbon) | 	ribbon = $(ribbon) | ||||||
| 	var images = ribbon.find('.image') | 	var images = ribbon.find('.image') | ||||||
|  | |||||||
| @ -294,9 +294,6 @@ function removeRibbon(ribbon){ | |||||||
| 
 | 
 | ||||||
| // NOTE: negative left or right will contract the ribbon...
 | // NOTE: negative left or right will contract the ribbon...
 | ||||||
| // XXX check what goes on if left/right are far more than length...
 | // XXX check what goes on if left/right are far more than length...
 | ||||||
| // XXX compensating for added/removed images at the start of the ribbon 
 |  | ||||||
| // 		does not work the same in every situation...
 |  | ||||||
| // 		...for some reason it is correct ONLY for left == -right
 |  | ||||||
| function extendRibbon(left, right, ribbon){ | function extendRibbon(left, right, ribbon){ | ||||||
| 	ribbon = ribbon == null ?  | 	ribbon = ribbon == null ?  | ||||||
| 				getRibbon() | 				getRibbon() | ||||||
| @ -309,6 +306,7 @@ function extendRibbon(left, right, ribbon){ | |||||||
| 		left: $([]), | 		left: $([]), | ||||||
| 		right: $([]) | 		right: $([]) | ||||||
| 	} | 	} | ||||||
|  | 	var pre = getRelativeVisualPosition($('.viewer'), ribbon).left | ||||||
| 
 | 
 | ||||||
| 	// truncate...
 | 	// truncate...
 | ||||||
| 	// NOTE: we save the detached elements to reuse them on extending,
 | 	// NOTE: we save the detached elements to reuse them on extending,
 | ||||||
| @ -329,22 +327,19 @@ function extendRibbon(left, right, ribbon){ | |||||||
| 		res.right = createImages(right, removed).appendTo(ribbon) | 		res.right = createImages(right, removed).appendTo(ribbon) | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	// compensate for the truncation...
 | 	// normalize position...
 | ||||||
| 	// XXX do we need to split this into a separate function?
 | 	// NOTE: this is fool-proof as it's based on relative visual 
 | ||||||
| 	// 		...the rest of the function is pretty generic...
 | 	// 		position...
 | ||||||
| 	// XXX for some reason this works correctly ONLY if left = -right
 | 	var post = getRelativeVisualPosition($('.viewer'), ribbon).left | ||||||
| 	// 		...appears to be connected with scale, but in a really odd 
 | 	if(pre != post){ | ||||||
| 	// 		way...
 | 		var scale = getElementScale($('.ribbon-set')) | ||||||
| 	//var scale = getElementScale($('.ribbon-set'))
 |  | ||||||
| 	if(left != 0){ |  | ||||||
| 		var l = parseFloat(ribbon.css('left')) | 		var l = parseFloat(ribbon.css('left')) | ||||||
| 		l = isNaN(l) ? 0 : l | 		l = isNaN(l) ? 0 : l | ||||||
| 		l = l + (-left * images.outerWidth()) |  | ||||||
| 		console.log('>>> compensating to:', l) |  | ||||||
| 		ribbon.css({ | 		ribbon.css({ | ||||||
| 			left: l | 			left: l + (pre - post)/scale, | ||||||
| 		}) | 		}) | ||||||
| 	} | 	} | ||||||
|  | 	// compensate for the truncation...
 | ||||||
| 
 | 
 | ||||||
| 	return res | 	return res | ||||||
| } | } | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user