import { Transition } from '../core/Transition';
import { Selection } from '../core/Selection';
import { transitionInheritId } from '../selection/transition';

export function transition(groups, ns, id) {
  groups.namespace = ns;
  groups.id = id;

  return Transition.from(groups);
}

export function transitionSelection(selection, name) {
  if (selection && selection.transition) {
    return transitionInheritId ? selection.transition(name) : selection;
  } else {
    return Selection.from([]).transition(selection);
  }
}

@@ -156,96 +156,636 @@
 n';%0A
-%0Aexport function transition(groups, ns, id
+import %7B transitionNode %7D from '../transition/transitionNode';%0A%0Aexport function transition() %7B%0A  var id0 = this.id;%0A  var id1 = transitionInheritId;%0A  var ns = this.namespace;%0A  var subgroups = %5B%5D, subgroup, node;%0A  var trans;%0A%0A  for (var j = 0, m = this.length; j %3C m; j++
 ) %7B%0A  
+  sub
 groups.
-namespace = ns;%0A  groups.id = id;
+push(subgroup = %5B%5D);%0A    for (var group = this%5Bj%5D, i = 0, n = group.length; i %3C n; i++) %7B%0A      if (node = group%5Bi%5D) %7B%0A        trans = node%5Bns%5D%5Bid0%5D;%0A        transitionNode(node, i, ns, id1, %7Btime: trans.time, ease: trans.ease, delay: trans.delay + trans.duration, duration: trans.duration%7D);%0A      %7D%0A      subgroup.push(node);%0A    %7D%0A  %7D
 %0A%0A  
@@ -791,17 +791,17 @@
  return 
-T
+t
 ransitio
@@ -805,20 +805,34 @@
 tion
-.from(groups
+Factory(subgroups, ns, id1
 );%0A%7D
@@ -1074,8 +1074,153 @@
 ;%0A  %7D%0A%7D%0A
+%0Afunction transitionFactory(groups, ns, id) %7B%0A  var trans = Transition.from(groups);%0A  trans.namespace = ns;%0A  trans.id = id;%0A%0A  return trans;%0A%7D%0A

support sub transitions