source: node_modules/d3-transition/src/selection/transition.js

Last change on this file was e4c61dd, checked in by istevanoska <ilinastevanoska@…>, 6 months ago

Prototype 1.1

  • Property mode set to 100644
File size: 1.1 KB
RevLine 
[e4c61dd]1import {Transition, newId} from "../transition/index.js";
2import schedule from "../transition/schedule.js";
3import {easeCubicInOut} from "d3-ease";
4import {now} from "d3-timer";
5
6var defaultTiming = {
7 time: null, // Set on use.
8 delay: 0,
9 duration: 250,
10 ease: easeCubicInOut
11};
12
13function inherit(node, id) {
14 var timing;
15 while (!(timing = node.__transition) || !(timing = timing[id])) {
16 if (!(node = node.parentNode)) {
17 throw new Error(`transition ${id} not found`);
18 }
19 }
20 return timing;
21}
22
23export default function(name) {
24 var id,
25 timing;
26
27 if (name instanceof Transition) {
28 id = name._id, name = name._name;
29 } else {
30 id = newId(), (timing = defaultTiming).time = now(), name = name == null ? null : name + "";
31 }
32
33 for (var groups = this._groups, m = groups.length, j = 0; j < m; ++j) {
34 for (var group = groups[j], n = group.length, node, i = 0; i < n; ++i) {
35 if (node = group[i]) {
36 schedule(node, name, id, i, group, timing || inherit(node, id));
37 }
38 }
39 }
40
41 return new Transition(groups, this._parents, name, id);
42}
Note: See TracBrowser for help on using the repository browser.