Sha256: 78ddf0ba10ea711597ea86f4e10487c96874cd47b0c31976a694d819527691b5

Contents?: true

Size: 2 KB

Versions: 5

Compression:

Stored size: 2 KB

Contents

import "../core/ns";
import "../interpolate/interpolate";
import "../interpolate/transform";
import "transition";
import "tween";

d3_transitionPrototype.attr = function(nameNS, value) {
  if (arguments.length < 2) {

    // For attr(object), the object specifies the names and values of the
    // attributes to transition. The values may be functions that are
    // evaluated for each element.
    for (value in nameNS) this.attr(value, nameNS[value]);
    return this;
  }

  var interpolate = nameNS == "transform" ? d3_interpolateTransform : d3_interpolate,
      name = d3.ns.qualify(nameNS);

  // For attr(string, null), remove the attribute with the specified name.
  function attrNull() {
    this.removeAttribute(name);
  }
  function attrNullNS() {
    this.removeAttributeNS(name.space, name.local);
  }

  // For attr(string, string), set the attribute with the specified name.
  function attrTween(b) {
    return b == null ? attrNull : (b += "", function() {
      var a = this.getAttribute(name), i;
      return a !== b && (i = interpolate(a, b), function(t) { this.setAttribute(name, i(t)); });
    });
  }
  function attrTweenNS(b) {
    return b == null ? attrNullNS : (b += "", function() {
      var a = this.getAttributeNS(name.space, name.local), i;
      return a !== b && (i = interpolate(a, b), function(t) { this.setAttributeNS(name.space, name.local, i(t)); });
    });
  }

  return d3_transition_tween(this, "attr." + nameNS, value, name.local ? attrTweenNS : attrTween);
};

d3_transitionPrototype.attrTween = function(nameNS, tween) {
  var name = d3.ns.qualify(nameNS);

  function attrTween(d, i) {
    var f = tween.call(this, d, i, this.getAttribute(name));
    return f && function(t) { this.setAttribute(name, f(t)); };
  }
  function attrTweenNS(d, i) {
    var f = tween.call(this, d, i, this.getAttributeNS(name.space, name.local));
    return f && function(t) { this.setAttributeNS(name.space, name.local, f(t)); };
  }

  return this.tween("attr." + nameNS, name.local ? attrTweenNS : attrTween);
};

Version data entries

5 entries across 5 versions & 3 rubygems

Version Path
mdarray-sol-0.1.0-java node_modules/dc/node_modules/d3/src/transition/attr.js
stripchart-0.0.3 lib/stripchart/public/components/d3/src/transition/attr.js
stripmem-0.0.3 lib/stripmem/public/components/d3/src/transition/attr.js
stripmem-0.0.2 lib/stripmem/public/components/d3/src/transition/attr.js
stripmem-0.0.1 lib/stripmem/public/components/d3/src/transition/attr.js