Table of contents

M4Q Animation

Use m4q animation to animate HTMLElements.

About

The m4q contains functions for animate HTML elements. Animate function used requestAnimationFrame method to executing animation rules.

Animation

To animate element properties, you can use $.animate function. Global function receive next arguments:


                    $.animate(element, draw, duration, timing, callback);
                
  • element - HTMLElement
  • draw - function or object of properties to animate
  • duration - animation duration
  • timing - easing function name to calculate timing
  • callback - callback function for executing after animation is done
Draw function

                    var el = $("#demo-cube-1");
                    var maxLeft = el.parent().width() - 132;
                    $.animate(el[0], function(t, p){
                        this.style.left = maxLeft * p + "px"
                    }, 3000);
                
Draw object

                    var el = $("#demo-cube-2");
                    var maxLeft = el.parent().width() - 132;
                    $.animate(el[0], {
                        left: maxLeft
                    }, 3000);
                

Animate elements set

To animate elements set, you must:

  1. Select elements to m4q set with m4q constructor - $(...)
  2. Use set animate function to animate elements set

                    var el = $(".c1, .c2, .c3");
                    var maxLeft = el.parent().width() - 62;

                    el.stop().css("left", 0).animate({
                        left: maxLeft
                    }, 3000);
                

Easing function for timing