I wrote a Javascript bezier curve animation library. I can’t seem to find any javascript bezier animation library that can handle multiple degree, so I made one myself. You can download it from the github here: https://github.com/tealtadpole/tt-javascript-bezier-animation
Live example
You can see the live example here: https://web.tealtadpole.me/tt-javascript-bezier-animation/
You can download the live example html file (or clone it from the github repository), then dissect the content inside. The usage is pretty simple, and I think it should cover most custom animation cases. I use requestAnimationFrame( ) method for a better performance (it will be paused when the tab is inactive (in the background). Beware that you might have your own animation function for your requestAnimationFrame method, if this is the case, you might have to manually modify your animation function.
Usage
- Import the javascript library
- Prepare the container tag and the child tag. (Container is where the animated DOM id located, it must have at least positioning relative/absolute, normally it should have a width and height. Child tag is the DOM id that will be animated)
- call ttBezier.add( options ) to ‘setup’ the bezier
- call ttBezier.start( name ) to start the animation with the given name
- call ttBezier.stop( name ) to stop the animation with the given name
That’s it, super easy. But please note that you need to provide ‘normalized’ control points. The number of points must be at least equal to degree + 1 (for example: bezier degree 3 will need 4 control points, while bezier degree 2 will need 3 control points). The 0,0 origin are the bottom left corner. While 1,1 is the top right corner. You can specify a number less than 0 and 1,meaning your animation might be outside the container box. If you’re not sure about where to put the points, you can use any online bezier drawing tool. Such as this one from desmos.com.
The following options are possible:
option | type | description |
---|---|---|
name | string | Animation name |
containerId | string | Animation container DOM id |
childId | string | Animated element DOM id |
childOrigin | string (optional, default ‘top-left’) | Center animated element origin |
degree | number (optional, default 3) | Bezier degree, starting from 1 (linear line) |
points | Array [{x: __ , y: __ }] | Array of points |
duration | number (int milliseconds) (optional, default 500) | Animation duration |
easing | string (optional) | Easing type |
loop | boolean (optional, default true) | Looped animation |
hideOnAnimationEnd | boolean (optional, default false) | Hide the child when the animation ends (with display=none) |
run | boolean (optional, default false) | Run the animation immediately |
Easings
I copy-pasted some easing functions from easings.net. It’s pretty straight forward, where the t is the normalized timestamp from 0 to 1. You can use it by adding an easing param. There are many easing options available, you should check it.
childOrigin
Child origin is when to align your animated DOM id, it has 9 possible values. The default is top-left.
- top-left
- top
- top-right
- left
- center
- right
- bottom-left
- bottom
- bottom-right
-tt-
%%
Here is my webpage Seo Services In London; 52.64.190.64,
%%
Here is my web site; promocode uk
%%
Also visit my webpage – misted double glazing bromley (jcec.Co.Kr)
%%
my blog :: bio ethanol outdoor fireplace uk (Shawn)
%%
My web-site – Mesothelioma Case In Oneonta
%%
Check out my homepage :: truck accident Attorney Clearwater
I’ve been exploring for a bit for any high-quality articles or blog posts mesothelioma case in richland center this sort of house .
Exploring in Yahoo I eventually stumbled upon this site.
Studying this information So i’m satisfied to express that I have a very just right uncanny feeling I discovered
exactly what I needed. I so much indisputably will make certain to don?t forget this website and provides it a look on a constant basis.
%%
My blog post … become A representative for makeup
%%
my webpage; Glass Bubbler Pipe
%%
My web blog … Corner bioethanol fireplace
%%
Feel free to visit my website :: mesothelioma
%%
Feel free to surf to my website – poker online (Josette)
%%
Also visit my homepage :: windows
%%
Feel free to visit my web-site – window installations near me
%%
Look at my blog post: northampton Adhd assessment
%%
Stop by my web site … mesothelioma Lawsuit in dickson
%%
Also visit my site mesothelioma lawyer bisbee
%%
Stop by my web page … d8 Near Me
%%
Also visit my homepage … Voucher 2023 (Daoom.Co.kr)
%%
Feel free to surf to my blog … 18 wheeler Litigation –
pandora.pe.kr,
%%
My blog post :: san Francisco mesothelioma lawyer
%%
Stop by my site 18 wheeler settlement
%%
Also visit my site :: Loomis mesothelioma settlement
%%
Also visit my blog post; become a Representative
%%
Feel free to visit my blog: Poker online
%%
Feel free to visit my site :: Mesothelioma compensation (http://t.Groupon.Fr/r?tsToken=FR_AFF_0_206343_260380_0&url=http%3A%2F%2Fvimeo.com%2F779958653&Wid=http://www.space-blogs.com)
%%
Here is my webpage – pragmatic play (https://beritapialadunia.online)
%%
Also visit my webpage lawyers
%%
Feel free to visit my page – mesothelioma Lawsuit
%%
My blog post cbd gummies Rhode Island (evernft.space)
%%
my website – weldon spring mesothelioma compensation
%%
Visit my webpage: motor vehicle Legal
%%
Stop by my web blog; lottery Singapore
%%
Feel free to visit my web blog mesothelioma Lawsuit elwood
%%
Here is my homepage – avon join
%%
Also visit my web site – Poker Online
%%
My blog: asbestos Lawsuit
%%
Here is my website promotional code Uk
Unquestionably believe that which you stated. Your favorite
justification appeared to be on the internet the easiest thing to be aware of.
I say to you, I definitely get irked while people think about worries that they just do not know about.
You managed to hit the nail upon the top and also defined
out the whole thing without having side-effects , people could take a signal.
Will probably be back to get more. Thanks
My blog post; delta 8 Gummies Wisconsin
%%
Stop by my website – 10.5 tog super king duvets (Teena)
%%
Look into my homepage: sportsbook
%%
my web page motor Vehicle attorney
%%
My blog … mesothelioma lawyer coeur dalene
Wow! Finally I got a website from where I be capable of truly
obtain useful data concerning my study and knowledge.
My web site … truck accident lawyers; http://retoolkorea.Com/,
%%
Also visit my blog post; Veterans disability lawyer (slimup2.homefree.kr)
%%
Review my site Mesothelioma attorney melrose park