Skip to content

Commit 30929dc

Browse files
committed
Test that shapes are updated by transitions
1 parent 03d19bc commit 30929dc

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

test/jasmine/tests/transition_test.js

+42
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,48 @@ function runTests(transitionDuration) {
127127
}).catch(fail).then(done);
128128
});
129129

130+
it('transitions a shape', function(done) {
131+
function getPath() {
132+
return gd._fullLayout._shapeUpperLayer.select('path').node();
133+
}
134+
var p1, p2, d1, d2;
135+
136+
Plotly.relayout(gd, {
137+
shapes: [{
138+
type: 'circle',
139+
xref: 'x',
140+
yref: 'y',
141+
x0: 0,
142+
y0: 0,
143+
x1: 2,
144+
y1: 2,
145+
opacity: 0.2,
146+
fillcolor: 'blue',
147+
line: {color: 'blue'}
148+
}]
149+
}).then(function() {
150+
p1 = getPath();
151+
d1 = p1.getAttribute('d');
152+
153+
return Plots.transition(gd, null, {
154+
'shapes[0].x0': 1,
155+
'shapes[0].y0': 1,
156+
}, [],
157+
{redraw: true, duration: transitionDuration},
158+
{duration: transitionDuration, easing: 'cubic-in-out'}
159+
);
160+
}).then(function() {
161+
p2 = getPath();
162+
d2 = p2.getAttribute('d');
163+
164+
// If object constancy is implemented, this will then be *equal*:
165+
expect(p1).not.toBe(p2);
166+
167+
expect(d1).not.toEqual(d2);
168+
}).catch(fail).then(done);
169+
});
170+
171+
130172
it('transitions a transform', function(done) {
131173
Plotly.restyle(gd, {
132174
'transforms[0]': {

0 commit comments

Comments
 (0)