source: node_modules/d3-transition/src/transition/attr.js@ a762898

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

Prototype 1.1

  • Property mode set to 100644
File size: 2.6 KB
Line 
1import {interpolateTransformSvg as interpolateTransform} from "d3-interpolate";
2import {namespace} from "d3-selection";
3import {tweenValue} from "./tween.js";
4import interpolate from "./interpolate.js";
5
6function attrRemove(name) {
7 return function() {
8 this.removeAttribute(name);
9 };
10}
11
12function attrRemoveNS(fullname) {
13 return function() {
14 this.removeAttributeNS(fullname.space, fullname.local);
15 };
16}
17
18function attrConstant(name, interpolate, value1) {
19 var string00,
20 string1 = value1 + "",
21 interpolate0;
22 return function() {
23 var string0 = this.getAttribute(name);
24 return string0 === string1 ? null
25 : string0 === string00 ? interpolate0
26 : interpolate0 = interpolate(string00 = string0, value1);
27 };
28}
29
30function attrConstantNS(fullname, interpolate, value1) {
31 var string00,
32 string1 = value1 + "",
33 interpolate0;
34 return function() {
35 var string0 = this.getAttributeNS(fullname.space, fullname.local);
36 return string0 === string1 ? null
37 : string0 === string00 ? interpolate0
38 : interpolate0 = interpolate(string00 = string0, value1);
39 };
40}
41
42function attrFunction(name, interpolate, value) {
43 var string00,
44 string10,
45 interpolate0;
46 return function() {
47 var string0, value1 = value(this), string1;
48 if (value1 == null) return void this.removeAttribute(name);
49 string0 = this.getAttribute(name);
50 string1 = value1 + "";
51 return string0 === string1 ? null
52 : string0 === string00 && string1 === string10 ? interpolate0
53 : (string10 = string1, interpolate0 = interpolate(string00 = string0, value1));
54 };
55}
56
57function attrFunctionNS(fullname, interpolate, value) {
58 var string00,
59 string10,
60 interpolate0;
61 return function() {
62 var string0, value1 = value(this), string1;
63 if (value1 == null) return void this.removeAttributeNS(fullname.space, fullname.local);
64 string0 = this.getAttributeNS(fullname.space, fullname.local);
65 string1 = value1 + "";
66 return string0 === string1 ? null
67 : string0 === string00 && string1 === string10 ? interpolate0
68 : (string10 = string1, interpolate0 = interpolate(string00 = string0, value1));
69 };
70}
71
72export default function(name, value) {
73 var fullname = namespace(name), i = fullname === "transform" ? interpolateTransform : interpolate;
74 return this.attrTween(name, typeof value === "function"
75 ? (fullname.local ? attrFunctionNS : attrFunction)(fullname, i, tweenValue(this, "attr." + name, value))
76 : value == null ? (fullname.local ? attrRemoveNS : attrRemove)(fullname)
77 : (fullname.local ? attrConstantNS : attrConstant)(fullname, i, value));
78}
Note: See TracBrowser for help on using the repository browser.