You can not select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
					37 lines
				
				644 B
			
		
		
			
		
	
	
					37 lines
				
				644 B
			| 
								 
											3 years ago
										 
									 | 
							
								'use strict';
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								var rafSchd = function rafSchd(fn) {
							 | 
						||
| 
								 | 
							
								  var lastArgs = [];
							 | 
						||
| 
								 | 
							
								  var frameId = null;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								  var wrapperFn = function wrapperFn() {
							 | 
						||
| 
								 | 
							
								    for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
							 | 
						||
| 
								 | 
							
								      args[_key] = arguments[_key];
							 | 
						||
| 
								 | 
							
								    }
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								    lastArgs = args;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								    if (frameId) {
							 | 
						||
| 
								 | 
							
								      return;
							 | 
						||
| 
								 | 
							
								    }
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								    frameId = requestAnimationFrame(function () {
							 | 
						||
| 
								 | 
							
								      frameId = null;
							 | 
						||
| 
								 | 
							
								      fn.apply(void 0, lastArgs);
							 | 
						||
| 
								 | 
							
								    });
							 | 
						||
| 
								 | 
							
								  };
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								  wrapperFn.cancel = function () {
							 | 
						||
| 
								 | 
							
								    if (!frameId) {
							 | 
						||
| 
								 | 
							
								      return;
							 | 
						||
| 
								 | 
							
								    }
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								    cancelAnimationFrame(frameId);
							 | 
						||
| 
								 | 
							
								    frameId = null;
							 | 
						||
| 
								 | 
							
								  };
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								  return wrapperFn;
							 | 
						||
| 
								 | 
							
								};
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								module.exports = rafSchd;
							 |