Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
MUR Drupal
d3-library
Commits
a4fed02b
Commit
a4fed02b
authored
Mar 14, 2013
by
Mike Bostock
Browse files
Get most transition tests working again.
parent
bd09d37e
Changes
21
Hide whitespace changes
Inline
Side-by-side
src/selection/selection.js
View file @
a4fed02b
...
...
@@ -49,6 +49,7 @@ import "call";
import
"
empty
"
;
import
"
node
"
;
import
"
enter
"
;
import
"
transition
"
;
var
d3_selectionRoot
=
d3_selection
([[
d3_document
]]);
...
...
src/selection/transition.js
View file @
a4fed02b
import
"
selection
"
;
import
"
../transition/transition
"
;
d3_selectionPrototype
.
transition
=
function
()
{
var
id
=
d3_transitionInheritId
||
++
d3_transitionId
,
...
...
src/transition/index.js
View file @
a4fed02b
import
"
../selection/transition
"
;
import
"
transition
"
;
test/transition/transition-test-attr.js
View file @
a4fed02b
require
(
"
../env
"
);
var
assert
=
require
(
"
../assert
"
);
module
.
exports
=
{
topic
:
function
()
{
topic
:
function
(
d3
)
{
var
s
=
d3
.
select
(
"
body
"
).
append
(
"
div
"
)
.
attr
(
"
display
"
,
"
none
"
)
.
attr
(
"
font-size
"
,
"
20px
"
)
...
...
test/transition/transition-test-attrTween.js
View file @
a4fed02b
require
(
"
../env
"
);
var
assert
=
require
(
"
../assert
"
);
var
assert
=
require
(
"
../assert
"
),
interpolateHsl
=
require
(
"
../../
"
).
interpolateHsl
;
module
.
exports
=
{
topic
:
function
()
{
topic
:
function
(
d3
)
{
var
cb
=
this
.
callback
,
dd
=
[],
ii
=
[],
...
...
@@ -13,7 +12,7 @@ module.exports = {
var
s
=
d3
.
select
(
"
body
"
).
html
(
""
).
append
(
"
div
"
).
selectAll
(
"
div
"
)
.
data
([
"
red
"
,
"
green
"
])
.
enter
().
append
(
"
div
"
)
.
attr
(
"
color
"
,
function
(
d
)
{
return
d3
.
rgb
(
d
)
+
"
"
;
});
.
attr
(
"
color
"
,
function
(
d
,
i
)
{
return
i
?
"
#008000
"
:
"
#ff0000
"
;
});
var
t
=
s
.
transition
()
.
attrTween
(
"
color
"
,
tween
);
...
...
@@ -30,7 +29,7 @@ module.exports = {
value
:
vv
,
context
:
tt
});
return
i
&&
d3
.
interpolateHsl
(
v
,
"
blue
"
);
return
i
&&
interpolateHsl
(
v
,
"
blue
"
);
}
},
...
...
test/transition/transition-test-call.js
View file @
a4fed02b
require
(
"
../env
"
);
var
assert
=
require
(
"
../assert
"
);
module
.
exports
=
{
topic
:
function
()
{
topic
:
function
(
d3
)
{
return
d3
.
select
(
"
body
"
).
append
(
"
div
"
).
transition
();
},
"
calls the function once
"
:
function
(
transition
)
{
...
...
test/transition/transition-test-delay.js
View file @
a4fed02b
require
(
"
../env
"
);
var
assert
=
require
(
"
../assert
"
);
module
.
exports
=
{
topic
:
function
()
{
topic
:
function
(
d3
)
{
return
d3
.
select
(
"
body
"
).
html
(
""
).
selectAll
()
.
data
([
"
foo
"
,
"
bar
"
])
.
enter
().
append
(
"
div
"
)
...
...
test/transition/transition-test-duration.js
View file @
a4fed02b
require
(
"
../env
"
);
var
assert
=
require
(
"
../assert
"
);
module
.
exports
=
{
topic
:
function
()
{
topic
:
function
(
d3
)
{
return
d3
.
select
(
"
body
"
).
html
(
""
).
selectAll
()
.
data
([
"
foo
"
,
"
bar
"
])
.
enter
().
append
(
"
div
"
)
...
...
test/transition/transition-test-each.js
View file @
a4fed02b
require
(
"
../env
"
);
var
assert
=
require
(
"
../assert
"
);
module
.
exports
=
{
"
start
"
:
{
topic
:
function
()
{
topic
:
function
(
d3
)
{
var
cb
=
this
.
callback
,
div
=
d3
.
select
(
"
body
"
).
html
(
""
).
selectAll
().
data
([
"
foo
"
,
"
bar
"
]).
enter
().
append
(
"
div
"
).
attr
(
"
class
"
,
String
),
transition
=
div
.
transition
().
delay
(
350
),
...
...
@@ -76,7 +74,7 @@ module.exports = {
},
"
end
"
:
{
topic
:
function
()
{
topic
:
function
(
d3
)
{
var
cb
=
this
.
callback
,
div
=
d3
.
select
(
"
body
"
).
html
(
""
).
selectAll
().
data
([
"
foo
"
,
"
bar
"
]).
enter
().
append
(
"
div
"
).
attr
(
"
class
"
,
String
),
transition
=
div
.
transition
().
duration
(
350
),
...
...
test/transition/transition-test-filter.js
View file @
a4fed02b
require
(
"
../env
"
);
var
assert
=
require
(
"
../assert
"
);
var
assert
=
require
(
"
../assert
"
),
merge
=
require
(
"
../../
"
).
merge
;
var
datum
=
{};
module
.
exports
=
{
topic
:
function
()
{
topic
:
function
(
d3
)
{
return
d3
.
select
(
"
body
"
).
html
(
""
).
selectAll
(
"
div
"
)
.
data
([
0
,
1
])
.
enter
().
append
(
"
div
"
)
...
...
@@ -25,7 +24,7 @@ module.exports = {
assert
.
isTrue
(
some
[
1
][
0
]
===
span
[
1
][
0
]);
},
"
removes non-matching elements
"
:
function
(
span
)
{
var
some
=
d3
.
merge
(
span
.
filter
(
function
(
d
,
i
)
{
return
d
&
1
;
}));
var
some
=
merge
(
span
.
filter
(
function
(
d
,
i
)
{
return
d
&
1
;
}));
assert
.
equal
(
some
.
indexOf
(
span
[
0
][
0
]),
-
1
);
assert
.
equal
(
some
.
indexOf
(
span
[
1
][
0
]),
-
1
);
},
...
...
@@ -50,12 +49,13 @@ module.exports = {
span
.
filter
(
function
(
d
,
i
)
{
return
d
&
1
;
}).
each
(
function
(
d
,
i
)
{
indexes
.
push
(
i
);
});
assert
.
deepEqual
(
indexes
,
[
0
,
0
]);
},
"
ignores null nodes
"
:
function
()
{
var
span
=
d3
.
selectAll
(
"
span
"
)
;
"
ignores null nodes
"
:
function
(
span
)
{
var
node
=
span
[
0
][
1
]
;
span
[
0
][
1
]
=
null
;
var
some
=
span
.
filter
(
function
(
d
,
i
)
{
return
d
&
1
;
});
assert
.
isTrue
(
some
[
0
][
0
]
===
span
[
0
][
3
]);
assert
.
equal
(
some
.
length
,
1
);
assert
.
equal
(
some
.
length
,
2
);
span
[
0
][
1
]
=
node
;
},
"
can be specified as a selector
"
:
function
(
span
)
{
var
some
=
span
.
filter
(
"
.foo
"
);
...
...
test/transition/transition-test-id.js
View file @
a4fed02b
require
(
"
../env
"
);
var
assert
=
require
(
"
../assert
"
);
module
.
exports
=
{
topic
:
function
()
{
return
d3
.
select
(
"
body
"
).
append
(
"
div
"
).
transition
();
},
"
has a positive integer id
"
:
function
(
transition
)
{
var
id
=
transition
.
id
;
assert
.
isTrue
(
id
>
0
);
assert
.
equal
(
~~
id
,
id
);
"
on a new transition
"
:
{
topic
:
function
(
d3
)
{
return
d3
.
select
(
"
body
"
).
append
(
"
div
"
).
transition
();
},
"
has a positive integer id
"
:
function
(
transition
)
{
var
id
=
transition
.
id
;
assert
.
isTrue
(
id
>
0
);
assert
.
equal
(
~~
id
,
id
);
}
},
"
increases monotonically across transitions
"
:
function
(
transition
)
{
var
t0
=
d3
.
select
(
"
body
"
).
append
(
"
div
"
).
transition
(),
...
...
test/transition/transition-test-remove.js
View file @
a4fed02b
require
(
"
../env
"
);
var
assert
=
require
(
"
../assert
"
);
module
.
exports
=
{
topic
:
function
()
{
var
cb
=
this
.
callback
,
t
=
d3
.
select
(
"
body
"
).
append
(
"
div
"
).
transition
().
remove
();
t
.
each
(
"
end
"
,
function
()
{
cb
(
null
,
t
);
});
},
"
removes the selected elements
"
:
function
(
transition
)
{
assert
.
domEqual
(
transition
[
0
][
0
].
parentNode
,
null
);
"
on a new transition
"
:
{
topic
:
function
(
d3
)
{
var
cb
=
this
.
callback
,
t
=
d3
.
select
(
"
body
"
).
append
(
"
div
"
).
transition
().
remove
();
t
.
each
(
"
end
"
,
function
()
{
cb
(
null
,
t
);
});
},
"
removes the selected elements
"
:
function
(
transition
)
{
assert
.
domEqual
(
transition
[
0
][
0
].
parentNode
,
null
);
}
},
"
when the element is already removed
"
:
{
topic
:
function
()
{
topic
:
function
(
d3
)
{
var
cb
=
this
.
callback
,
t
=
d3
.
select
(
"
body
"
).
append
(
"
div
"
).
remove
().
transition
().
remove
();
t
.
each
(
"
end
"
,
function
()
{
cb
(
null
,
t
);
});
...
...
@@ -30,7 +30,7 @@ module.exports = {
// time, the last transition becomes the owner.
"
when another transition is scheduled
"
:
{
topic
:
function
()
{
topic
:
function
(
d3
)
{
var
cb
=
this
.
callback
,
s
=
d3
.
select
(
"
body
"
).
append
(
"
div
"
);
setTimeout
(
function
()
{
...
...
@@ -39,7 +39,7 @@ module.exports = {
},
10
);
},
"
does nothing
"
:
function
(
selection
)
{
assert
.
domE
qual
(
selection
[
0
][
0
].
parentNode
,
document
.
body
);
assert
.
e
qual
(
selection
[
0
][
0
].
parentNode
.
tagName
,
"
BODY
"
);
}
}
};
test/transition/transition-test-select.js
View file @
a4fed02b
require
(
"
../env
"
);
var
assert
=
require
(
"
../assert
"
);
module
.
exports
=
{
topic
:
function
()
{
topic
:
function
(
d3
)
{
var
s
=
d3
.
select
(
"
body
"
).
append
(
"
div
"
).
selectAll
(
"
div
"
)
.
data
([
"
one
"
,
"
two
"
,
"
three
"
,
"
four
"
])
.
enter
().
append
(
"
div
"
)
...
...
test/transition/transition-test-selectAll.js
View file @
a4fed02b
require
(
"
../env
"
);
var
assert
=
require
(
"
../assert
"
);
module
.
exports
=
{
topic
:
function
()
{
topic
:
function
(
d3
)
{
var
s
=
d3
.
select
(
"
body
"
).
append
(
"
div
"
).
selectAll
(
"
div
"
)
.
data
([
"
one
"
,
"
two
"
,
"
three
"
,
"
four
"
])
.
enter
().
append
(
"
div
"
)
...
...
@@ -51,8 +49,8 @@ module.exports = {
assert
.
equal
(
t0
.
id
,
id
);
assert
.
equal
(
t1
.
id
,
id
);
},
"
groups are not instances of NodeList
"
:
function
(
transition
)
{
"
groups are
arrays,
not instances of NodeList
"
:
function
(
transition
)
{
var
t
=
transition
.
selectAll
(
function
()
{
return
this
.
getElementsByClassName
(
"
span
"
);
});
assert
.
is
False
(
t
[
0
]
instanceof
window
.
NodeList
);
assert
.
is
True
(
Array
.
isArray
(
t
[
0
])
);
}
};
test/transition/transition-test-style.js
View file @
a4fed02b
require
(
"
../env
"
);
var
assert
=
require
(
"
../assert
"
);
module
.
exports
=
{
topic
:
function
()
{
topic
:
function
(
d3
)
{
var
s
=
d3
.
select
(
"
body
"
).
append
(
"
div
"
)
.
style
(
"
background-color
"
,
"
white
"
)
.
style
(
"
color
"
,
"
red
"
)
...
...
test/transition/transition-test-styleTween.js
View file @
a4fed02b
require
(
"
../env
"
);
var
assert
=
require
(
"
../assert
"
);
var
assert
=
require
(
"
../assert
"
),
interpolateHsl
=
require
(
"
../../
"
).
interpolateHsl
;
module
.
exports
=
{
topic
:
function
()
{
topic
:
function
(
d3
)
{
var
cb
=
this
.
callback
,
dd
=
[],
ii
=
[],
...
...
@@ -33,7 +32,7 @@ module.exports = {
context
:
tt
,
fails
:
fails
});
return
i
&&
d3
.
interpolateHsl
(
v
,
"
blue
"
);
return
i
&&
interpolateHsl
(
v
,
"
blue
"
);
}
},
...
...
test/transition/transition-test-text.js
View file @
a4fed02b
require
(
"
../env
"
);
var
assert
=
require
(
"
../assert
"
);
module
.
exports
=
{
topic
:
function
()
{
topic
:
function
(
d3
)
{
return
d3
.
select
(
"
body
"
).
append
(
"
div
"
).
text
(
"
foo
"
).
transition
().
text
(
"
bar
"
);
},
"
sets the text tween
"
:
function
(
div
)
{
...
...
test/transition/transition-test-time.js
View file @
a4fed02b
require
(
"
../env
"
);
var
assert
=
require
(
"
../assert
"
);
module
.
exports
=
{
topic
:
function
()
{
return
d3
.
select
(
"
body
"
).
append
(
"
div
"
).
transition
();
},
"
is approximately equal to now
"
:
function
(
transition
)
{
var
time
=
transition
[
0
][
0
].
__transition__
[
transition
.
id
].
time
;
assert
.
inDelta
(
time
,
Date
.
now
(),
20
);
"
on a new transition
"
:
{
topic
:
function
(
d3
)
{
return
d3
.
select
(
"
body
"
).
append
(
"
div
"
).
transition
();
},
"
is approximately equal to now
"
:
function
(
transition
)
{
var
time
=
transition
[
0
][
0
].
__transition__
[
transition
.
id
].
time
;
assert
.
inDelta
(
time
,
Date
.
now
(),
20
);
}
},
"
increases monotonically across transitions
"
:
function
(
transition
)
{
"
increases monotonically across transitions
"
:
function
(
d3
)
{
var
now
=
Date
.
now
,
then
=
Date
.
now
();
try
{
Date
.
now
=
function
()
{
return
++
then
;
};
...
...
@@ -21,7 +21,7 @@ module.exports = {
Date
.
now
=
now
;
}
},
"
is inherited by subtransitions
"
:
function
(
transition
)
{
"
is inherited by subtransitions
"
:
function
(
d3
)
{
var
now
=
Date
.
now
,
then
=
Date
.
now
();
try
{
Date
.
now
=
function
()
{
return
++
then
;
};
...
...
test/transition/transition-test-transition.js
View file @
a4fed02b
require
(
"
../env
"
);
var
assert
=
require
(
"
../assert
"
);
module
.
exports
=
{
topic
:
function
()
{
topic
:
function
(
d3
)
{
return
d3
.
select
(
"
body
"
).
append
(
"
div
"
).
transition
()
.
delay
(
101
)
.
duration
(
152
)
...
...
@@ -28,13 +26,14 @@ module.exports = {
"
while transitioning
"
:
{
topic
:
function
(
t1
)
{
var
t2
=
t1
.
transition
(),
cb
=
this
.
callback
;
t2
.
each
(
"
start
"
,
function
()
{
d3
.
timer
(
function
()
{
cb
(
null
,
t2
);
return
true
;
});
var
callback
=
this
.
callback
;
var
t2
=
t1
.
transition
().
tween
(
"
custom
"
,
function
()
{
return
function
(
t
)
{
if
(
callback
)
{
callback
(
null
,
t2
);
callback
=
null
;
}
};
});
},
"
increments the lock's reference count
"
:
function
(
t2
)
{
...
...
@@ -47,7 +46,7 @@ module.exports = {
var
cb
=
this
.
callback
;
var
t2
=
t1
.
transition
();
t2
.
each
(
"
end
"
,
function
()
{
d3
.
timer
(
function
()
{
setTimeout
(
function
()
{
cb
(
null
,
t2
);
return
true
;
},
50
);
...
...
test/transition/transition-test-tween.js
View file @
a4fed02b
require
(
"
../env
"
);
var
assert
=
require
(
"
../assert
"
);
module
.
exports
=
{
topic
:
function
()
{
topic
:
function
(
d3
)
{
var
cb
=
this
.
callback
,
dd
=
[],
ii
=
[],
...
...
Prev
1
2
Next
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment