Pauses and resumes animation executed by the jQuery animate() method.
#jquery-plugin #animation
IE 10+, latest of Chrome/FF/Safari, iOS 7+ and Android 2.3+ (except 3.x)
<!-- 1) Load jQuery -->
<script src="https://code.jquery.com/jquery-1.11.3.min.js"></script>
<!-- 2) Load egjs packaged file -->
<script src="//naver.github.io/egjs-jquery-pauseresume/release/latest/dist/pauseresume.js"></script>
var $el = $("#anim");
$el.animate({"left": "300px"});
$el.pause(); //pause animation
$el.resume(); // resume animation
//pause / resume by mouse over/out events.
$("#rectBox").hover(function() {
$(this).pause();
}, function() {
$(this).resume();
});
// Animate element infinitely
var $rectBox = $("#rectBox");
var easing = "linear";
function drawRectangle() {
$rectBox
.animate({"opacity": 0.5}, 1000)
.animate({"left": "+=200px"}, 1000, easing) // relative value
.animate({"top": "200px"}, 1000, easing) // absolute value
.animate({"left": "0px"}, 1000, easing)
.animate({"top": "-=200px"}, 1000, easing)
.animate({"opacity": "+=0.5"}, 1000, drawRectangle)
}
drawRectangle();