Scroll smoothly to specific element on page

Super smoothly with requestAnimationFrame For smoothly rendered scrolling animation one could use window.requestAnimationFrame() which performs better with rendering than regular setTimeout() solutions. A basic example looks like this. Function step is called for browser’s every animation frame and allows for better time management of repaints, and thus increasing performance. function doScrolling(elementY, duration) { var startingY … Read more

CSS rotation cross browser with jquery.animate()

CSS-Transforms are not possible to animate with jQuery, yet. You can do something like this: function AnimateRotate(angle) { // caching the object for performance reasons var $elem = $(‘#MyDiv2’); // we use a pseudo object for the animation // (starts from `0` to `angle`), you can name it as you want $({deg: 0}).animate({deg: angle}, { … Read more

Animate element to auto height with jQuery

Save the current height: var curHeight = $(‘#first’).height(); Temporarily switch the height to auto: $(‘#first’).css(‘height’, ‘auto’); Get the auto height: var autoHeight = $(‘#first’).height(); Switch back to curHeight and animate to autoHeight: $(‘#first’).height(curHeight).animate({height: autoHeight}, 1000); And together: var el = $(‘#first’), curHeight = el.height(), autoHeight = el.css(‘height’, ‘auto’).height(); el.height(curHeight).animate({height: autoHeight}, 1000);

jQuery animate backgroundColor

I had the same problem and fixed it by including jQuery UI. Here is the complete script : <!– include Google’s AJAX API loader –> <script src=”http://www.google.com/jsapi”></script> <!– load JQuery and UI from Google (need to use UI to animate colors) –> <script type=”text/javascript”> google.load(“jqueryui”, “1.5.2”); </script> <script type=”text/javascript”> $(document).ready(function() { $(‘#menu ul li.item’).hover( function() … Read more

tech