mirror of
				https://github.com/flynx/PortableMag.git
				synced 2025-11-04 05:50:19 +00:00 
			
		
		
		
	some refactoring and tuneup...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
		
							parent
							
								
									1c9119767c
								
							
						
					
					
						commit
						bf8a47ed8b
					
				
							
								
								
									
										36
									
								
								lib/jli.js
									
									
									
									
									
								
							
							
						
						
									
										36
									
								
								lib/jli.js
									
									
									
									
									
								
							@ -10,6 +10,7 @@
 | 
				
			|||||||
//var DEBUG = DEBUG != null ? DEBUG : true
 | 
					//var DEBUG = DEBUG != null ? DEBUG : true
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/*********************************************************************/
 | 
					/*********************************************************************/
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// this will create a function that will cycle through a class_list on elem 
 | 
					// this will create a function that will cycle through a class_list on elem 
 | 
				
			||||||
@ -482,6 +483,9 @@ function makeKeyboardHandler(keybindings, unhandled){
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					var CLICK_THRESHOLD = 10
 | 
				
			||||||
 | 
					var LONG_CLICK_THRESHOLD = 400
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// XXX add a resonable cancel scheme...
 | 
					// XXX add a resonable cancel scheme...
 | 
				
			||||||
// 		... something similar to touch threshold but bigger...
 | 
					// 		... something similar to touch threshold but bigger...
 | 
				
			||||||
// XXX handle multiple touches...
 | 
					// XXX handle multiple touches...
 | 
				
			||||||
@ -696,7 +700,10 @@ function makeScrollHandler(root, config){
 | 
				
			|||||||
			eventBounds: 5,
 | 
								eventBounds: 5,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			// 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...
 | 
				
			||||||
 | 
								clickThreshold: null,
 | 
				
			||||||
 | 
								longClickThreshold: null,
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
		// 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',
 | 
				
			||||||
@ -748,17 +755,25 @@ function makeScrollHandler(root, config){
 | 
				
			|||||||
	return scroller
 | 
						return scroller
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
var CLICK_THRESHOLD = 10
 | 
					// default callback...
 | 
				
			||||||
var LONG_CLICK_THRESHOLD = 400
 | 
					// This will provide support for the folowing events on the scroll root
 | 
				
			||||||
 | 
					// element:
 | 
				
			||||||
 | 
					// 		- scrollCancelled
 | 
				
			||||||
// this is the default callback...
 | 
					// 		- longClick
 | 
				
			||||||
 | 
					// 		- shortClick
 | 
				
			||||||
 | 
					// 		- swipeLeft
 | 
				
			||||||
 | 
					// 		- swipeRight
 | 
				
			||||||
 | 
					// 		- screenReleased
 | 
				
			||||||
 | 
					//
 | 
				
			||||||
// XXX add up/down swipes
 | 
					// XXX add up/down swipes
 | 
				
			||||||
// XXX add double clicks
 | 
					// XXX add double clicks
 | 
				
			||||||
// XXX add generic snap
 | 
					// XXX add generic snap
 | 
				
			||||||
// XXX add generic innertial scroll
 | 
					// XXX add generic innertial scroll
 | 
				
			||||||
function postScrollCallback(data){
 | 
					function postScrollCallback(data){
 | 
				
			||||||
	var root = data.scroller.root
 | 
						var root = data.scroller.root
 | 
				
			||||||
 | 
						var clickThreshold = data.scroller.options.clickThreshold || CLICK_THRESHOLD
 | 
				
			||||||
 | 
						var longClickThreshold = data.scroller.options.longClickThreshold || LONG_CLICK_THRESHOLD
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// cancel event...
 | 
						// cancel event...
 | 
				
			||||||
	if(data.scroller.state == 'canceling'){
 | 
						if(data.scroller.state == 'canceling'){
 | 
				
			||||||
		return root.trigger('scrollCancelled', data)
 | 
							return root.trigger('scrollCancelled', data)
 | 
				
			||||||
@ -771,8 +786,8 @@ function postScrollCallback(data){
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// clicks and long clicks...
 | 
						// clicks and long clicks...
 | 
				
			||||||
	if(Math.abs(data.distance) < CLICK_THRESHOLD){
 | 
						if(Math.abs(data.distance) < clickThreshold){
 | 
				
			||||||
		if(data.duration > LONG_CLICK_THRESHOLD){
 | 
							if(data.duration > longClickThreshold){
 | 
				
			||||||
			return root.trigger('longClick', data) 
 | 
								return root.trigger('longClick', data) 
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		return root.trigger('shortClick', data)
 | 
							return root.trigger('shortClick', data)
 | 
				
			||||||
@ -780,10 +795,11 @@ function postScrollCallback(data){
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	// left/right swipes...
 | 
						// left/right swipes...
 | 
				
			||||||
	// XXX add up/down support...
 | 
						// XXX add up/down support...
 | 
				
			||||||
	if(data.distance <= -CLICK_THRESHOLD){
 | 
						// XXX check if these are bound...
 | 
				
			||||||
 | 
						if(data.distance <= -clickThreshold){
 | 
				
			||||||
		return root.trigger('swipeLeft', data)
 | 
							return root.trigger('swipeLeft', data)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	if(data.distance >= CLICK_THRESHOLD){
 | 
						if(data.distance >= clickThreshold){
 | 
				
			||||||
		return root.trigger('swipeRight', data)
 | 
							return root.trigger('swipeRight', data)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user