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
							
								
									f5a6fc8c87
								
							
						
					
					
						commit
						6613f1fc5c
					
				| @ -165,17 +165,8 @@ function setupBookmarks(viewer){ | |||||||
| 			bookmarksUpdated() | 			bookmarksUpdated() | ||||||
| 		}) | 		}) | ||||||
| 		.on('horizontalShiftedImage', function(evt, gid, direction){ | 		.on('horizontalShiftedImage', function(evt, gid, direction){ | ||||||
| 			var n = DATA.order.indexOf(gid) | 			if(shiftGIDInSparseList(gid, BOOKMARKS)){ | ||||||
| 			var o = BOOKMARKS.indexOf(gid) | 				bookmarksUpdated() | ||||||
| 
 |  | ||||||
| 			// move the marked gid...
 |  | ||||||
| 			BOOKMARKS.splice(o, 1) |  | ||||||
| 			BOOKMARKS.splice(n, 0, gid) |  | ||||||
| 
 |  | ||||||
| 			// test if there are any marked images between n and o...
 |  | ||||||
| 			var shift = compactSparceList(BOOKMARKS.slice(Math.min(n, o)+1, Math.max(n, o))) |  | ||||||
| 			if(shift.length > 0){ |  | ||||||
| 				marksUpdated() |  | ||||||
| 			} | 			} | ||||||
| 		}) | 		}) | ||||||
| } | } | ||||||
|  | |||||||
							
								
								
									
										27
									
								
								ui/marks.js
									
									
									
									
									
								
							
							
						
						
									
										27
									
								
								ui/marks.js
									
									
									
									
									
								
							| @ -289,6 +289,22 @@ function shiftGIDToOrderInList(gid, direction, list){ | |||||||
| 	} | 	} | ||||||
| 	return false | 	return false | ||||||
| } | } | ||||||
|  | // a sparse version of shiftGIDToOrderInList(..)...
 | ||||||
|  | function shiftGIDInSparseList(gid, list){ | ||||||
|  | 	var n = DATA.order.indexOf(gid) | ||||||
|  | 	var o = list.indexOf(gid) | ||||||
|  | 
 | ||||||
|  | 	// move the marked gid...
 | ||||||
|  | 	list.splice(o, 1) | ||||||
|  | 	list.splice(n, 0, gid) | ||||||
|  | 
 | ||||||
|  | 	// test if there are any marked images between n and o...
 | ||||||
|  | 	var shift = compactSparceList(list.slice(Math.min(n, o)+1, Math.max(n, o))) | ||||||
|  | 	if(shift.length > 0){ | ||||||
|  | 		return true | ||||||
|  | 	} | ||||||
|  | 	return false | ||||||
|  | } | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| @ -775,16 +791,7 @@ function setupMarks(viewer){ | |||||||
| 			marksUpdated() | 			marksUpdated() | ||||||
| 		}) | 		}) | ||||||
| 		.on('horizontalShiftedImage', function(evt, gid, direction){ | 		.on('horizontalShiftedImage', function(evt, gid, direction){ | ||||||
| 			var n = DATA.order.indexOf(gid) | 			if(shiftGIDInSparseList(gid, MARKED)){ | ||||||
| 			var o = MARKED.indexOf(gid) |  | ||||||
| 
 |  | ||||||
| 			// move the marked gid...
 |  | ||||||
| 			MARKED.splice(o, 1) |  | ||||||
| 			MARKED.splice(n, 0, gid) |  | ||||||
| 
 |  | ||||||
| 			// test if there are any marked images between n and o...
 |  | ||||||
| 			var shift = compactSparceList(MARKED.slice(Math.min(n, o)+1, Math.max(n, o))) |  | ||||||
| 			if(shift.length > 0){ |  | ||||||
| 				marksUpdated() | 				marksUpdated() | ||||||
| 			} | 			} | ||||||
| 		}) | 		}) | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user