mirror of
				https://github.com/flynx/ImageGrid.git
				synced 2025-10-30 19:00:09 +00:00 
			
		
		
		
	fixed a corner-case scope bug in loadImages(...)...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
		
							parent
							
								
									74efe28d26
								
							
						
					
					
						commit
						c039842f8c
					
				
							
								
								
									
										29
									
								
								ui/data.js
									
									
									
									
									
								
							
							
						
						
									
										29
									
								
								ui/data.js
									
									
									
									
									
								
							| @ -295,13 +295,14 @@ function loadImages(ref_gid, count, ribbon){ | |||||||
| 	var l = DATA.ribbons[ribbon_i].length | 	var l = DATA.ribbons[ribbon_i].length | ||||||
| 	if(l <= count){ | 	if(l <= count){ | ||||||
| 		var from_i = 0 | 		var from_i = 0 | ||||||
|  | 
 | ||||||
| 	} else { | 	} else { | ||||||
| 		var from_i = DATA.ribbons[ribbon_i].indexOf(gid) - Math.floor(count/2) | 		var from_i = DATA.ribbons[ribbon_i].indexOf(gid) - Math.floor(count/2) | ||||||
| 	} |  | ||||||
| 		// special case: head...
 | 		// special case: head...
 | ||||||
| 		from_i = from_i < 0 ? 0 : from_i | 		from_i = from_i < 0 ? 0 : from_i | ||||||
| 		// special case: tail...
 | 		// special case: tail...
 | ||||||
| 		from_i = l - from_i < count ? l - count : from_i | 		from_i = l - from_i < count ? l - count : from_i | ||||||
|  | 	} | ||||||
| 	var from_gid = DATA.ribbons[ribbon_i][from_i] | 	var from_gid = DATA.ribbons[ribbon_i][from_i] | ||||||
| 
 | 
 | ||||||
| 	var old_gids = getImageGIDs(getImageGID(images.first()), images.length, ribbon_i, true) | 	var old_gids = getImageGIDs(getImageGID(images.first()), images.length, ribbon_i, true) | ||||||
| @ -328,7 +329,7 @@ function loadImages(ref_gid, count, ribbon){ | |||||||
| 	// check if we have a common section at all / full reload...
 | 	// check if we have a common section at all / full reload...
 | ||||||
| 	if(head == 0 && tail == 0){ | 	if(head == 0 && tail == 0){ | ||||||
| 		if(gids.indexOf(old_gids[0]) == -1){ | 		if(gids.indexOf(old_gids[0]) == -1){ | ||||||
| 			console.log('>>> FULL RELOAD...') | 			console.log('>>> (ribbon:', ribbon_i, ') FULL RELOAD --', gids.length) | ||||||
| 			// XXX do we need to think about alining here???
 | 			// XXX do we need to think about alining here???
 | ||||||
| 			extendRibbon(0, gids.length - old_gids.length, ribbon) | 			extendRibbon(0, gids.length - old_gids.length, ribbon) | ||||||
| 			return ribbon | 			return ribbon | ||||||
| @ -340,13 +341,13 @@ function loadImages(ref_gid, count, ribbon){ | |||||||
| 		// do nothing...
 | 		// do nothing...
 | ||||||
| 		// ...the requested section is the same as the one already loaded...
 | 		// ...the requested section is the same as the one already loaded...
 | ||||||
| 		} else { | 		} else { | ||||||
| 			console.log('>>> NOTHING TO DO...') | 			console.log('>>> (ribbon:', ribbon_i, ') NOTHING TO DO.') | ||||||
| 			return images | 			return images | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
| 	// do a partial reload...
 | 	// do a partial reload...
 | ||||||
| 	} else { | 	} else { | ||||||
| 		console.log('>>>', head, '+-('+ (old_gids.length) +')-+', tail) | 		console.log('>>> (ribbon:', ribbon_i, ')', head, '+-('+ (old_gids.length) +')-+', tail) | ||||||
| 		// NOTE: we do not need to do anything about alignment as 
 | 		// NOTE: we do not need to do anything about alignment as 
 | ||||||
| 		// 		extendRibbon will get the correct head and tail so as to
 | 		// 		extendRibbon will get the correct head and tail so as to
 | ||||||
| 		// 		align everything by itself...
 | 		// 		align everything by itself...
 | ||||||
| @ -481,6 +482,26 @@ function convertDataGen1(data){ | |||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  | /********************************************************************** | ||||||
|  | * localStorage | ||||||
|  | * | ||||||
|  | * XXX should we use jStorage here? | ||||||
|  | */ | ||||||
|  | 
 | ||||||
|  | function loadLocalStorage(attr){ | ||||||
|  | 	attr = attr == null ? 'DATA' : attr | ||||||
|  | 	DATA = JSON.parse(localStorage[attr]) | ||||||
|  | 	return loadData(DATA) | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | function saveLocalStorage(attr){ | ||||||
|  | 	attr = attr == null ? 'DATA' : attr | ||||||
|  | 	localStorage[attr] = JSON.stringify(DATA) | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
| /********************************************************************** | /********************************************************************** | ||||||
| * Setup | * Setup | ||||||
| */ | */ | ||||||
|  | |||||||
| @ -264,9 +264,12 @@ $(function(){ | |||||||
| 
 | 
 | ||||||
| 	//setElementOrigin($('.ribbon-set'), 'top', 'left') | 	//setElementOrigin($('.ribbon-set'), 'top', 'left') | ||||||
| 
 | 
 | ||||||
|  | 	if('DATA' in localStorage){ | ||||||
|  | 		loadLocalStorage() | ||||||
|  | 	} else { | ||||||
| 		DATA = convertDataGen1(image_list) | 		DATA = convertDataGen1(image_list) | ||||||
| 
 |  | ||||||
| 		loadData(DATA) | 		loadData(DATA) | ||||||
|  | 	} | ||||||
| 
 | 
 | ||||||
| 	// NOTE: this is global so as to not to add any extra complexity to  | 	// NOTE: this is global so as to not to add any extra complexity to  | ||||||
| 	//		the internal workings... | 	//		the internal workings... | ||||||
| @ -283,7 +286,7 @@ $(function(){ | |||||||
| 	setupDataBindings() | 	setupDataBindings() | ||||||
| 
 | 
 | ||||||
| 	// XXX stub... | 	// XXX stub... | ||||||
| 	centerView(focusImage($('.image').first()), 'css') | 	//centerView(focusImage($('.image').first()), 'css') | ||||||
| 	updateImages() | 	updateImages() | ||||||
| 
 | 
 | ||||||
| }) | }) | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user