How to use the d3-timer.now function in d3-timer

To help you get started, we’ve selected a few d3-timer examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github DefinitelyTyped / DefinitelyTyped / types / d3-timer / d3-timer-tests.ts View on Github external
/**
 * Typescript definition tests for d3/d3-timer module
 *
 * Note: These tests are intended to test the definitions only
 * in the sense of typing and call signature consistency. They
 * are not intended as functional tests.
 */

import * as d3Timer from 'd3-timer';

// Test now definition
const now: number = d3Timer.now();

// Test timer and timerFlush definitions ------------

let t0: d3Timer.Timer = d3Timer.timer((elapsed: number) => { console.log(elapsed); });
let t1: d3Timer.Timer = d3Timer.timer((elapsed: number) => { console.log(elapsed); }, 150);
let t2: d3Timer.Timer = d3Timer.timer((elapsed: number) => { console.log(elapsed); }, 150, performance.now() || Date.now());

t0.restart((elapsed: number) => { console.log(elapsed); });
t0.restart((elapsed: number) => { console.log(elapsed); }, 150);
t0.restart((elapsed: number) => { console.log(elapsed); }, 150, performance.now() || Date.now());
t0.stop();

d3Timer.timerFlush();

t1.stop(); t2.stop();
github DefinitelyTyped / DefinitelyTyped / d3-timer / d3-timer-tests.ts View on Github external
/**
 * Typescript definition tests for d3/d3-timer module
 *
 * Note: These tests are intended to test the definitions only
 * in the sense of typing and call signature consistency. They
 * are not intended as functional tests.
 */

import * as d3Timer from 'd3-timer';

// Test now definition
let now: number = d3Timer.now();

// Test timer and timerFlush definitions ------------

let t0: d3Timer.Timer = d3Timer.timer((elapsed: number) => { console.log(elapsed); });
let t1: d3Timer.Timer = d3Timer.timer((elapsed: number) => { console.log(elapsed); }, 150);
let t2: d3Timer.Timer = d3Timer.timer((elapsed: number) => { console.log(elapsed); }, 150, performance.now() || Date.now());

t0.restart((elapsed: number) => { console.log(elapsed); });
t0.restart((elapsed: number) => { console.log(elapsed); }, 150);
t0.restart((elapsed: number) => { console.log(elapsed); }, 150, performance.now() || Date.now());
t0.stop();

d3Timer.timerFlush();

t1.stop(); t2.stop();
github react-tools / react-move / src / core / transition / transition.js View on Github external
}

          return resonanceCustomTween
        }

        tweens.push(getResonanceCustomTween)
      } else {
        this.setState(() => {
          return { [stateKey]: val }
        })
        // This assures any existing transitions are stopped
        tweens.push(tween.call(this, null, stateKey, val))
      }
    }

    const timingConfig = { ...preset, ...timing, time: timeNow() }
    schedule(this, stateKey, newId(), timingConfig, tweens, events)
  })
}
github sghall / resonance / src / core / transition / transition.js View on Github external
};

          return resonanceCustomTween;
        };

        tweens.push(getResonanceCustomTween);
      } else {
        this.setState(() => {
          return { [stateKey]: val };
        });
        // This assures any existing transitions are stopped
        tweens.push(tween.call(this, null, stateKey, val));
      }
    }

    const timingConfig = { ...preset, ...timing, time: timeNow() };
    schedule(this, stateKey, newId(), timingConfig, tweens, events);
  });
}
github sghall / subunit / src / selection / transition.js View on Github external
function inherit(node, id) {
  var timing;

  while (!(timing = node.__transition) || !(timing = timing[id])) {
    if (!(node = node.parentNode)) {
      return defaultTiming.time = now(), defaultTiming;
    }
  }

  return timing;
}
github d3 / d3-transition / src / selection / transition.js View on Github external
function inherit(node, id) {
  var timing;
  while (!(timing = node.__transition) || !(timing = timing[id])) {
    if (!(node = node.parentNode)) {
      return defaultTiming.time = now(), defaultTiming;
    }
  }
  return timing;
}
github FormidableLabs / victory / packages / victory-core / src / victory-util / timer.js View on Github external
subscribe(callback, duration) {
    duration = this.shouldAnimate ? duration : 0;
    return this.subscribers.push({
      startTime: now(),
      callback,
      duration
    });
  }
github FormidableLabs / victory / packages / victory-core / src / victory-util / timer.js View on Github external
this.subscribers.forEach((s) => {
      s.callback(now() - s.startTime, s.duration);
    });
  }
github sghall / resonance / src / transition / transition.js View on Github external
Object.keys(transitions[ref]).forEach((attr) => {
      const value = transitions[ref][attr];

      if (Array.isArray(value)) {
        if (value.length === 1) {
          tweens.push(tween.call(this[ref], attr, value[0]));
        } else {
          this[ref].setAttribute(attr, value[0]);
          tweens.push(tween.call(this[ref], attr, value[1]));
        }
      } else {
        this[ref].setAttribute(attr, value);
      }
    });

    const timingConfig = { ...preset, ...timing, time: now() };
    schedule(this, ref, newId(), timingConfig, tweens, events);
  });
}

d3-timer

An efficient queue capable of managing thousands of concurrent animations.

ISC
Latest version published 3 years ago

Package Health Score

71 / 100
Full package analysis