mirror of
				https://github.com/flynx/ImageGrid.git
				synced 2025-10-30 19:00:09 +00:00 
			
		
		
		
	started adding zooming support to experiment...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
		
							parent
							
								
									2656eaf14e
								
							
						
					
					
						commit
						287b5c8f96
					
				| @ -33,7 +33,11 @@ function squareClick(){ | |||||||
| 	centerSquare() | 	centerSquare() | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| function centerSquare(){ | function centerSquare(zoom){ | ||||||
|  | 	// defaults... | ||||||
|  | 	if (zoom == null){ | ||||||
|  | 		zoom = $('.container').css('zoom') | ||||||
|  | 	} | ||||||
| 	var ribbons = $('.ribbon') | 	var ribbons = $('.ribbon') | ||||||
| 	var ribbon = $('.ribbon.current') | 	var ribbon = $('.ribbon.current') | ||||||
| 	var squares = ribbon.children('.square') | 	var squares = ribbon.children('.square') | ||||||
| @ -51,13 +55,13 @@ function centerSquare(){ | |||||||
| 	// relative position to container...  | 	// relative position to container...  | ||||||
| 	// XXX is there a better way to get this? | 	// XXX is there a better way to get this? | ||||||
| 	var t = rn * (h - mh/2) | 	var t = rn * (h - mh/2) | ||||||
| 	$('.container').css({'margin-top': -t + H/2 + h/2}) | 	$('.container').css({'margin-top': (-t + H/zoom/2 + h/2)}) | ||||||
| 
 | 
 | ||||||
| 	// horizontal... | 	// horizontal... | ||||||
| 	alignRibbon() | 	alignRibbon() | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| function alignRibbon(square, position){ | function alignRibbon(square, position, zoom){ | ||||||
| 	// default values... | 	// default values... | ||||||
| 	if(position == null){ | 	if(position == null){ | ||||||
| 		position = 'center' | 		position = 'center' | ||||||
| @ -65,6 +69,10 @@ function alignRibbon(square, position){ | |||||||
| 	if(square == null){ | 	if(square == null){ | ||||||
| 		square = $('.square.current') | 		square = $('.square.current') | ||||||
| 	} | 	} | ||||||
|  | 	// defaults... | ||||||
|  | 	if (zoom == null){ | ||||||
|  | 		zoom = $('.container').css('zoom') | ||||||
|  | 	} | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| 	var ribbon = square.parents('.ribbon') | 	var ribbon = square.parents('.ribbon') | ||||||
| @ -81,18 +89,26 @@ function alignRibbon(square, position){ | |||||||
| 
 | 
 | ||||||
| 	switch(position){ | 	switch(position){ | ||||||
| 		case 'before': | 		case 'before': | ||||||
| 			ribbon.css({'margin-left': -l + W/2 + w}) | 			ribbon.css({'margin-left': (-l + W/zoom/2 + w)}) | ||||||
| 			return true | 			return true | ||||||
| 		case 'center': | 		case 'center': | ||||||
| 			ribbon.css({'margin-left': -l + W/2 + w/2}) | 			ribbon.css({'margin-left': (-l + W/zoom/2 + w/2)}) | ||||||
| 			return true | 			return true | ||||||
| 		case 'after': | 		case 'after': | ||||||
| 			ribbon.css({'margin-left': -l + W/2}) | 			ribbon.css({'margin-left': (-l + W/zoom/2)}) | ||||||
| 			return true | 			return true | ||||||
| 	} | 	} | ||||||
| 	return false | 	return false | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | // XXX need to compensate for zoom-shift (container.margin-top & ribbon.margin-left)... | ||||||
|  | function zoomIn(){ | ||||||
|  | 	$('.container').css({'zoom': $('.container').css('zoom') * 2}) | ||||||
|  | } | ||||||
|  | function zoomOut(){ | ||||||
|  | 	$('.container').css({'zoom': $('.container').css('zoom') * 0.5}) | ||||||
|  | } | ||||||
|  | 
 | ||||||
| 
 | 
 | ||||||
| </script> | </script> | ||||||
| 
 | 
 | ||||||
| @ -131,6 +147,8 @@ function alignRibbon(square, position){ | |||||||
| 	-o-transition: all 0.5s ease; | 	-o-transition: all 0.5s ease; | ||||||
| 	-ms-transition: all 0.5s ease;	 | 	-ms-transition: all 0.5s ease;	 | ||||||
| 	transition: all 0.5s ease; | 	transition: all 0.5s ease; | ||||||
|  | 
 | ||||||
|  | 	zoom: 1; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| .ribbon { | .ribbon { | ||||||
| @ -169,6 +187,13 @@ function alignRibbon(square, position){ | |||||||
| 
 | 
 | ||||||
| </style> | </style> | ||||||
| 
 | 
 | ||||||
|  | <button onclick="zoomIn()">+</button> | ||||||
|  | <button onclick="zoomOut()">-</button> | ||||||
|  | 
 | ||||||
|  | <br> | ||||||
|  | <br> | ||||||
|  | <br> | ||||||
|  | 
 | ||||||
| <div class="meta-container"> | <div class="meta-container"> | ||||||
| 	<div class="container"> | 	<div class="container"> | ||||||
| 		<div class="ribbon"> | 		<div class="ribbon"> | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user