mirror of
				https://github.com/flynx/PortableMag.git
				synced 2025-10-31 12:00:11 +00:00 
			
		
		
		
	minor refactoring and decupling...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
		
							parent
							
								
									e24ba60a13
								
							
						
					
					
						commit
						c66ca38357
					
				
							
								
								
									
										19
									
								
								magazine.js
									
									
									
									
									
								
							
							
						
						
									
										19
									
								
								magazine.js
									
									
									
									
									
								
							| @ -83,7 +83,6 @@ function hashChangeHandler(e){ | |||||||
| 	var r = loadURLState() | 	var r = loadURLState() | ||||||
| 	// if we are dealing with history actions the browser will 
 | 	// if we are dealing with history actions the browser will 
 | ||||||
| 	// do the work for us...
 | 	// do the work for us...
 | ||||||
| 	// XXX revise...
 |  | ||||||
| 	if(r == 'back'){ | 	if(r == 'back'){ | ||||||
| 		// we shift by 2 to combensate for the back/forward URL itself...
 | 		// we shift by 2 to combensate for the back/forward URL itself...
 | ||||||
| 		window.history.go(-2) | 		window.history.go(-2) | ||||||
| @ -96,9 +95,9 @@ function hashChangeHandler(e){ | |||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| // window resize event handler...
 | // window resize event handler...
 | ||||||
|  | // XXX might be good to compensate for document zoom...
 | ||||||
| function viewResizeHandler(){ | function viewResizeHandler(){ | ||||||
| 	/* | 	/* | ||||||
| 	// XXX might be good to compensate for document zoom...
 |  | ||||||
| 	if(document.width/$(document).width() != 1){ | 	if(document.width/$(document).width() != 1){ | ||||||
| 		// XXX scale the page...
 | 		// XXX scale the page...
 | ||||||
| 		console.log('>>> Page Zoom:', document.width/$(document).width()) | 		console.log('>>> Page Zoom:', document.width/$(document).width()) | ||||||
| @ -116,6 +115,7 @@ function viewResizeHandler(){ | |||||||
| 
 | 
 | ||||||
| // swipe state handler
 | // swipe state handler
 | ||||||
| // this handles single and double finger swipes and dragging
 | // this handles single and double finger swipes and dragging
 | ||||||
|  | // while draggign this triggers magazineDragging event on the viewer...
 | ||||||
| function swipeHandler(evt, phase, direction, distance, duration, fingers){ | function swipeHandler(evt, phase, direction, distance, duration, fingers){ | ||||||
| 	var pages = $('.page') | 	var pages = $('.page') | ||||||
| 	var cur = $('.current.page') | 	var cur = $('.current.page') | ||||||
| @ -134,8 +134,8 @@ function swipeHandler(evt, phase, direction, distance, duration, fingers){ | |||||||
| 		} else if(direction == 'right') { | 		} else if(direction == 'right') { | ||||||
| 			mag.css({left: -n*cur.width()+distance/scale}) | 			mag.css({left: -n*cur.width()+distance/scale}) | ||||||
| 		} | 		} | ||||||
| 		// XXX should this be here...
 | 
 | ||||||
| 		updateNavigator() | 		$('.viewer').trigger('magazineDragging') | ||||||
| 
 | 
 | ||||||
| 	} else if(phase == 'start'){ | 	} else if(phase == 'start'){ | ||||||
| 		togglePageDragging('on') | 		togglePageDragging('on') | ||||||
| @ -484,12 +484,15 @@ function _makeArticleIndicator(i, article, width){ | |||||||
| 	return article | 	return article | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | 
 | ||||||
| function setupArticleIndicators(W){ | function setupArticleIndicators(W){ | ||||||
| 	var articles = $('.magazine .article') | 	var articles = $('.magazine .article') | ||||||
| 	// cleanup...
 | 	// cleanup...
 | ||||||
| 	$('.indicator .bar .article').remove() | 	$('.indicator .bar .article').remove() | ||||||
| 	// set article positions...
 | 	// set article indicator positions...
 | ||||||
| 	articles.each(function(i, e){return _makeArticleIndicator(i, e, W)}) | 	articles.each(function(i, e){ | ||||||
|  | 		return _makeArticleIndicator(i, e, W) | ||||||
|  | 	}) | ||||||
| } | } | ||||||
| 	 | 	 | ||||||
| 
 | 
 | ||||||
| @ -512,7 +515,9 @@ function setupNavigator(){ | |||||||
| 	updateNavigator() | 	updateNavigator() | ||||||
| 	 | 	 | ||||||
| 	// setup event handlers...
 | 	// setup event handlers...
 | ||||||
| 	$('.viewer').on('pageChanged', function(e, n){updateNavigator(n)}) | 	$('.viewer') | ||||||
|  | 		.on('pageChanged', function(e, n){updateNavigator(n)}) | ||||||
|  | 		.on('magazineDragging', function(){updateNavigator()}) | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user