jquery-animate-promise

jquery-animate-promise

by Haytham Douaihy

HTML

<a href="#" id="link">Link</a>
<span>Moving</span>

JavaScript

$('#link').click(function () {
    console.log("Enter");
    var asyncFunct = new Promise(function(resolve, reject) {
			$('#link').animate({ width: 200 }, 2000, function() {
         console.log("finished");            	
				 resolve();
			}); 			
		});
    asyncFunct.then((result) => {
			console.log("Exit");    
		});
});

function asyncFunct() {
	$('#link').animate({ width: 200 }, 2000, function() {
         console.log("finished");            	
	});   
}