christinecha / choreographer-js Goto Github PK
View Code? Open in Web Editor NEWA simple library to take care of complicated animations.
Home Page: https://christinecha.github.io/choreographer-js/
A simple library to take care of complicated animations.
Home Page: https://christinecha.github.io/choreographer-js/
Apologies if this is clear from the js itself.
Is it possible to scale the alpha value in an rgba color, for example:
{
range: [-1, 600],
selector: '#fixy',
type: 'scale',
style: 'background-color',
from: "rgba(255,0,0,0)",
to: "rgba(255,0,0,1)"
}
Obviously you can't scale a value like that but it should explain what I'm struggling to accomplish.
Thanks!
Thanks for this script.
Just tested it quickly and found out an issue.
If the script src tag to import the library is placed before the body
tag (for instance, the head
tag) an undefined function error will be thrown at this line:
https://github.com/christinecha/choreographer-js/blob/master/src/getInjectedTransformString.js#L26
Best
First-off, brilliant work on this library. I like the API!
I've tested the demo page and it doesn't work in IE 10/11.
Any future plans on making this cross-browser compliant?
I'm doing the following to handle updating animations on window resize:
var Choreographer = require('choreographer-js');
var obj_anim = [
{
range: [-1, 500],
selector: '.object',
type: 'scale',
style: 'transform:translateY',
from: 100,
to: 0,
unit: '%'
},
{
range: [document.getElementById('trigger').getBoundingClientRect().top + window.scrollY, document.getElementById('trigger').getBoundingClientRect().top + window.scrollY + 300],
selector: '.object',
type: 'scale',
style: 'left',
from: 50,
to: -50,
unit: '%'
}
];
var choreographer = new Choreographer({
animations: obj_anim
});
window.addEventListener('scroll', function() {
choreographer.runAnimationsAt(window.pageYOffset);
});
window.addEventListener('resize', function() {
choreographer.updateAnimations(obj_anim);
});
However the animation doesn't begin when the trigger element hits the top of the page as expected unless I hard refresh. It doesn't seem to be respecting the range I've set.
I can confirm that the distance from the top of the document to the top of the trigger element is accurate on resize, so what am I missing here?
Thanks!
It would be great on page scroll if the animations leveraged linear interpolation so they don't appear so choppy/abrupt.
Here's an excerpt from Rachel Smith's codepen article about moving objects on scroll that outlines this more clearly:
Personally, I’m not really in to the ‘moving things at a linear rate as the page scrolls down’ look. For one, linear movement makes me sad. It also looks kind of choppy if you’re scrolling at random speeds. So instead I like to use linear interpolation to move elements to their target. I think this is one of those effects that are down to personal preference, but I definitely think it makes things look a lot smoother and better.
You can check out an example of how this feels here.
Whatcha think?
I have an animation that gets set up when my component mounts. I need to update the from
value for the animation after a resize event. This is my initial config:
choreographer = new Choreographer({
animations: [
{
range: [-1, 150],
selector: '#licenseBar',
type: 'scale',
style: 'height',
from: licenseBarExpandedHeight,
to: licenseBarCollapsedHeight,
unit: 'px'
}
]
});
What’s the cleanest way to update the from
value after the animation has already been set up?
First of all, i love your library. It helps me a lot with scroll-based animation choreographys.
I tried to use it also to change a class, according to your docs… But it do not add the class to my object.
Here's the code i used:
{ range: [first.end, second.end], selector: '#start .second-scene--video', type: 'class', style: 'class', to: 'play' }
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.