mirror of
				https://github.com/flynx/PortableMag.git
				synced 2025-10-30 19:40:12 +00:00 
			
		
		
		
	fixed an navigator indicator bug...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
		
							parent
							
								
									ade8832372
								
							
						
					
					
						commit
						b5cbd895d6
					
				
							
								
								
									
										5
									
								
								TODO.otl
									
									
									
									
									
								
							
							
						
						
									
										5
									
								
								TODO.otl
									
									
									
									
									
								
							| @ -1,6 +1,5 @@ | |||||||
| [_] 37% Priority work | [_] 37% Priority work | ||||||
| 	[_] 65% general todo | 	[_] 66% general todo | ||||||
| 		[X] JSON load/save |  | ||||||
| 		[_] 0% Version 1.0 checklist (migration to layout.html) | 		[_] 0% Version 1.0 checklist (migration to layout.html) | ||||||
| 			[_] page scaling for full page view | 			[_] page scaling for full page view | ||||||
| 			[_] top/bottom toolbars | 			[_] top/bottom toolbars | ||||||
| @ -174,6 +173,8 @@ | |||||||
| 			[_] try using the scroll event to see of we reached the limit... | 			[_] try using the scroll event to see of we reached the limit... | ||||||
| 			| and move the limit accordingly | 			| and move the limit accordingly | ||||||
| 			[_] BUG: scrool seems to do odd things on refresh... | 			[_] BUG: scrool seems to do odd things on refresh... | ||||||
|  | 		[X] JSON load/save | ||||||
|  | 		[X] BUG: navigator indicator does not scroll | ||||||
| 		[X] check if scrollTo knows about element scaling... | 		[X] check if scrollTo knows about element scaling... | ||||||
| 		| if not update the code.... | 		| if not update the code.... | ||||||
| 		[X] Editor: make the editor switchable... | 		[X] Editor: make the editor switchable... | ||||||
|  | |||||||
| @ -112,8 +112,6 @@ $(document).ready(function(){ | |||||||
| 		},  | 		},  | ||||||
| 		function(k){console.log(k)})) | 		function(k){console.log(k)})) | ||||||
| 
 | 
 | ||||||
| 
 |  | ||||||
