here is small code
<div id="clickme">
Click here
</div>
<img id="book" src="book.png" alt="" width="100" height="123"
style="position: relative; left: 10px;" />
$('#clickme').click(function() {
$('#book').animate({
opacity: 0.25,
left: '+=50',
height: 'toggle'
}, 5000, function() {
// Animation complete.
});
});
it is clear from the code left is increasing and opacity will be .25. how jquery manage to do so...does jquery internally execute a loop to increase the left and change the opacity until it becomes .25. need guidance. thanks
The animate() method performs a custom animation of a set of CSS properties. This method changes an element from one state to another with CSS styles. The CSS property value is changed gradually, to create an animated effect. Only numeric values can be animated (like "margin:30px").
The . animate() method allows us to create animation effects on any numeric CSS property. The only required parameter is a plain object of CSS properties.
The solution to Jquery To Animate A Flash To The Button Selected will be demonstrated using examples in this article. $("#someElement"). fadeOut(100). fadeIn(100).
It's gradually increases (or decreases) values at set periods using timer. It can't use a loop because if that was the case it would block/freeze the main js thread while doing that and you wouldn't see the animation. Everything in js is (or should be) asynchronous, via events.
To know how the animate code looks and works have a look at the source:
https://github.com/jquery/jquery/blob/master/src/effects.js
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With