mirror of
				https://github.com/flynx/ImageGrid.git
				synced 2025-10-31 03:10:07 +00:00 
			
		
		
		
	added fitRibbon(..) to ribbons.js and friends...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
		
							parent
							
								
									635cd9a358
								
							
						
					
					
						commit
						e5f2e14022
					
				| @ -1554,6 +1554,36 @@ module.RibbonsPrototype = { | |||||||
| 		 | 		 | ||||||
| 		return this | 		return this | ||||||
| 	}, | 	}, | ||||||
|  | 	// NOTE: if fit_whole_images is true (default) this will fit a discrete
 | ||||||
|  | 	// 		number of images in width...
 | ||||||
|  | 	// XXX this does not account for ribbon spacing...
 | ||||||
|  | 	fitRibbon: function(n, fit_whole_images){ | ||||||
|  | 		fit_whole_images = fit_whole_images == null ? true : false | ||||||
|  | 
 | ||||||
|  | 		var h = this.getVisibleImageSize('height', 1) | ||||||
|  | 		var scale = this.viewer.height() / (h * n) | ||||||
|  | 
 | ||||||
|  | 		var w = this.getVisibleImageSize('width', 1) | ||||||
|  | 		var W = this.viewer.width() | ||||||
|  | 
 | ||||||
|  | 		// n ribbons will be wider than the viewer...
 | ||||||
|  | 		if(w*scale >= W){ | ||||||
|  | 			scale = W/w | ||||||
|  | 		} | ||||||
|  | 
 | ||||||
|  | 		// shift the scale to the point where screen width is a whole 
 | ||||||
|  | 		// number of images...
 | ||||||
|  | 		if(fit_whole_images){ | ||||||
|  | 			var d = this.getScreenWidthImages(scale) | ||||||
|  | 			d = d / Math.ceil(d) | ||||||
|  | 
 | ||||||
|  | 			scale *= d | ||||||
|  | 		} | ||||||
|  | 
 | ||||||
|  | 		this.setScale(scale) | ||||||
|  | 
 | ||||||
|  | 		return this | ||||||
|  | 	}, | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| 	_setup: function(viewer, images){ | 	_setup: function(viewer, images){ | ||||||
|  | |||||||
| @ -135,11 +135,17 @@ module.GLOBAL_KEYBOARD = { | |||||||
| 			ctrl: 'fitOrig!', | 			ctrl: 'fitOrig!', | ||||||
| 		}, | 		}, | ||||||
| 		'#2': 'fitTwo', | 		'#2': 'fitTwo', | ||||||
| 		'#3': 'fitThree', | 		'#3': { | ||||||
|  | 			default: 'fitThree', | ||||||
|  | 			shift: 'fitThreeRibbons', | ||||||
|  | 		}, | ||||||
| 		'#4': 'fitFour', | 		'#4': 'fitFour', | ||||||
| 		'#5': 'fitFive', | 		'#5': { | ||||||
|  | 			default: 'fitFive', | ||||||
|  | 			shift: 'fitFiveRibbons', | ||||||
|  | 		}, | ||||||
| 		'#6': 'fitSix', | 		'#6': 'fitSix', | ||||||
| 		'#7': 'fitSeven', | 		'#7': 'fitSevenr', | ||||||
| 		'#8':'fitEight', | 		'#8':'fitEight', | ||||||
| 		'#9': 'fitNine', | 		'#9': 'fitNine', | ||||||
| 		 | 		 | ||||||
|  | |||||||
| @ -839,6 +839,7 @@ actions.Actions(Client, { | |||||||
| 	fitMax: ['Fit the maximum number of images', | 	fitMax: ['Fit the maximum number of images', | ||||||
| 		function(){ this.fitImage(this.config['max-screen-images']) }], | 		function(){ this.fitImage(this.config['max-screen-images']) }], | ||||||
| 
 | 
 | ||||||
|  | 
 | ||||||
| 	// XXX
 | 	// XXX
 | ||||||
| 	fitSmall: ['Show small image', | 	fitSmall: ['Show small image', | ||||||
| 		function(){  }], | 		function(){  }], | ||||||
| @ -850,6 +851,18 @@ actions.Actions(Client, { | |||||||
| 		function(){  }], | 		function(){  }], | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  | 	fitRibbon: ['Fit ribbon vertically', | ||||||
|  | 		function(count){ | ||||||
|  | 			this.ribbons.fitRibbon(count) | ||||||
|  | 			this.ribbons.updateImage('*') | ||||||
|  | 		}], | ||||||
|  | 
 | ||||||
|  | 	// XXX is n + 0.5 a good number here???
 | ||||||
|  | 	fitThreeRibbons: ['Fit three ribbons vertically', function(){ this.fitRibbon(3.5) }], | ||||||
|  | 	fitFiveRibbons: ['Fit five ribbons vertically', function(){ this.fitRibbon(5.5) }], | ||||||
|  | 	fitSevenRibbon: ['Fit seven ribbons vertically', function(){ this.fitRibbon(7.5) }], | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
| 	// NOTE: these work by getting the target position from .data...
 | 	// NOTE: these work by getting the target position from .data...
 | ||||||
| 	shiftImageTo: [  | 	shiftImageTo: [  | ||||||
| 		function(target){ return updateImagePosition(this, target) }], | 		function(target){ return updateImagePosition(this, target) }], | ||||||
| @ -1350,10 +1363,7 @@ module.CurrentImageIndicator = Feature({ | |||||||
| 				} | 				} | ||||||
| 			}) | 			}) | ||||||
| 			// hide marker on shift left/right and show it after done shifting...
 | 			// hide marker on shift left/right and show it after done shifting...
 | ||||||
| 			.on([ | 			.on('shiftImageLeft.pre shiftImageRight.pre', this.tag, function(){ | ||||||
| 					'shiftImageLeft.pre', |  | ||||||
| 					'shiftImageRight.pre', |  | ||||||
| 				], this.tag, function(){ |  | ||||||
| 					this.ribbons.viewer.find('.current-marker').hide() | 					this.ribbons.viewer.find('.current-marker').hide() | ||||||
| 					if(timeout != null){ | 					if(timeout != null){ | ||||||
| 						clearTimeout(timeout) | 						clearTimeout(timeout) | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user