toolkit/javascript/d3/src/core/transition-attr.js
changeset 47 c0b4a8b5a012
equal deleted inserted replaced
46:efd9c589177a 47:c0b4a8b5a012
       
     1 d3_transitionPrototype.attr = function(name, value) {
       
     2   return this.attrTween(name, d3_transitionTween(name, value));
       
     3 };
       
     4 
       
     5 d3_transitionPrototype.attrTween = function(nameNS, tween) {
       
     6   var name = d3.ns.qualify(nameNS);
       
     7 
       
     8   function attrTween(d, i) {
       
     9     var f = tween.call(this, d, i, this.getAttribute(name));
       
    10     return f === d3_transitionRemove
       
    11         ? (this.removeAttribute(name), null)
       
    12         : f && function(t) { this.setAttribute(name, f(t)); };
       
    13   }
       
    14 
       
    15   function attrTweenNS(d, i) {
       
    16     var f = tween.call(this, d, i, this.getAttributeNS(name.space, name.local));
       
    17     return f === d3_transitionRemove
       
    18         ? (this.removeAttributeNS(name.space, name.local), null)
       
    19         : f && function(t) { this.setAttributeNS(name.space, name.local, f(t)); };
       
    20   }
       
    21 
       
    22   return this.tween("attr." + nameNS, name.local ? attrTweenNS : attrTween);
       
    23 };