Remove highlights when code stops
This commit is contained in:
parent
aded178ab7
commit
ba9562f000
1 changed files with 3 additions and 5 deletions
|
|
@ -20,10 +20,9 @@ function useHighlighting({ view, pattern, active, getTime }) {
|
||||||
highlights.current = highlights.current.filter((hap) => hap.endClipped > audioTime); // keep only highlights that are still active
|
highlights.current = highlights.current.filter((hap) => hap.endClipped > audioTime); // keep only highlights that are still active
|
||||||
const haps = pattern.queryArc(...span).filter((hap) => hap.hasOnset());
|
const haps = pattern.queryArc(...span).filter((hap) => hap.hasOnset());
|
||||||
highlights.current = highlights.current.concat(haps); // add potential new onsets
|
highlights.current = highlights.current.concat(haps); // add potential new onsets
|
||||||
// view.dispatch({ effects: setHighlights.of({ haps: highlights.current }) }); // highlight all still active + new active haps
|
highlightMiniLocations(view, highlights.current);
|
||||||
highlightMiniLocations(view, highlights.current); // <- new method, replaces above line when done
|
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
view.dispatch({ effects: setHighlights.of({ haps: [] }) });
|
highlightMiniLocations(view, [])
|
||||||
}
|
}
|
||||||
frame = requestAnimationFrame(updateHighlights);
|
frame = requestAnimationFrame(updateHighlights);
|
||||||
});
|
});
|
||||||
|
|
@ -31,8 +30,7 @@ function useHighlighting({ view, pattern, active, getTime }) {
|
||||||
cancelAnimationFrame(frame);
|
cancelAnimationFrame(frame);
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
highlights.current = [];
|
highlightMiniLocations(view, []);
|
||||||
view.dispatch({ effects: setHighlights.of({ haps: [] }) });
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, [pattern, active, view]);
|
}, [pattern, active, view]);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue