Skip to content

Commit

Permalink
move clock signals to toplevelsignals
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathanzong committed Sep 25, 2023
1 parent 850156c commit aecefa5
Showing 1 changed file with 24 additions and 15 deletions.
39 changes: 24 additions & 15 deletions src/compile/selection/point.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,6 @@ export const THROTTLE = (1 / 60) * 1000; // 60 FPS
const animationSignals = (selectionName: string, scaleName: string): Signal[] => {
return [
// timer signals
{
name: ANIM_CLOCK,
init: '0',
on: [
{
events: {type: 'timer', throttle: THROTTLE},
update: `true ? (${ANIM_CLOCK} + (now() - ${LAST_TICK}) > ${MAX_RANGE_EXTENT} ? 0 : ${ANIM_CLOCK} + (now() - ${LAST_TICK})) : ${ANIM_CLOCK}`
}
]
},
{
name: LAST_TICK,
init: 'now()',
on: [{events: [{signal: ANIM_CLOCK}], update: 'now()'}]
},
{
name: EASED_ANIM_CLOCK,
// update: 'easeLinear(anim_clock / max_range_extent) * max_range_extent'
Expand All @@ -54,6 +39,30 @@ const animationSignals = (selectionName: string, scaleName: string): Signal[] =>
const point: SelectionCompiler<'point'> = {
defined: selCmpt => selCmpt.type === 'point',

topLevelSignals: (model, selCmpt, signals) => {
if (isTimerSelection(selCmpt)) {
signals = signals.concat([
{
name: ANIM_CLOCK,
init: '0',
on: [
{
events: {type: 'timer', throttle: THROTTLE},
update: `true ? (${ANIM_CLOCK} + (now() - ${LAST_TICK}) > ${MAX_RANGE_EXTENT} ? 0 : ${ANIM_CLOCK} + (now() - ${LAST_TICK})) : ${ANIM_CLOCK}`
}
]
},
{
name: LAST_TICK,
init: 'now()',
on: [{events: [{signal: ANIM_CLOCK}], update: 'now()'}]
}
]);
}

return signals;
},

signals: (model, selCmpt, signals) => {
const name = selCmpt.name;
const fieldsSg = name + TUPLE_FIELDS;
Expand Down

0 comments on commit aecefa5

Please sign in to comment.