kenburns-dom standalone usage
Closed this issue · 3 comments
When using kenburns-dom standalone, the start method
deviates from the kenburns module (runStart and run).
Also, runStart of kenburns-dom apparently also doesn't
return a promise or callback for the finish of the animation.
things are a bit weird coupled I admit. Maybe all of these should just be one package because it's a bit confusing.
But basically, kenburns-dom / kenburns-core is not meant to be used directly. It's an hidden dep. only kenburns
should be depend on.
kenburns expose DOM
which is the dom implementation.
If I have time, I should try to regroup things in one directory. I also imagine we could require("kenburns/dom")
later so only the dom impl get actively imported so it reduces bundle size. but it's an optim...
I've released a major version of the library (2.0.0) that have a new documentation. https://github.com/gre/kenburns/blob/master/API.md
checkout also the example: https://github.com/gre/kenburns/blob/master/example/index.js
You now only need to use the library kenburns
and no more kenburns-dom
.
To use the dom implementation:
import KenBurnsDOM from "kenburns/lib/DOM";
var div = document.createElement("div");
div.style.width = "400px";
div.style.height = "400px";
const kenBurnsDOM = new KenBurnsDOM(div);
// kenBurnsDOM.animate(...).then(...);
// kenBurnsDOM.animateStep(...);
animate(image, fromCrop, toCrop, duration/*, easing*/)
runs the animation and returns a Promise.
if you want finer control, animateStep(image, fromCrop, toCrop, progress)
allows to render one frame of the animation. It's lower level but you can do whatever speed / easing / interruption / ...