xAnimation.line Demo

Animate an element's position over a line segment. This is an xAnimation method.

For more demos see the animation index page.

Demo Controls

Click a button to cause the corresponding method to be called for each xAnimation object.

pauseresume

No Acceleration

This code starts the animations in this DIV, and updates them on window resize.

XA[0].line('de0', x + cw, y + ch, tt, 0, 0, 'true');
XA[1].line('de1', x + cw, y, tt, 0, 0, 'true');
travelBorder(XA[2]);

Sine Acceleration

This code starts the animations in this DIV, and updates them on window resize.

XA[3].line('de3', x + cw, y + ch, tt, 1, 1, 'true');
XA[4].line('de4', x + cw, y, tt, 1, 1, 'true');
travelBorder(XA[5]);

Cosine Acceleration

This code starts the animations in this DIV, and updates them on window resize.

XA[6].line('de6', x + cw, y + ch, tt, 2, 1, 'true');
XA[7].line('de7', x + cw, y, tt, 2, 1, 'true');
travelBorder(XA[8]);

travelBorder

Each of the above demos call travelBorder which causes an element to travel around the border of the DIV.

function travelBorder(xa)
{
  xa.line(xa.o.e, xa.o.x + xa.o.cw, xa.o.y + xa.o.ch, xa.o.t, xa.o.a, xa.o.b, function(a) {// sw to se
    xa.line(a.o.e, a.o.x + a.o.cw, a.o.y, a.o.t/2, a.o.a, a.o.b, function(a) {             // se to ne
      xa.line(a.o.e, a.o.x, a.o.y, a.o.t, a.o.a, a.o.b, function(a) {                      // ne to nw
        xa.line(a.o.e, a.o.x, a.o.y + a.o.ch, a.o.t/2, a.o.a, a.o.b, function(a) {         // nw to sw
          travelBorder(a);                                                                 // repeat  
        });
      });
    });
  });
}