| 	// XXX make this a default setup in the lib... |  | ||||||
| 	window.MagazineScroller = makeScrollHandler($('.viewer'), { | 	window.MagazineScroller = makeScrollHandler($('.viewer'), { | ||||||
| 		hScroll: true, | 		hScroll: true, | ||||||
| 		vScroll: false, | 		vScroll: false, | ||||||
|  | |||||||
| @ -170,12 +170,12 @@ function handleScrollRelease(evt, data){ | |||||||
| 	} else { | 	} else { | ||||||
| 		if(at > first){ | 		if(at > first){ | ||||||
| 			setTransitionEasing(mag, 'ease-in') | 			setTransitionEasing(mag, 'ease-in') | ||||||
| 			setTransitionDuration(mag, DEFAULT_TRANSITION_DURATION) | 			setTransitionDuration(mag, DEFAULT_TRANSITION_DURATION/2) | ||||||
| 			setElementTransform(mag, first) | 			setElementTransform(mag, first) | ||||||
| 
 | 
 | ||||||
| 		} else if(at < last){ | 		} else if(at < last){ | ||||||
| 			setTransitionEasing(mag, 'ease-in') | 			setTransitionEasing(mag, 'ease-in') | ||||||
| 			setTransitionDuration(mag, DEFAULT_TRANSITION_DURATION) | 			setTransitionDuration(mag, DEFAULT_TRANSITION_DURATION/2) | ||||||
| 			setElementTransform(mag, last) | 			setElementTransform(mag, last) | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
|  | |||||||
							
								
								
									
										38
									
								
								lib/jli.js
									
									
									
									
									
								
							
							
						
						
									
										38
									
								
								lib/jli.js
									
									
									
									
									
								
							| @ -487,10 +487,14 @@ function makeKeyboardHandler(keybindings, unhandled){ | |||||||
| // less than this, the whole event is considered a click and not a 
 | // less than this, the whole event is considered a click and not a 
 | ||||||
| // drag/swipe...
 | // drag/swipe...
 | ||||||
| var CLICK_THRESHOLD = 10 | var CLICK_THRESHOLD = 10 | ||||||
|  | 
 | ||||||
| // if the amount of time to wait beween start and end is greater than this
 | // if the amount of time to wait beween start and end is greater than this
 | ||||||
| // the event is considered a long click.
 | // the event is considered a long click.
 | ||||||
| // NOTE: this will not auto-fire the event, the user MUST release first.
 | // NOTE: this will not auto-fire the event, the user MUST release first.
 | ||||||
| var LONG_CLICK_THRESHOLD = 400 | var LONG_CLICK_THRESHOLD = 400 | ||||||
|  | 
 | ||||||
|  | // the maximum amount of time between clicks to count them together.
 | ||||||
|  | // NOTE: if multi-clicks are disabled this has no effect.
 | ||||||
| // NOTE: this is reset by the timeout explicitly set in the handler...
 | // NOTE: this is reset by the timeout explicitly set in the handler...
 | ||||||
| // NOTE: this is the timeout between two consecutive clicks and not the total.
 | // NOTE: this is the timeout between two consecutive clicks and not the total.
 | ||||||
| // NOTE: if multiple clicks are enabled this will introduce a lag after
 | // NOTE: if multiple clicks are enabled this will introduce a lag after
 | ||||||
| @ -498,6 +502,8 @@ var LONG_CLICK_THRESHOLD = 400 | |||||||
| // 		as possible.
 | // 		as possible.
 | ||||||
| var MULTI_CLICK_TIMEOUT = 200 | var MULTI_CLICK_TIMEOUT = 200 | ||||||
| 
 | 
 | ||||||
|  | // the amount of time between finger releases.
 | ||||||
|  | // NOTE: when this is passed all the fingers released before are ignored.
 | ||||||
| var MULTITOUCH_RELEASE_THRESHOLD = 100 | var MULTITOUCH_RELEASE_THRESHOLD = 100 | ||||||
| 
 | 
 | ||||||
| // XXX add a resonable cancel scheme...
 | // XXX add a resonable cancel scheme...
 | ||||||
| @ -510,6 +516,8 @@ var MULTITOUCH_RELEASE_THRESHOLD = 100 | |||||||
| // XXX BUG: on landing a second finger while scrolling the things goes 
 | // XXX BUG: on landing a second finger while scrolling the things goes 
 | ||||||
| // 		haywhire...
 | // 		haywhire...
 | ||||||
| // 		...check if this is gone...
 | // 		...check if this is gone...
 | ||||||
|  | // XXX add something like a scrollTo that would understand elements as 
 | ||||||
|  | // 		well as explicit positions.
 | ||||||
| // XXX split this into a seporate lib...
 | // XXX split this into a seporate lib...
 | ||||||
| function makeScrollHandler(root, config){ | function makeScrollHandler(root, config){ | ||||||
| 	root = $(root) | 	root = $(root) | ||||||
| @ -707,11 +715,12 @@ function makeScrollHandler(root, config){ | |||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| 	var scroller = { | 	var scroller = { | ||||||
| 		root: root, |  | ||||||
| 		options: { | 		options: { | ||||||
| 			// if one of these is false, it will restrict scrolling in 
 | 			// if one of these is false, it will restrict scrolling in 
 | ||||||
| 			// that direction. hScroll for horizontal and vScroll for 
 | 			// that direction. hScroll for horizontal and vScroll for 
 | ||||||
| 			// vertical.
 | 			// vertical.
 | ||||||
|  | 			// NOTE: to disable scroll completely use scrollDisabled, see
 | ||||||
|  | 			// 		below for details.
 | ||||||
| 			hScroll: true, | 			hScroll: true, | ||||||
| 			vScroll: true, | 			vScroll: true, | ||||||
| 
 | 
 | ||||||
| @ -728,12 +737,15 @@ function makeScrollHandler(root, config){ | |||||||
| 
 | 
 | ||||||
| 			// items to be ignored by the scroller...
 | 			// items to be ignored by the scroller...
 | ||||||
| 			// this is a jQuery compatible selector.
 | 			// this is a jQuery compatible selector.
 | ||||||
| 			ignoreElements: '.noSwipe', | 			ignoreElements: '.noScroll', | ||||||
| 			// this is the side of the rectangle if the user movees out of
 | 			// this is the side of the rectangle in px, if the user moves
 | ||||||
| 			// and then returns back to the action will get cancelled.
 | 			// out of it, and then returns back, the action will get cancelled.
 | ||||||
| 			// i.e. the callback will get called with the "cancelling" state.
 | 			// i.e. the callback will get called with the "cancelling" state.
 | ||||||
| 			scrollCancelThreshold: 100, | 			scrollCancelThreshold: 100, | ||||||
| 
 | 
 | ||||||
|  | 			// these control weather in-scroll events will get triggered.
 | ||||||
|  | 			// NOTE: these may impact performance, especially the scroll 
 | ||||||
|  | 			// 		event, thus they need to enabled explicitly.
 | ||||||
| 			enabelStartEvent: false, | 			enabelStartEvent: false, | ||||||
| 			enableUserScrollEvent: false, | 			enableUserScrollEvent: false, | ||||||
| 			enableEndEvent: false, | 			enableEndEvent: false, | ||||||
| @ -744,11 +756,20 @@ function makeScrollHandler(root, config){ | |||||||
| 			autoCancelEvents: false, | 			autoCancelEvents: false, | ||||||
| 			eventBounds: 5, | 			eventBounds: 5, | ||||||
| 
 | 
 | ||||||
| 
 | 			// callback to be called when the user lifts a finger/mouse.
 | ||||||
|  | 			// NOTE: this may happen before the scroll is done, for instance
 | ||||||
|  | 			// 		when one of several fingers participating in the action
 | ||||||
|  | 			// 		gets lifted.
 | ||||||
| 			// NOTE: if this returns false explicitly, this will stop scrolling.
 | 			// NOTE: if this returns false explicitly, this will stop scrolling.
 | ||||||
| 			callback: postScrollCallback, | 			callback: postScrollCallback, | ||||||
| 
 | 
 | ||||||
| 			// These are used by the default callback...
 | 			// These are used by the default callback...
 | ||||||
|  | 			// if true then doubleClick and multiClick events will get 
 | ||||||
|  | 			// triggered.
 | ||||||
|  | 			// NOTE: this will introduce a lag needed to wait for next 
 | ||||||
|  | 			// 		clicks in a group.
 | ||||||
|  | 			// NOTE: when this is false, shortClick is triggered for every 
 | ||||||
|  | 			// 		single click separately.
 | ||||||
| 			enableMultiClicks: false, | 			enableMultiClicks: false, | ||||||
| 			// NOTE: if these are null, respective values from the env will
 | 			// NOTE: if these are null, respective values from the env will
 | ||||||
| 			// 		be used.
 | 			// 		be used.
 | ||||||
| @ -759,6 +780,7 @@ function makeScrollHandler(root, config){ | |||||||
| 		}, | 		}, | ||||||
| 		// NOTE: this is updated live but not used by the system in any way...
 | 		// NOTE: this is updated live but not used by the system in any way...
 | ||||||
| 		state: 'stopped', | 		state: 'stopped', | ||||||
|  | 		root: root, | ||||||
| 
 | 
 | ||||||
| 		start: function(){ | 		start: function(){ | ||||||
| 			this.state = 'waiting' | 			this.state = 'waiting' | ||||||
| @ -835,6 +857,7 @@ function makeScrollHandler(root, config){ | |||||||
| // 		same field when it recieves the object.
 | // 		same field when it recieves the object.
 | ||||||
| // XXX add generic snap
 | // XXX add generic snap
 | ||||||
| // XXX add generic innertial scroll
 | // XXX add generic innertial scroll
 | ||||||
|  | // XXX test multiple touches...
 | ||||||
| function postScrollCallback(data){ | function postScrollCallback(data){ | ||||||
| 	var scroller = data.scroller | 	var scroller = data.scroller | ||||||
| 	var options = scroller.options | 	var options = scroller.options | ||||||
| @ -853,7 +876,6 @@ function postScrollCallback(data){ | |||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	// handle multiple touches...
 | 	// handle multiple touches...
 | ||||||
| 	// XXX needs testing...
 |  | ||||||
| 	if(data.touches > 0){ | 	if(data.touches > 0){ | ||||||
| 		var then = scroller._last_touch_release | 		var then = scroller._last_touch_release | ||||||
| 		if(then == null || now - then < multitouchTimeout){ | 		if(then == null || now - then < multitouchTimeout){ | ||||||
| @ -919,9 +941,7 @@ function postScrollCallback(data){ | |||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	// swipes...
 | 	// swipes...
 | ||||||
| 	// XXX make these less brain dead...
 | 	// XXX might be a good idea to chain these with swipe and screenReleased
 | ||||||
| 	// 		...when all is OK also call screenReleased (chain events)
 |  | ||||||
| 	// 		also would be nice to add a generic swipe event...
 |  | ||||||
| 	if(Math.abs(data.distance.x) > Math.abs(data.distance.y)){ | 	if(Math.abs(data.distance.x) > Math.abs(data.distance.y)){ | ||||||
| 		if(data.distance.x <= -clickThreshold && root.data('events').swipeLeft){ | 		if(data.distance.x <= -clickThreshold && root.data('events').swipeLeft){ | ||||||
| 			return root.trigger('swipeLeft', data) | 			return root.trigger('swipeLeft', data) | ||||||
|  | |||||||
| @ -77,8 +77,9 @@ function updateNavigator(n){ | |||||||
| 	var pW = bar.width()/pn | 	var pW = bar.width()/pn | ||||||
| 
 | 
 | ||||||
| 	if(n == null){ | 	if(n == null){ | ||||||
|  | 		var left = getMagazineShift() | ||||||
| 		// XXX this behaves erratically if the page is zoomed...
 | 		// XXX this behaves erratically if the page is zoomed...
 | ||||||
| 		var res = (-parseFloat(mag.css('left'))/(mW-PW)) * (bW-pW) | 		var res = (Math.abs(left)/(mW-PW)) * (bW-pW) | ||||||
| 	} else { | 	} else { | ||||||
| 		res = pW*n | 		res = pW*n | ||||||
| 	} | 	} | ||||||
| @ -88,6 +89,7 @@ function updateNavigator(n){ | |||||||
| 	res = res < (bW-pW) ? res: (bW-pW) | 	res = res < (bW-pW) ? res: (bW-pW) | ||||||
| 
 | 
 | ||||||
| 	// set indicator position...
 | 	// set indicator position...
 | ||||||
|  | 	console.log('>>>', res) | ||||||
| 	pos.css({ | 	pos.css({ | ||||||
| 		left: res  | 		left: res  | ||||||
| 	}) | 	}) | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user