mirror of
				https://github.com/flynx/ImageGrid.git
				synced 2025-10-30 10:50:08 +00:00 
			
		
		
		
	added data loading, still problems with aligning...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
		
							parent
							
								
									970c772c52
								
							
						
					
					
						commit
						23c9736376
					
				| @ -635,13 +635,18 @@ function loadImagesAround(ref_gid, count, ribbon){ | |||||||
| } | } | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  | var LOAD_SCREENS = 2 | ||||||
|  | var LOAD_THRESHOLD = 1 | ||||||
|  | var DEFAULT_SCREEN_IMAGES = 5 | ||||||
| 
 | 
 | ||||||
| function loadData(data){ | function loadData(data, images_per_screen){ | ||||||
| 	var ribbons_set = $('.ribbon-set') | 	var ribbons_set = $('.ribbon-set') | ||||||
| 	var current = data.current | 	var current = data.current | ||||||
| 	// XXX will this work without any images loaded?
 | 	// if no width is given, use the current or default...
 | ||||||
| 	var w = getScreenWidthInImages() | 	var w = images_per_screen == null ? getScreenWidthInImages() : images_per_screen | ||||||
|  | 	w = w > MAX_SCREEN_IMAGES ? DEFAULT_SCREEN_IMAGES : w | ||||||
| 
 | 
 | ||||||
|  | 	// clear data...
 | ||||||
| 	$('.ribbon').remove() | 	$('.ribbon').remove() | ||||||
| 
 | 
 | ||||||
| 	// create ribbons...
 | 	// create ribbons...
 | ||||||
| @ -656,6 +661,7 @@ function loadData(data){ | |||||||
| 
 | 
 | ||||||
| 	focusImage($('.image').filter('[gid='+JSON.stringify(current)+']')) | 	focusImage($('.image').filter('[gid='+JSON.stringify(current)+']')) | ||||||
| 
 | 
 | ||||||
|  | 	fitNImages(w) | ||||||
| 	centerRibbons('css') | 	centerRibbons('css') | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| @ -774,6 +780,7 @@ function toggleImageProportions(mode){ | |||||||
| 
 | 
 | ||||||
| function focusImage(image){ | function focusImage(image){ | ||||||
| 	image.closest('.viewer').find('.current.image').removeClass('current') | 	image.closest('.viewer').find('.current.image').removeClass('current') | ||||||
|  | 	$('.viewer').trigger('focusingImage', [image]) | ||||||
| 	return image.addClass('current') | 	return image.addClass('current') | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -231,21 +231,8 @@ | |||||||
| // setup... | // setup... | ||||||
| $(function(){ | $(function(){ | ||||||
| 
 | 
 | ||||||
| 	// populate the viewer... | 	loadData(DATA) | ||||||
| 	var r = createRibbon() |  | ||||||
| 	var images = [] |  | ||||||
| 	for(var i=0; i < 40; i++){ |  | ||||||
| 		images.push(createImage().text(i)[0])  |  | ||||||
| 	} |  | ||||||
| 	r.append($(images)) |  | ||||||
| 	//var rr = r.clone() |  | ||||||
| 	//var rrr = r.clone() |  | ||||||
| 
 | 
 | ||||||
| 	// XXX use something like loadImages()... |  | ||||||
| 	$('.ribbon-set') |  | ||||||
| 		.append(r) |  | ||||||
| 		//.append(rr) |  | ||||||
| 		//.append(rrr) |  | ||||||
| 
 | 
 | ||||||
| 	// 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... | ||||||
| @ -264,10 +251,6 @@ $(function(){ | |||||||
| 
 | 
 | ||||||
| 	if(DYNAMIC_LOADING){ | 	if(DYNAMIC_LOADING){ | ||||||
| 		// XXX move to a setup function in the lib... | 		// XXX move to a setup function in the lib... | ||||||
| 		// XXX update this depending on zoom and navigation speed... |  | ||||||
| 		LOAD_SCREENS = 2 |  | ||||||
| 		// XXX update this depending on zoom and navigation speed... |  | ||||||
| 		LOAD_THRESHOLD = 1 |  | ||||||
| 		$('.viewer') | 		$('.viewer') | ||||||
| 			// XXX still some times does not load the needed ribbon section | 			// XXX still some times does not load the needed ribbon section | ||||||
| 			//		on the first try... | 			//		on the first try... | ||||||
| @ -322,6 +305,7 @@ $(function(){ | |||||||
| 				*/ | 				*/ | ||||||
| 			}) | 			}) | ||||||
| 			/* | 			/* | ||||||
|  | 			// XXX BUGGY... | ||||||
| 			.on('centeringRibbon', function(evt, ribbon, image){ | 			.on('centeringRibbon', function(evt, ribbon, image){ | ||||||
| 				// check if we are in the right range... | 				// check if we are in the right range... | ||||||
| 				var gid = getImageGID(image) | 				var gid = getImageGID(image) | ||||||
| @ -402,6 +386,10 @@ $(function(){ | |||||||
| 			.on('fittingImages', function(evt, n){ | 			.on('fittingImages', function(evt, n){ | ||||||
| 				updateImages() | 				updateImages() | ||||||
| 			}) | 			}) | ||||||
|  | 
 | ||||||
|  | 			.on('focusingImage', function(evt, image){ | ||||||
|  | 				DATA.current = getImageGID($(image)) | ||||||
|  | 			}) | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user