mirror of
				https://github.com/flynx/PortableMag.git
				synced 2025-10-31 03:50:16 +00:00 
			
		
		
		
	added fitting of pages...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
		
							parent
							
								
									9b9c7deaf2
								
							
						
					
					
						commit
						92db9383a6
					
				
							
								
								
									
										29
									
								
								index.html
									
									
									
									
									
								
							
							
						
						
									
										29
									
								
								index.html
									
									
									
									
									
								
							| @ -6,17 +6,27 @@ | |||||||
| <script src="jquery.touchSwipe.js"></script> | <script src="jquery.touchSwipe.js"></script> | ||||||
| <script> | <script> | ||||||
| 
 | 
 | ||||||
|  | /* this is needed only for live resize... */ | ||||||
|  | var PAGES_VISIBLE = 1 | ||||||
|  | 
 | ||||||
| $(document).ready(function(){ | $(document).ready(function(){ | ||||||
|  | 	$(window).resize(function() { | ||||||
|  | 		fitNPages(PAGES_VISIBLE) | ||||||
|  | 	}) | ||||||
| 	$('.viewer') | 	$('.viewer') | ||||||
| 		.swipe({ | 		.swipe({ | ||||||
| 			//swipeLeft: nextPage, | 			//swipeLeft: nextPage, | ||||||
| 			//swipeRight: prevPage, | 			//swipeRight: prevPage, | ||||||
| 			swipeStatus: swipeUpdate, | 			swipeStatus: swipeUpdate, | ||||||
| 			// XXX change this to pinch... | 			// XXX change this to pinch... | ||||||
| 			swipeUp: function(){fitNPages(6)}, | 			swipeUp: function(){ | ||||||
|  | 				PAGES_VISIBLE = 6 | ||||||
|  | 				fitNPages(PAGES_VISIBLE) | ||||||
|  | 			}, | ||||||
| 			// XXX change this to pinch... | 			// XXX change this to pinch... | ||||||
| 			swipeDown: function(){ | 			swipeDown: function(){ | ||||||
| 				fitNPages(1) | 				PAGES_VISIBLE = 1 | ||||||
|  | 				fitNPages(PAGES_VISIBLE) | ||||||
| 				// to prevent drag while zooming to affect | 				// to prevent drag while zooming to affect | ||||||
| 				// the resulting position set it to current  | 				// the resulting position set it to current  | ||||||
| 				// page... | 				// page... | ||||||
| @ -32,7 +42,8 @@ $(document).ready(function(){ | |||||||
| 
 | 
 | ||||||
| 	// XXX add splash screen... | 	// XXX add splash screen... | ||||||
| 
 | 
 | ||||||
| 	fitNPages(1) | 	fitNPages(PAGES_VISIBLE) | ||||||
|  | 
 | ||||||
| }) | }) | ||||||
| 
 | 
 | ||||||
| function swipeUpdate(evt, phase, direction, distance){ | function swipeUpdate(evt, phase, direction, distance){ | ||||||
| @ -74,14 +85,13 @@ function swipeUpdate(evt, phase, direction, distance){ | |||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| function setCurrentPage(n){ | function setCurrentPage(n){ | ||||||
| 	var cur |  | ||||||
| 	if(n == null){ | 	if(n == null){ | ||||||
| 		cur = $('.current.page') | 		var cur = $('.current.page') | ||||||
| 		n = $('.page').index(cur)  | 		n = $('.page').index(cur)  | ||||||
| 	} else if(typeof(n) == typeof(1)) { | 	} else if(typeof(n) == typeof(1)) { | ||||||
| 		cur = $($('.page')[n]) | 		var cur = $($('.page')[n]) | ||||||
| 	} else { | 	} else { | ||||||
| 		cur = n | 		var cur = $(n) | ||||||
| 		n = $('.page').index(cur)  | 		n = $('.page').index(cur)  | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| @ -191,6 +201,11 @@ function fitNPages(n){ | |||||||
| 	var pages = $('.page') | 	var pages = $('.page') | ||||||
| 	var scale = $('.viewer').width()/(pages.width()*n) | 	var scale = $('.viewer').width()/(pages.width()*n) | ||||||
| 
 | 
 | ||||||
|  | 	// fit vertically if needed... | ||||||
|  | 	if(pages.height()*scale > $('.viewer').height()){ | ||||||
|  | 		scale = $('.viewer').height()/pages.height() | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
| 	setElementScale($('.scaler'), scale) | 	setElementScale($('.scaler'), scale) | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user