• Stars
    star
    407
  • Rank 106,183 (Top 3 %)
  • Language
    JavaScript
  • Created about 15 years ago
  • Updated over 8 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Animatation for arcs and bezier curves with jQuery

jQuery.path

Provides animation along bezier and circular arcs.

The animation engine in jQuery is focussed on single dimensional animation - hence it's difficult to animate two variables along a path.

This simple plugin provides a method of multidimensional animation, and in particular provides a method for animating along bezier curves and arcs.

Bezier

Example: animate along a bezier path

var bezier_params = {
    start: { 
      x: 185, 
      y: 185, 
      angle: 10
    },	
    end: { 
      x:540,
      y:110, 
      angle: -10, 
      length: 0.25
    }
  }
  
$("my_elem").animate({path : new $.path.bezier(bezier_params)})

Bezier curves are made form a start point, an end point each with a control point

  • start is starting point
  • end is the final point
  • x,y indicate the coordinates at that point. Required
  • angle is the angle of the control point from the line joining the start and end. Optional, default is 0
  • length is the distance from the point to it's control point as a ratio of the distance from start to end. Optional, default is 1/3

Arc

Exampe: animate along an arc

  
var arc_params = {
    center: [285,185],	
		radius: 100,	
		start: 30,
		end: 200,
		dir: -1
  }
  
$("my_elem").animate({path : new $.path.arc(arc_params)})
  • center is the coords of the centre of an imaginary circle that contains the start and end point
  • radius is the radius of this circle
  • start is the angle of the start point. 0 is "North", measured clockwise
  • end is the angle of the start point. 0 is "North", measured clockwise
  • dir is the direction to move in. Only required if not obvious from start and end (e.g. if start is 100, end is 30, but you want to animate clockwise)

Other Paths

It is trivial to create other paths, or even animate other parameters. E.g:

var SineWave = function() {
  this.css = function(p) {
    var s = Math.sin(p*20)
    var x = 500 - p * 300 
    var y = s * 50 + 150
    var o = ((s+2)/4+0.1)
    return {top: y + "px", left: x + "px", opacity: o}
  } 
};
  
$("my_elem").animate({path : new SineWave})

Links

Compatibility

Tested in

  • Firefox 3.5
  • Safari 4
  • IE 6, 7, 8

More Repositories

1

kaffeine

Extended Javascript for Pros
JavaScript
180
star
2

o_O

Funnyface: HTML binding for teh lulz
JavaScript
149
star
3

brequire

Dropin require polyfill for the browser
JavaScript
103
star
4

attr

evented attribute component with automatic dependencies
JavaScript
52
star
5

saucy

Dynamic Text Rendering Plugin for Rails. Like sIFR but without the Hassle, Flash or even Javascript.
Ruby
43
star
6

sublive

Public Repo for Sublive for bug reports and feedback
37
star
7

jade-browser

compile jade for the browser
JavaScript
34
star
8

bounce

Node Reload
JavaScript
31
star
9

cornerz

Bullet Proof Corners plugin for jQuery using Canvas/VML
JavaScript
27
star
10

cssie

CSS in your face (only IE need to apply)
JavaScript
24
star
11

bean-server

Rubygems for Javascript
Ruby
17
star
12

node-jobs

simple job runner
JavaScript
12
star
13

test

test
10
star
14

ie-hover

Bringing :hover to IE Stylesheets with jQuery
JavaScript
10
star
15

snips

Super Simple CMS for Rails
Ruby
9
star
16

redisify

object orientated redis proxy
JavaScript
7
star
17

node_eval

Evaluate's javascript and returns a JSON object using Node
JavaScript
6
star
18

sprite-factory

sprites for jquery - with full PNG support
JavaScript
5
star
19

sam

simple asset manager
JavaScript
5
star
20

browser-require

`require` polyfill for the browser
JavaScript
5
star
21

jsvm_server

RPC Server and client for running multiple javascript environments in a separate process (Event Machine).
Ruby
4
star
22

pipe_utils

Utilities for use with the pipe operator in Kaffeine
JavaScript
4
star
23

mmmodel

Homer's favorite ORM
JavaScript
4
star
24

spiderz

Scarily easy spidering
Ruby
3
star
25

vanilla-notify

Vanilla growlesque notification for jQuery. Only 20 LOC
JavaScript
3
star
26

EML

EaselJS Markup Language
JavaScript
2
star
27

vanilla

Basic Rails App with all the starting points. jQuery, Restful Auth, ClearSS + lots of other bits n bobs
Ruby
2
star
28

StudioAmplify2.github.io

Documentation site for StudioAmplify
1
star
29

express

1
star
30

weepy2.github.io

1
star
31

weepy.github.com

project page
1
star
32

studioamplify.github.io

Documentation site for Studio Amplify
1
star
33

__edgy

1
star
34

GramrphoneDownloads

1
star
35

sprockets-server

simple sprockets server based on sinatra to afford modular TDD javascript
Ruby
1
star