Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

d3-transition

Package Overview
Dependencies
Maintainers
1
Versions
48
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

d3-transition - npm Package Compare versions

Comparing version 0.2.1 to 0.2.2

2

build/bundle.js

@@ -1,1 +0,1 @@

var version = "0.2.1"; export * from "../index"; export {version};
var version = "0.2.2"; export * from "../index"; export {version};

@@ -7,114 +7,4 @@ (function (global, factory) {

// TODO Assumes either ALL selected nodes are SVG, or none are.
function attrInterpolate(node, name) {
return name === "transform" && node.namespaceURI === d3Selection.namespaces.svg
? d3Interpolate.interpolateTransform
: d3Interpolate.interpolate;
}
function attrRemove(name) {
return function() {
this.removeAttribute(name);
};
}
function attrRemoveNS(fullname) {
return function() {
this.removeAttributeNS(fullname.space, fullname.local);
};
}
function attrConstant(name, value1) {
var value00,
interpolate0;
return value1 += "", function() {
var value0 = this.getAttribute(name);
return value0 === value1 ? null
: value0 === value00 ? interpolate0
: interpolate0 = attrInterpolate(this, name)(value00 = value0, value1);
};
}
function attrConstantNS(fullname, value1) {
var value00,
interpolate0;
return value1 += "", function() {
var value0 = this.getAttributeNS(fullname.space, fullname.local);
return value0 === value1 ? null
: value0 === value00 ? interpolate0
: interpolate0 = d3Interpolate.interpolate(value00 = value0, value1);
};
}
function attrFunction(name, value) {
var value00,
value10,
interpolate0;
return function() {
var value0,
value1 = value.apply(this, arguments);
if (value1 == null) return void this.removeAttribute(name);
value0 = this.getAttribute(name), value1 += "";
return value0 === value1 ? null
: value0 === value00 && value1 === value10 ? interpolate0
: interpolate0 = attrInterpolate(this, name)(value00 = value0, value10 = value1);
};
}
function attrFunctionNS(fullname, value) {
var value00,
value10,
interpolate0;
return function() {
var value0, value1 = value.apply(this, arguments);
if (value1 == null) return void this.removeAttributeNS(fullname.space, fullname.local);
value0 = this.getAttributeNS(fullname.space, fullname.local), value1 += "";
return value0 === value1 ? null
: value0 === value00 && value1 === value10 ? interpolate0
: interpolate0 = d3Interpolate.interpolate(value00 = value0, value10 = value1);
};
}
function transition_attr(name, value) {
var fullname = d3Selection.namespace(name);
return this.attrTween(name, (value == null
? (fullname.local ? attrRemoveNS : attrRemove) : (typeof value === "function"
? (fullname.local ? attrFunctionNS : attrFunction)
: (fullname.local ? attrConstantNS : attrConstant)))(fullname, value));
}
function attrTweenNS(fullname, value) {
function tween() {
var node = this, i = value.apply(node, arguments);
return i && function(t) {
node.setAttributeNS(fullname.space, fullname.local, i(t));
};
}
tween._value = value;
return tween;
}
function attrTween(name, value) {
function tween() {
var node = this, i = value.apply(node, arguments);
return i && function(t) {
node.setAttribute(name, i(t));
};
}
tween._value = value;
return tween;
}
function transition_attrTween(name, value) {
var key = "attr." + name;
if (arguments.length < 2) return (key = this.tween(key)) && key._value;
if (typeof value !== "function") throw new Error;
var fullname = d3Selection.namespace(name);
return this.tween(key, (fullname.local
? attrTweenNS
: attrTween)(fullname, value));
}
var emptyOn = d3Dispatch.dispatch("start", "end", "interrupt");
var emptyTweens = [];
var emptyTween = [];

@@ -133,3 +23,3 @@ var CREATED = 0;

on: emptyOn,
tweens: emptyTweens,
tween: emptyTween,
time: timing.time,

@@ -173,3 +63,3 @@ delay: timing.delay,

var schedules = node[key],
tweens;
tween;

@@ -226,14 +116,14 @@ // Initialize the self timer when the transition is created.

// Dispatch the start event.
// Note this must be done before the tweens are initialized.
// Note this must be done before the tween are initialized.
self.on.call("start", node, node.__data__, self.index, self.group);
self.state = STARTED;
// Initialize the tweens, deleting null tweens.
tweens = new Array(n = self.tweens.length);
// Initialize the tween, deleting null tween.
tween = new Array(n = self.tween.length);
for (i = 0, j = -1; i < n; ++i) {
if (o = self.tweens[i].value.call(node, node.__data__, self.index, self.group)) {
tweens[++j] = o;
if (o = self.tween[i].value.call(node, node.__data__, self.index, self.group)) {
tween[++j] = o;
}
}
tweens.length = j + 1;
tween.length = j + 1;
}

@@ -246,4 +136,4 @@

for (i = 0, n = tweens.length; i < n; ++i) {
tweens[i].call(null, e);
for (i = 0, n = tween.length; i < n; ++i) {
tween[i].call(null, e);
}

@@ -261,2 +151,169 @@

function tweenFunction(key, id, name, value) {
var tween0, tween1;
return function() {
var schedule = set(this, key, id),
tween = schedule.tween;
// If this node shared tween with the previous node,
// just assign the updated shared tween and we’re done!
// Otherwise, copy-on-write.
if (tween !== tween0) {
tween1 = (tween0 = tween).slice();
for (var t = {name: name, value: value}, i = 0, n = tween1.length; i < n; ++i) {
if (tween1[i].name === name) {
tween1[i] = t;
break;
}
}
if (i === n) tween1.push(t);
}
schedule.tween = tween1;
};
}
function transition_tween(name, value) {
var key = this._key,
id = this._id;
name += "";
if (arguments.length < 2) {
var tween = get(this.node(), key, id).tween;
for (var i = 0, n = tween.length, t; i < n; ++i) {
if ((t = tween[i]).name === name) {
return t.value;
}
}
return null;
}
if (typeof value !== "function") throw new Error;
return this.each(tweenFunction(key, id, name, value));
}
function tweenValue(transition, name, value) {
var key = transition._key,
id = transition._id;
transition.each(function() {
var schedule = set(this, key, id), v = value.apply(this, arguments);
(schedule.value || (schedule.value = {}))[name] = v == null ? null : v + "";
});
return function(node) {
return get(node, key, id).value[name];
};
}
// TODO Assumes either ALL selected nodes are SVG, or none are.
function attrInterpolate(node, name) {
return name === "transform" && node.namespaceURI === d3Selection.namespaces.svg
? d3Interpolate.interpolateTransform
: d3Interpolate.interpolate;
}
function attrRemove(name) {
return function() {
this.removeAttribute(name);
};
}
function attrRemoveNS(fullname) {
return function() {
this.removeAttributeNS(fullname.space, fullname.local);
};
}
function attrConstant(name, value1) {
var value00,
interpolate0;
return function() {
var value0 = this.getAttribute(name);
return value0 === value1 ? null
: value0 === value00 ? interpolate0
: interpolate0 = attrInterpolate(this, name)(value00 = value0, value1);
};
}
function attrConstantNS(fullname, value1) {
var value00,
interpolate0;
return function() {
var value0 = this.getAttributeNS(fullname.space, fullname.local);
return value0 === value1 ? null
: value0 === value00 ? interpolate0
: interpolate0 = d3Interpolate.interpolate(value00 = value0, value1);
};
}
function attrFunction(name, value) {
var value00,
value10,
interpolate0;
return function() {
var value0, value1 = value(this);
if (value1 == null) return void this.removeAttribute(name);
value0 = this.getAttribute(name);
return value0 === value1 ? null
: value0 === value00 && value1 === value10 ? interpolate0
: interpolate0 = attrInterpolate(this, name)(value00 = value0, value10 = value1);
};
}
function attrFunctionNS(fullname, value) {
var value00,
value10,
interpolate0;
return function() {
var value0, value1 = value(this);
if (value1 == null) return void this.removeAttributeNS(fullname.space, fullname.local);
value0 = this.getAttributeNS(fullname.space, fullname.local);
return value0 === value1 ? null
: value0 === value00 && value1 === value10 ? interpolate0
: interpolate0 = d3Interpolate.interpolate(value00 = value0, value10 = value1);
};
}
function transition_attr(name, value) {
var fullname = d3Selection.namespace(name);
return this.attrTween(name, typeof value === "function"
? (fullname.local ? attrFunctionNS : attrFunction)(fullname, tweenValue(this, "attr." + name, value))
: value == null ? (fullname.local ? attrRemoveNS : attrRemove)(fullname)
: (fullname.local ? attrConstantNS : attrConstant)(fullname, value + ""));
}
function attrTweenNS(fullname, value) {
function tween() {
var node = this, i = value.apply(node, arguments);
return i && function(t) {
node.setAttributeNS(fullname.space, fullname.local, i(t));
};
}
tween._value = value;
return tween;
}
function attrTween(name, value) {
function tween() {
var node = this, i = value.apply(node, arguments);
return i && function(t) {
node.setAttribute(name, i(t));
};
}
tween._value = value;
return tween;
}
function transition_attrTween(name, value) {
var key = "attr." + name;
if (arguments.length < 2) return (key = this.tween(key)) && key._value;
if (typeof value !== "function") throw new Error;
var fullname = d3Selection.namespace(name);
return this.tween(key, (fullname.local
? attrTweenNS
: attrTween)(fullname, value));
}
function delayFunction(key, id, value) {

@@ -462,3 +519,3 @@ return function() {

interpolate0;
return value1 += "", function() {
return function() {
var value0 = d3Selection.window(this).getComputedStyle(this, null).getPropertyValue(name);

@@ -478,5 +535,4 @@ return value0 === value1 ? null

value0 = style.getPropertyValue(name),
value1 = value.apply(this, arguments);
value1 = value(this);
if (value1 == null) value1 = (this.style.removeProperty(name), style.getPropertyValue(name));
else value1 += "";
return value0 === value1 ? null

@@ -492,5 +548,5 @@ : value0 === value00 && value1 === value10 ? interpolate0

.on("end.style." + name, styleRemoveEnd(name))
: this.styleTween(name, (typeof value === "function"
? styleFunction
: styleConstant)(name, value), priority);
: this.styleTween(name, typeof value === "function"
? styleFunction(name, tweenValue(this, "style." + name, value))
: styleConstant(name, value + ""), priority);
}

@@ -518,3 +574,3 @@

function textConstant(value) {
return value = value == null ? "" : value + "", function() {
return function() {
this.textContent = value;

@@ -526,5 +582,4 @@ };

return function() {
var v = value.apply(this, arguments);
if (v == null) v = "";
this.textContent = v;
var value1 = value(this);
this.textContent = value1 == null ? "" : value1;
};

@@ -534,5 +589,5 @@ }

function transition_text(value) {
return this.tween("text", (typeof value === "function"
? textFunction
: textConstant)(value));
return this.tween("text", typeof value === "function"
? textFunction(tweenValue(this, "text", value))
: textConstant(value == null ? "" : value + ""));
}

@@ -562,46 +617,2 @@

function tweenFunction(key, id, name, value) {
var tweens0, tweens1;
return function() {
var schedule = set(this, key, id),
tweens = schedule.tweens;
// If this node shared tweens with the previous node,
// just assign the updated shared tweens and we’re done!
// Otherwise, copy-on-write.
if (tweens !== tweens0) {
tweens1 = (tweens0 = tweens).slice();
for (var t = {name: name, value: value}, i = 0, n = tweens1.length; i < n; ++i) {
if (tweens1[i].name === name) {
tweens1[i] = t;
break;
}
}
if (i === n) tweens1.push(t);
}
schedule.tweens = tweens1;
};
}
function transition_tween(name, value) {
var key = this._key,
id = this._id;
name += "";
if (arguments.length < 2) {
var tweens = get(this.node(), key, id).tweens;
for (var i = 0, n = tweens.length, t; i < n; ++i) {
if ((t = tweens[i]).name === name) {
return t.value;
}
}
return null;
}
if (typeof value !== "function") throw new Error;
return this.each(tweenFunction(key, id, name, value));
}
var id = 0;

@@ -719,3 +730,3 @@

var version = "0.2.1";
var version = "0.2.2";

@@ -722,0 +733,0 @@ exports.version = version;

@@ -1,1 +0,1 @@

!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("d3-selection"),require("d3-interpolate"),require("d3-dispatch"),require("d3-timer"),require("d3-ease")):"function"==typeof define&&define.amd?define(["exports","d3-selection","d3-interpolate","d3-dispatch","d3-timer","d3-ease"],e):e(t.d3_transition=t.d3_transition||{},t.d3_selection,t.d3_interpolate,t.d3_dispatch,t.d3_timer,t.d3_ease)}(this,function(t,e,n,r,i,o){"use strict";function u(t,r){return"transform"===r&&t.namespaceURI===e.namespaces.svg?n.interpolateTransform:n.interpolate}function a(t){return function(){this.removeAttribute(t)}}function s(t){return function(){this.removeAttributeNS(t.space,t.local)}}function l(t,e){var n,r;return e+="",function(){var i=this.getAttribute(t);return i===e?null:i===n?r:r=u(this,t)(n=i,e)}}function c(t,e){var r,i;return e+="",function(){var o=this.getAttributeNS(t.space,t.local);return o===e?null:o===r?i:i=n.interpolate(r=o,e)}}function f(t,e){var n,r,i;return function(){var o,a=e.apply(this,arguments);return null==a?void this.removeAttribute(t):(o=this.getAttribute(t),a+="",o===a?null:o===n&&a===r?i:i=u(this,t)(n=o,r=a))}}function h(t,e){var r,i,o;return function(){var u,a=e.apply(this,arguments);return null==a?void this.removeAttributeNS(t.space,t.local):(u=this.getAttributeNS(t.space,t.local),a+="",u===a?null:u===r&&a===i?o:o=n.interpolate(r=u,i=a))}}function p(t,n){var r=e.namespace(t);return this.attrTween(t,(null==n?r.local?s:a:"function"==typeof n?r.local?h:f:r.local?c:l)(r,n))}function d(t,e){function n(){var n=this,r=e.apply(n,arguments);return r&&function(e){n.setAttributeNS(t.space,t.local,r(e))}}return n._value=e,n}function _(t,e){function n(){var n=this,r=e.apply(n,arguments);return r&&function(e){n.setAttribute(t,r(e))}}return n._value=e,n}function v(t,n){var r="attr."+t;if(arguments.length<2)return(r=this.tween(r))&&r._value;if("function"!=typeof n)throw new Error;var i=e.namespace(t);return this.tween(r,(i.local?d:_)(i,n))}function y(t,e,n,r,i,o){var u=t[e];if(u){if(g(t,e,n))return}else t[e]=u={active:null,pending:[]};k(t,e,{id:n,index:r,group:i,on:ut,tweens:at,time:o.time,delay:o.delay,duration:o.duration,ease:o.ease,timer:null,state:st})}function g(t,e,n){var r=t[e];if(r){var i=r.active;if(i&&i.id===n)return i;for(var o=r.pending,u=o.length;--u>=0;)if((i=o[u]).id===n)return i}}function w(t,e,n){var r=g(t,e,n);if(!r||r.state>st)throw new Error("too late");return r}function m(t,e,n){var r=g(t,e,n);if(!r||r.state>lt)throw new Error("too late");return r}function A(t,e,n){var r=g(t,e,n);if(!r)throw new Error("too late");return r}function k(t,e,n){function r(t){n.state=lt,n.delay<=t?o(t-n.delay):n.timer.restart(o,n.delay,n.time)}function o(e){var r,o,l,c,f=s.active,h=s.pending;for(f&&(f.timer.stop(),f.on.call("interrupt",t,t.__data__,f.index,f.group)),r=0,o=-1,l=h.length;l>r;++r)c=h[r],c.id<n.id?c.timer.stop():c.id>n.id&&(h[++o]=c);for(h.length=o+1,s.active=n,i.timeout(function(){s.active===n&&(n.timer.restart(u,n.delay,n.time),u(e))}),n.on.call("start",t,t.__data__,n.index,n.group),n.state=ct,a=new Array(l=n.tweens.length),r=0,o=-1;l>r;++r)(c=n.tweens[r].value.call(t,t.__data__,n.index,n.group))&&(a[++o]=c);a.length=o+1}function u(r){var i,o,u=r/n.duration,l=u>=1?1:n.ease.call(null,u);for(i=0,o=a.length;o>i;++i)a[i].call(null,l);u>=1&&(n.on.call("end",t,t.__data__,n.index,n.group),s.active=null,s.pending.length||delete t[e],n.timer.stop())}var a,s=t[e];s.pending.push(n),n.timer=i.timer(r,0,n.time)}function b(t,e,n){return function(){w(this,t,e).delay=+n.apply(this,arguments)}}function x(t,e,n){return n=+n,function(){w(this,t,e).delay=n}}function P(t){var e=this._key,n=this._id;return arguments.length?this.each(("function"==typeof t?b:x)(e,n,t)):A(this.node(),e,n).delay}function E(t,e,n){return function(){m(this,t,e).duration=+n.apply(this,arguments)}}function S(t,e,n){return n=+n,function(){m(this,t,e).duration=n}}function C(t){var e=this._key,n=this._id;return arguments.length?this.each(("function"==typeof t?E:S)(e,n,t)):A(this.node(),e,n).duration}function N(t,e,n){if("function"!=typeof n)throw new Error;return function(){m(this,t,e).ease=n}}function T(t){var e=this._key,n=this._id;return arguments.length?this.each(N(e,n,t)):A(this.node(),e,n).ease}function q(t){"function"!=typeof t&&(t=e.matcher(t));for(var n=this._groups,r=n.length,i=new Array(r),o=0;r>o;++o)for(var u,a=n[o],s=a.length,l=i[o]=new Array(s),c=0;s>c;++c)(u=a[c])&&t.call(u,u.__data__,c,a)&&(l[c]=u);return new $(i,this._parents,this._key,this._id)}function V(t){for(var e=this._groups,n=t._groups,r=e.length,i=n.length,o=Math.min(r,i),u=new Array(r),a=0;o>a;++a)for(var s,l=e[a],c=n[a],f=l.length,h=u[a]=new Array(f),p=0;f>p;++p)(s=l[p]||c[p])&&(h[p]=s);for(;r>a;++a)u[a]=e[a];return new $(u,this._parents,this._key,this._id)}function z(t,e,n,r){if("function"!=typeof r)throw new Error;var i,o;return function(){var u=w(this,t,e),a=u.on;a!==i&&(o=(i=a).copy()).on(n,r),u.on=o}}function I(t,e){var n=this._key,r=this._id;return arguments.length<2?A(this.node(),n,r).on.on(t):this.each(z(n,r,t,e))}function j(t){return function(){var e=this.parentNode;e&&!this[t].pending.length&&e.removeChild(this)}}function M(){return this.on("end.remove",j(this._key))}function O(t){var n=this._key,r=this._id;"function"!=typeof t&&(t=e.selector(t));for(var i=this._groups,o=i.length,u=new Array(o),a=0;o>a;++a)for(var s,l,c=i[a],f=c.length,h=u[a]=new Array(f),p=0;f>p;++p)(s=c[p])&&(l=t.call(s,s.__data__,p,c))&&("__data__"in s&&(l.__data__=s.__data__),h[p]=l,y(h[p],n,r,p,h,A(s,n,r)));return new $(u,this._parents,n,r)}function R(t){var n=this._key,r=this._id;"function"!=typeof t&&(t=e.selectorAll(t));for(var i=this._groups,o=i.length,u=[],a=[],s=0;o>s;++s)for(var l,c=i[s],f=c.length,h=0;f>h;++h)if(l=c[h]){for(var p,d=t.call(l,l.__data__,h,c),_=A(l,n,r),v=0,g=d.length;g>v;++v)(p=d[v])&&y(p,n,r,v,d,_);u.push(d),a.push(l)}return new $(u,a,n,r)}function U(){return new ft(this._groups,this._parents)}function B(t){var r,i,o;return function(){var u=e.window(this).getComputedStyle(this,null),a=u.getPropertyValue(t),s=(this.style.removeProperty(t),u.getPropertyValue(t));return a===s?null:a===r&&s===i?o:o=n.interpolate(r=a,i=s)}}function D(t){return function(){this.style.removeProperty(t)}}function F(t,r){var i,o;return r+="",function(){var u=e.window(this).getComputedStyle(this,null).getPropertyValue(t);return u===r?null:u===i?o:o=n.interpolate(i=u,r)}}function G(t,r){var i,o,u;return function(){var a=e.window(this).getComputedStyle(this,null),s=a.getPropertyValue(t),l=r.apply(this,arguments);return null==l?(this.style.removeProperty(t),l=a.getPropertyValue(t)):l+="",s===l?null:s===i&&l===o?u:u=n.interpolate(i=s,o=l)}}function H(t,e,n){return null==e?this.styleTween(t,B(t)).on("end.style."+t,D(t)):this.styleTween(t,("function"==typeof e?G:F)(t,e),n)}function J(t,e,n){function r(){var r=this,i=e.apply(r,arguments);return i&&function(e){r.style.setProperty(t,i(e),n)}}if("function"!=typeof e)throw new Error;return r._value=e,r}function K(t,e,n){var r="style."+t;return arguments.length<2?(r=this.tween(r))&&r._value:this.tween(r,J(t,e,null==n?"":n))}function L(t){return t=null==t?"":t+"",function(){this.textContent=t}}function Q(t){return function(){var e=t.apply(this,arguments);null==e&&(e=""),this.textContent=e}}function W(t){return this.tween("text",("function"==typeof t?Q:L)(t))}function X(){for(var t=this._key,e=this._id,n=et(),r=this._groups,i=r.length,o=0;i>o;++o)for(var u,a=r[o],s=a.length,l=0;s>l;++l)if(u=a[l]){var c=A(u,t,e);y(u,t,n,l,a,{time:c.time+c.delay+c.duration,delay:0,duration:c.duration,ease:c.ease})}return new $(r,this._parents,t,n)}function Y(t,e,n,r){var i,o;return function(){var u=m(this,t,e),a=u.tweens;if(a!==i){o=(i=a).slice();for(var s={name:n,value:r},l=0,c=o.length;c>l;++l)if(o[l].name===n){o[l]=s;break}l===c&&o.push(s)}u.tweens=o}}function Z(t,e){var n=this._key,r=this._id;if(t+="",arguments.length<2){for(var i,o=A(this.node(),n,r).tweens,u=0,a=o.length;a>u;++u)if((i=o[u]).name===t)return i.value;return null}if("function"!=typeof e)throw new Error;return this.each(Y(n,r,t,e))}function $(t,e,n,r){this._groups=t,this._parents=e,this._key=n,this._id=r}function tt(t){return e.selection().transition(t)}function et(){return++ht}function nt(t){return t?"__transition"+t:"__transition"}function rt(t){var e=nt(t);return this.each(function(){var t=this[e];if(t){var n,r,i=t.pending,o=t.active;for(o&&(o.on.call("interrupt",this,this.__data__,o.index,o.group),t.active=null,o.timer.stop()),n=0,r=i.length;r>n;++n)i[n].timer.stop();i.length=0,delete this[e]}})}function it(t){var e,n,r;t instanceof $?(e=t._key,n=t._id,r=A(t.node(),e,n)):(e=nt(t),n=et(),(r=dt).time=i.now());for(var o=this._groups,u=o.length,a=0;u>a;++a)for(var s,l=o[a],c=l.length,f=0;c>f;++f)(s=l[f])&&y(s,e,n,f,l,r);return new $(o,this._parents,e,n)}function ot(t,e){var n=nt(e),r=t[n];return r&&(r=r.active)?new $([[t]],_t,n,r.id):null}var ut=r.dispatch("start","end","interrupt"),at=[],st=0,lt=1,ct=2,ft=e.selection.prototype.constructor,ht=0,pt=e.selection.prototype;$.prototype=tt.prototype={constructor:$,select:O,selectAll:R,filter:q,merge:V,selection:U,transition:X,call:pt.call,nodes:pt.nodes,node:pt.node,size:pt.size,empty:pt.empty,each:pt.each,on:I,attr:p,attrTween:v,style:H,styleTween:K,text:W,remove:M,tween:Z,delay:P,duration:C,ease:T};var dt={time:null,delay:0,duration:250,ease:o.easeCubicInOut};e.selection.prototype.interrupt=rt,e.selection.prototype.transition=it;var _t=[null],vt="0.2.1";t.version=vt,t.transition=tt,t.active=ot});
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("d3-selection"),require("d3-interpolate"),require("d3-dispatch"),require("d3-timer"),require("d3-ease")):"function"==typeof define&&define.amd?define(["exports","d3-selection","d3-interpolate","d3-dispatch","d3-timer","d3-ease"],e):e(t.d3_transition=t.d3_transition||{},t.d3_selection,t.d3_interpolate,t.d3_dispatch,t.d3_timer,t.d3_ease)}(this,function(t,e,n,r,i,o){"use strict";function u(t,e,n,r,i,o){var u=t[e];if(u){if(a(t,e,n))return}else t[e]=u={active:null,pending:[]};f(t,e,{id:n,index:r,group:i,on:at,tween:st,time:o.time,delay:o.delay,duration:o.duration,ease:o.ease,timer:null,state:lt})}function a(t,e,n){var r=t[e];if(r){var i=r.active;if(i&&i.id===n)return i;for(var o=r.pending,u=o.length;--u>=0;)if((i=o[u]).id===n)return i}}function s(t,e,n){var r=a(t,e,n);if(!r||r.state>lt)throw new Error("too late");return r}function l(t,e,n){var r=a(t,e,n);if(!r||r.state>ct)throw new Error("too late");return r}function c(t,e,n){var r=a(t,e,n);if(!r)throw new Error("too late");return r}function f(t,e,n){function r(t){n.state=ct,n.delay<=t?o(t-n.delay):n.timer.restart(o,n.delay,n.time)}function o(e){var r,o,l,c,f=s.active,h=s.pending;for(f&&(f.timer.stop(),f.on.call("interrupt",t,t.__data__,f.index,f.group)),r=0,o=-1,l=h.length;l>r;++r)c=h[r],c.id<n.id?c.timer.stop():c.id>n.id&&(h[++o]=c);for(h.length=o+1,s.active=n,i.timeout(function(){s.active===n&&(n.timer.restart(u,n.delay,n.time),u(e))}),n.on.call("start",t,t.__data__,n.index,n.group),n.state=ft,a=new Array(l=n.tween.length),r=0,o=-1;l>r;++r)(c=n.tween[r].value.call(t,t.__data__,n.index,n.group))&&(a[++o]=c);a.length=o+1}function u(r){var i,o,u=r/n.duration,l=u>=1?1:n.ease.call(null,u);for(i=0,o=a.length;o>i;++i)a[i].call(null,l);u>=1&&(n.on.call("end",t,t.__data__,n.index,n.group),s.active=null,s.pending.length||delete t[e],n.timer.stop())}var a,s=t[e];s.pending.push(n),n.timer=i.timer(r,0,n.time)}function h(t,e,n,r){var i,o;return function(){var u=l(this,t,e),a=u.tween;if(a!==i){o=(i=a).slice();for(var s={name:n,value:r},c=0,f=o.length;f>c;++c)if(o[c].name===n){o[c]=s;break}c===f&&o.push(s)}u.tween=o}}function p(t,e){var n=this._key,r=this._id;if(t+="",arguments.length<2){for(var i,o=c(this.node(),n,r).tween,u=0,a=o.length;a>u;++u)if((i=o[u]).name===t)return i.value;return null}if("function"!=typeof e)throw new Error;return this.each(h(n,r,t,e))}function d(t,e,n){var r=t._key,i=t._id;return t.each(function(){var t=l(this,r,i),o=n.apply(this,arguments);(t.value||(t.value={}))[e]=null==o?null:o+""}),function(t){return c(t,r,i).value[e]}}function v(t,r){return"transform"===r&&t.namespaceURI===e.namespaces.svg?n.interpolateTransform:n.interpolate}function _(t){return function(){this.removeAttribute(t)}}function y(t){return function(){this.removeAttributeNS(t.space,t.local)}}function g(t,e){var n,r;return function(){var i=this.getAttribute(t);return i===e?null:i===n?r:r=v(this,t)(n=i,e)}}function w(t,e){var r,i;return function(){var o=this.getAttributeNS(t.space,t.local);return o===e?null:o===r?i:i=n.interpolate(r=o,e)}}function m(t,e){var n,r,i;return function(){var o,u=e(this);return null==u?void this.removeAttribute(t):(o=this.getAttribute(t),o===u?null:o===n&&u===r?i:i=v(this,t)(n=o,r=u))}}function A(t,e){var r,i,o;return function(){var u,a=e(this);return null==a?void this.removeAttributeNS(t.space,t.local):(u=this.getAttributeNS(t.space,t.local),u===a?null:u===r&&a===i?o:o=n.interpolate(r=u,i=a))}}function k(t,n){var r=e.namespace(t);return this.attrTween(t,"function"==typeof n?(r.local?A:m)(r,d(this,"attr."+t,n)):null==n?(r.local?y:_)(r):(r.local?w:g)(r,n+""))}function x(t,e){function n(){var n=this,r=e.apply(n,arguments);return r&&function(e){n.setAttributeNS(t.space,t.local,r(e))}}return n._value=e,n}function b(t,e){function n(){var n=this,r=e.apply(n,arguments);return r&&function(e){n.setAttribute(t,r(e))}}return n._value=e,n}function P(t,n){var r="attr."+t;if(arguments.length<2)return(r=this.tween(r))&&r._value;if("function"!=typeof n)throw new Error;var i=e.namespace(t);return this.tween(r,(i.local?x:b)(i,n))}function E(t,e,n){return function(){s(this,t,e).delay=+n.apply(this,arguments)}}function S(t,e,n){return n=+n,function(){s(this,t,e).delay=n}}function C(t){var e=this._key,n=this._id;return arguments.length?this.each(("function"==typeof t?E:S)(e,n,t)):c(this.node(),e,n).delay}function N(t,e,n){return function(){l(this,t,e).duration=+n.apply(this,arguments)}}function T(t,e,n){return n=+n,function(){l(this,t,e).duration=n}}function q(t){var e=this._key,n=this._id;return arguments.length?this.each(("function"==typeof t?N:T)(e,n,t)):c(this.node(),e,n).duration}function V(t,e,n){if("function"!=typeof n)throw new Error;return function(){l(this,t,e).ease=n}}function z(t){var e=this._key,n=this._id;return arguments.length?this.each(V(e,n,t)):c(this.node(),e,n).ease}function I(t){"function"!=typeof t&&(t=e.matcher(t));for(var n=this._groups,r=n.length,i=new Array(r),o=0;r>o;++o)for(var u,a=n[o],s=a.length,l=i[o]=new Array(s),c=0;s>c;++c)(u=a[c])&&t.call(u,u.__data__,c,a)&&(l[c]=u);return new tt(i,this._parents,this._key,this._id)}function j(t){for(var e=this._groups,n=t._groups,r=e.length,i=n.length,o=Math.min(r,i),u=new Array(r),a=0;o>a;++a)for(var s,l=e[a],c=n[a],f=l.length,h=u[a]=new Array(f),p=0;f>p;++p)(s=l[p]||c[p])&&(h[p]=s);for(;r>a;++a)u[a]=e[a];return new tt(u,this._parents,this._key,this._id)}function M(t,e,n,r){if("function"!=typeof r)throw new Error;var i,o;return function(){var u=s(this,t,e),a=u.on;a!==i&&(o=(i=a).copy()).on(n,r),u.on=o}}function O(t,e){var n=this._key,r=this._id;return arguments.length<2?c(this.node(),n,r).on.on(t):this.each(M(n,r,t,e))}function R(t){return function(){var e=this.parentNode;e&&!this[t].pending.length&&e.removeChild(this)}}function U(){return this.on("end.remove",R(this._key))}function B(t){var n=this._key,r=this._id;"function"!=typeof t&&(t=e.selector(t));for(var i=this._groups,o=i.length,a=new Array(o),s=0;o>s;++s)for(var l,f,h=i[s],p=h.length,d=a[s]=new Array(p),v=0;p>v;++v)(l=h[v])&&(f=t.call(l,l.__data__,v,h))&&("__data__"in l&&(f.__data__=l.__data__),d[v]=f,u(d[v],n,r,v,d,c(l,n,r)));return new tt(a,this._parents,n,r)}function D(t){var n=this._key,r=this._id;"function"!=typeof t&&(t=e.selectorAll(t));for(var i=this._groups,o=i.length,a=[],s=[],l=0;o>l;++l)for(var f,h=i[l],p=h.length,d=0;p>d;++d)if(f=h[d]){for(var v,_=t.call(f,f.__data__,d,h),y=c(f,n,r),g=0,w=_.length;w>g;++g)(v=_[g])&&u(v,n,r,g,_,y);a.push(_),s.push(f)}return new tt(a,s,n,r)}function F(){return new ht(this._groups,this._parents)}function G(t){var r,i,o;return function(){var u=e.window(this).getComputedStyle(this,null),a=u.getPropertyValue(t),s=(this.style.removeProperty(t),u.getPropertyValue(t));return a===s?null:a===r&&s===i?o:o=n.interpolate(r=a,i=s)}}function H(t){return function(){this.style.removeProperty(t)}}function J(t,r){var i,o;return function(){var u=e.window(this).getComputedStyle(this,null).getPropertyValue(t);return u===r?null:u===i?o:o=n.interpolate(i=u,r)}}function K(t,r){var i,o,u;return function(){var a=e.window(this).getComputedStyle(this,null),s=a.getPropertyValue(t),l=r(this);return null==l&&(this.style.removeProperty(t),l=a.getPropertyValue(t)),s===l?null:s===i&&l===o?u:u=n.interpolate(i=s,o=l)}}function L(t,e,n){return null==e?this.styleTween(t,G(t)).on("end.style."+t,H(t)):this.styleTween(t,"function"==typeof e?K(t,d(this,"style."+t,e)):J(t,e+""),n)}function Q(t,e,n){function r(){var r=this,i=e.apply(r,arguments);return i&&function(e){r.style.setProperty(t,i(e),n)}}if("function"!=typeof e)throw new Error;return r._value=e,r}function W(t,e,n){var r="style."+t;return arguments.length<2?(r=this.tween(r))&&r._value:this.tween(r,Q(t,e,null==n?"":n))}function X(t){return function(){this.textContent=t}}function Y(t){return function(){var e=t(this);this.textContent=null==e?"":e}}function Z(t){return this.tween("text","function"==typeof t?Y(d(this,"text",t)):X(null==t?"":t+""))}function $(){for(var t=this._key,e=this._id,n=nt(),r=this._groups,i=r.length,o=0;i>o;++o)for(var a,s=r[o],l=s.length,f=0;l>f;++f)if(a=s[f]){var h=c(a,t,e);u(a,t,n,f,s,{time:h.time+h.delay+h.duration,delay:0,duration:h.duration,ease:h.ease})}return new tt(r,this._parents,t,n)}function tt(t,e,n,r){this._groups=t,this._parents=e,this._key=n,this._id=r}function et(t){return e.selection().transition(t)}function nt(){return++pt}function rt(t){return t?"__transition"+t:"__transition"}function it(t){var e=rt(t);return this.each(function(){var t=this[e];if(t){var n,r,i=t.pending,o=t.active;for(o&&(o.on.call("interrupt",this,this.__data__,o.index,o.group),t.active=null,o.timer.stop()),n=0,r=i.length;r>n;++n)i[n].timer.stop();i.length=0,delete this[e]}})}function ot(t){var e,n,r;t instanceof tt?(e=t._key,n=t._id,r=c(t.node(),e,n)):(e=rt(t),n=nt(),(r=vt).time=i.now());for(var o=this._groups,a=o.length,s=0;a>s;++s)for(var l,f=o[s],h=f.length,p=0;h>p;++p)(l=f[p])&&u(l,e,n,p,f,r);return new tt(o,this._parents,e,n)}function ut(t,e){var n=rt(e),r=t[n];return r&&(r=r.active)?new tt([[t]],_t,n,r.id):null}var at=r.dispatch("start","end","interrupt"),st=[],lt=0,ct=1,ft=2,ht=e.selection.prototype.constructor,pt=0,dt=e.selection.prototype;tt.prototype=et.prototype={constructor:tt,select:B,selectAll:D,filter:I,merge:j,selection:F,transition:$,call:dt.call,nodes:dt.nodes,node:dt.node,size:dt.size,empty:dt.empty,each:dt.each,on:O,attr:k,attrTween:P,style:L,styleTween:W,text:Z,remove:U,tween:p,delay:C,duration:q,ease:z};var vt={time:null,delay:0,duration:250,ease:o.easeCubicInOut};e.selection.prototype.interrupt=it,e.selection.prototype.transition=ot;var _t=[null],yt="0.2.2";t.version=yt,t.transition=et,t.active=ut});
{
"name": "d3-transition",
"version": "0.2.1",
"version": "0.2.2",
"description": "Animated transitions for D3 selections.",

@@ -5,0 +5,0 @@ "keywords": [

import {interpolate, interpolateTransform} from "d3-interpolate";
import {namespace, namespaces} from "d3-selection";
import {tweenValue} from "./tween";

@@ -26,3 +27,3 @@ // TODO Assumes either ALL selected nodes are SVG, or none are.

interpolate0;
return value1 += "", function() {
return function() {
var value0 = this.getAttribute(name);

@@ -38,3 +39,3 @@ return value0 === value1 ? null

interpolate0;
return value1 += "", function() {
return function() {
var value0 = this.getAttributeNS(fullname.space, fullname.local);

@@ -52,6 +53,5 @@ return value0 === value1 ? null

return function() {
var value0,
value1 = value.apply(this, arguments);
var value0, value1 = value(this);
if (value1 == null) return void this.removeAttribute(name);
value0 = this.getAttribute(name), value1 += "";
value0 = this.getAttribute(name);
return value0 === value1 ? null

@@ -68,5 +68,5 @@ : value0 === value00 && value1 === value10 ? interpolate0

return function() {
var value0, value1 = value.apply(this, arguments);
var value0, value1 = value(this);
if (value1 == null) return void this.removeAttributeNS(fullname.space, fullname.local);
value0 = this.getAttributeNS(fullname.space, fullname.local), value1 += "";
value0 = this.getAttributeNS(fullname.space, fullname.local);
return value0 === value1 ? null

@@ -80,6 +80,6 @@ : value0 === value00 && value1 === value10 ? interpolate0

var fullname = namespace(name);
return this.attrTween(name, (value == null
? (fullname.local ? attrRemoveNS : attrRemove) : (typeof value === "function"
? (fullname.local ? attrFunctionNS : attrFunction)
: (fullname.local ? attrConstantNS : attrConstant)))(fullname, value));
return this.attrTween(name, typeof value === "function"
? (fullname.local ? attrFunctionNS : attrFunction)(fullname, tweenValue(this, "attr." + name, value))
: value == null ? (fullname.local ? attrRemoveNS : attrRemove)(fullname)
: (fullname.local ? attrConstantNS : attrConstant)(fullname, value + ""));
}

@@ -5,3 +5,3 @@ import {dispatch} from "d3-dispatch";

var emptyOn = dispatch("start", "end", "interrupt");
var emptyTweens = [];
var emptyTween = [];

@@ -21,3 +21,3 @@ var CREATED = 0,

on: emptyOn,
tweens: emptyTweens,
tween: emptyTween,
time: timing.time,

@@ -61,3 +61,3 @@ delay: timing.delay,

var schedules = node[key],
tweens;
tween;

@@ -114,14 +114,14 @@ // Initialize the self timer when the transition is created.

// Dispatch the start event.
// Note this must be done before the tweens are initialized.
// Note this must be done before the tween are initialized.
self.on.call("start", node, node.__data__, self.index, self.group);
self.state = STARTED;
// Initialize the tweens, deleting null tweens.
tweens = new Array(n = self.tweens.length);
// Initialize the tween, deleting null tween.
tween = new Array(n = self.tween.length);
for (i = 0, j = -1; i < n; ++i) {
if (o = self.tweens[i].value.call(node, node.__data__, self.index, self.group)) {
tweens[++j] = o;
if (o = self.tween[i].value.call(node, node.__data__, self.index, self.group)) {
tween[++j] = o;
}
}
tweens.length = j + 1;
tween.length = j + 1;
}

@@ -134,4 +134,4 @@

for (i = 0, n = tweens.length; i < n; ++i) {
tweens[i].call(null, e);
for (i = 0, n = tween.length; i < n; ++i) {
tween[i].call(null, e);
}

@@ -138,0 +138,0 @@

import {interpolate} from "d3-interpolate";
import {window} from "d3-selection";
import {tweenValue} from "./tween";

@@ -27,3 +28,3 @@ function styleRemove(name) {

interpolate0;
return value1 += "", function() {
return function() {
var value0 = window(this).getComputedStyle(this, null).getPropertyValue(name);

@@ -43,5 +44,4 @@ return value0 === value1 ? null

value0 = style.getPropertyValue(name),
value1 = value.apply(this, arguments);
value1 = value(this);
if (value1 == null) value1 = (this.style.removeProperty(name), style.getPropertyValue(name));
else value1 += "";
return value0 === value1 ? null

@@ -57,5 +57,5 @@ : value0 === value00 && value1 === value10 ? interpolate0

.on("end.style." + name, styleRemoveEnd(name))
: this.styleTween(name, (typeof value === "function"
? styleFunction
: styleConstant)(name, value), priority);
: this.styleTween(name, typeof value === "function"
? styleFunction(name, tweenValue(this, "style." + name, value))
: styleConstant(name, value + ""), priority);
}

@@ -0,3 +1,5 @@

import {tweenValue} from "./tween";
function textConstant(value) {
return value = value == null ? "" : value + "", function() {
return function() {
this.textContent = value;

@@ -9,5 +11,4 @@ };

return function() {
var v = value.apply(this, arguments);
if (v == null) v = "";
this.textContent = v;
var value1 = value(this);
this.textContent = value1 == null ? "" : value1;
};

@@ -17,5 +18,5 @@ }

export default function(value) {
return this.tween("text", (typeof value === "function"
? textFunction
: textConstant)(value));
return this.tween("text", typeof value === "function"
? textFunction(tweenValue(this, "text", value))
: textConstant(value == null ? "" : value + ""));
}
import {get, set} from "./schedule";
function tweenFunction(key, id, name, value) {
var tweens0, tweens1;
var tween0, tween1;
return function() {
var schedule = set(this, key, id),
tweens = schedule.tweens;
tween = schedule.tween;
// If this node shared tweens with the previous node,
// just assign the updated shared tweens and we’re done!
// If this node shared tween with the previous node,
// just assign the updated shared tween and we’re done!
// Otherwise, copy-on-write.
if (tweens !== tweens0) {
tweens1 = (tweens0 = tweens).slice();
for (var t = {name: name, value: value}, i = 0, n = tweens1.length; i < n; ++i) {
if (tweens1[i].name === name) {
tweens1[i] = t;
if (tween !== tween0) {
tween1 = (tween0 = tween).slice();
for (var t = {name: name, value: value}, i = 0, n = tween1.length; i < n; ++i) {
if (tween1[i].name === name) {
tween1[i] = t;
break;
}
}
if (i === n) tweens1.push(t);
if (i === n) tween1.push(t);
}
schedule.tweens = tweens1;
schedule.tween = tween1;
};

@@ -34,5 +34,5 @@ }

if (arguments.length < 2) {
var tweens = get(this.node(), key, id).tweens;
for (var i = 0, n = tweens.length, t; i < n; ++i) {
if ((t = tweens[i]).name === name) {
var tween = get(this.node(), key, id).tween;
for (var i = 0, n = tween.length, t; i < n; ++i) {
if ((t = tween[i]).name === name) {
return t.value;

@@ -47,1 +47,15 @@ }

}
export function tweenValue(transition, name, value) {
var key = transition._key,
id = transition._id;
transition.each(function() {
var schedule = set(this, key, id), v = value.apply(this, arguments);
(schedule.value || (schedule.value = {}))[name] = v == null ? null : v + "";
});
return function(node) {
return get(node, key, id).value[name];
};
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc