mirror of
				https://github.com/flynx/ImageGrid.git
				synced 2025-10-31 11:20:09 +00:00 
			
		
		
		
	some optimisation and cleanup...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
		
							parent
							
								
									d399a6b194
								
							
						
					
					
						commit
						8872ee6241
					
				| @ -145,33 +145,25 @@ var RibbonsPrototype = { | |||||||
| 	// 	.preventTransitions(elem)
 | 	// 	.preventTransitions(elem)
 | ||||||
| 	// 		-> data
 | 	// 		-> data
 | ||||||
| 	//
 | 	//
 | ||||||
| 	// 	Prevent transitions on this and all nested calls
 |  | ||||||
| 	// 	.preventTransitions(.., true)
 |  | ||||||
| 	// 		-> data
 |  | ||||||
| 	//
 |  | ||||||
| 	// 		NOTE: all *nested* calls to this and .restoreTransitions(..)
 |  | ||||||
| 	// 			will be ignored.
 |  | ||||||
| 	//
 | 	//
 | ||||||
| 	// NOTE: this will set a .no-transitions CSS class and force 
 | 	// NOTE: this will set a .no-transitions CSS class and force 
 | ||||||
| 	// 		recalculation on the given element
 | 	// 		recalculation on the given element
 | ||||||
| 	// NOTE: for this to have effect proper CSS configuration is needed.
 | 	// NOTE: for this to have effect proper CSS configuration is needed.
 | ||||||
| 	preventTransitions: function(target, prevent_nested){ | 	preventTransitions: function(target){ | ||||||
| 		target = target || this.viewer | 		target = target || this.viewer | ||||||
| 		prevent_nested = prevent_nested || false | 		//prevent_nested = prevent_nested || false
 | ||||||
| 		if(target.length == 0){ | 		if(target.length == 0){ | ||||||
| 			return this | 			return this | ||||||
| 		} | 		} | ||||||
| 		var t = target[0] | 		var t = target[0] | ||||||
| 
 | 
 | ||||||
| 		// handle nesting...
 | 		// handle nesting...
 | ||||||
| 		if(prevent_nested){ |  | ||||||
| 		var l = t.getAttribute('__prevent_transitions') | 		var l = t.getAttribute('__prevent_transitions') | ||||||
| 		if(l != null){ | 		if(l != null){ | ||||||
| 			t.getAttribute('__prevent_transitions', l+1) | 			t.getAttribute('__prevent_transitions', l+1) | ||||||
| 			return this | 			return this | ||||||
| 		} | 		} | ||||||
| 		t.getAttribute('__prevent_transitions', 0) | 		t.getAttribute('__prevent_transitions', 0) | ||||||
| 		} |  | ||||||
| 
 | 
 | ||||||
| 		target.addClass('no-transitions') | 		target.addClass('no-transitions') | ||||||
| 		getComputedStyle(t).webkitTransition | 		getComputedStyle(t).webkitTransition | ||||||
| @ -209,6 +201,9 @@ var RibbonsPrototype = { | |||||||
| 	// levels.
 | 	// levels.
 | ||||||
| 	// This can be overridden via setting the force to true.
 | 	// This can be overridden via setting the force to true.
 | ||||||
| 	//
 | 	//
 | ||||||
|  | 	// NOTE: the implementation of this method might seem ugly, but the 
 | ||||||
|  | 	// 		code is speed-critical, thus we access the DOM directly and
 | ||||||
|  | 	// 		the two branches are unrolled...
 | ||||||
| 	restoreTransitions: function(target, now, force){ | 	restoreTransitions: function(target, now, force){ | ||||||
| 		if(target === true || target === false){ | 		if(target === true || target === false){ | ||||||
| 			now = target | 			now = target | ||||||
| @ -221,6 +216,8 @@ var RibbonsPrototype = { | |||||||
| 		} | 		} | ||||||
| 		var t = target[0] | 		var t = target[0] | ||||||
| 
 | 
 | ||||||
|  | 		// sync...
 | ||||||
|  | 		if(now){ | ||||||
| 			// handle nesting...
 | 			// handle nesting...
 | ||||||
| 			var l = t.getAttribute('__prevent_transitions') | 			var l = t.getAttribute('__prevent_transitions') | ||||||
| 			if(l != null && !force && l != '0'){ | 			if(l != null && !force && l != '0'){ | ||||||
| @ -229,8 +226,6 @@ var RibbonsPrototype = { | |||||||
| 			} | 			} | ||||||
| 			t.removeAttribute('__prevent_transitions') | 			t.removeAttribute('__prevent_transitions') | ||||||
| 
 | 
 | ||||||
| 		// sync...
 |  | ||||||
| 		if(now){ |  | ||||||
| 			target.removeClass('no-transitions') | 			target.removeClass('no-transitions') | ||||||
| 			var s = getComputedStyle(t) | 			var s = getComputedStyle(t) | ||||||
| 			s.webkitTransition | 			s.webkitTransition | ||||||
| @ -243,13 +238,22 @@ var RibbonsPrototype = { | |||||||
| 		} else { | 		} else { | ||||||
| 			var that = this | 			var that = this | ||||||
| 			setTimeout(function(){ | 			setTimeout(function(){ | ||||||
| 				target.removeClass('no-transitions')}, 0) | 				// handle nesting...
 | ||||||
|  | 				var l = t.getAttribute('__prevent_transitions') | ||||||
|  | 				if(l != null && !force && l != '0'){ | ||||||
|  | 					t.getAttribute('__prevent_transitions', l-1) | ||||||
|  | 					return this | ||||||
|  | 				} | ||||||
|  | 				t.removeAttribute('__prevent_transitions') | ||||||
|  | 
 | ||||||
|  | 				target.removeClass('no-transitions') | ||||||
| 				var s = getComputedStyle(t) | 				var s = getComputedStyle(t) | ||||||
| 				s.webkitTransition | 				s.webkitTransition | ||||||
| 				s.mozTransition | 				s.mozTransition | ||||||
| 				s.msTransition | 				s.msTransition | ||||||
| 				s.oTransition | 				s.oTransition | ||||||
| 				s.transition | 				s.transition | ||||||
|  | 			}, 0) | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
| 		return this | 		return this | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user