mirror of
https://github.com/eliasstepanik/strudel-docker.git
synced 2026-01-11 13:48:34 +00:00
allow offsetting onFrame
This commit is contained in:
parent
d5ed065011
commit
75098adbdb
@ -64,7 +64,7 @@ Pattern.prototype.draw = function (callback, { from, to, onQuery } = {}) {
|
||||
|
||||
// this is a more generic helper to get a rendering callback for the currently active haps
|
||||
// TODO: this misses events that are prolonged with clip or duration (would need state)
|
||||
Pattern.prototype.onFrame = function (fn) {
|
||||
Pattern.prototype.onFrame = function (fn, offset = 0) {
|
||||
if (typeof window === 'undefined') {
|
||||
return this;
|
||||
}
|
||||
@ -72,7 +72,7 @@ Pattern.prototype.onFrame = function (fn) {
|
||||
cancelAnimationFrame(window.strudelAnimation);
|
||||
}
|
||||
const animate = () => {
|
||||
const t = getTime();
|
||||
const t = getTime() + offset;
|
||||
const haps = this.queryArc(t, t);
|
||||
fn(haps, t, this);
|
||||
window.strudelAnimation = requestAnimationFrame(animate);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user