Skip to content

Commit c137464

Browse files
committed
Add test for annotations actually moving
1 parent b20371c commit c137464

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

test/jasmine/tests/transition_test.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,34 @@ function runTests(transitionDuration) {
6565
}).catch(fail).then(done);
6666
});
6767

68+
it('transitions an annotation', function (done) {
69+
function annotationPosition () {
70+
var g = gd._fullLayout._infolayer.select('.annotation').select('.annotation-text-g');
71+
return [parseInt(g.attr('x')), parseInt(g.attr('y'))];
72+
}
73+
var p1, p2;
74+
75+
Plotly.relayout(gd, {annotations: [{x: 0, y: 0, text: 'test'}]}).then(function() {
76+
p1 = annotationPosition();
77+
78+
return Plots.transition(gd, null, {
79+
'annotations[0].x': 1,
80+
'annotations[0].y': 1
81+
}, [],
82+
{redraw: true, duration: transitionDuration},
83+
{duration: transitionDuration, easing: 'cubic-in-out'}
84+
);
85+
}).then(function () {
86+
p2 = annotationPosition();
87+
88+
// Ensure both coordinates have moved, i.e. that the annotation has transitioned:
89+
expect(p1[0]).not.toEqual(p2[0]);
90+
expect(p1[1]).not.toEqual(p2[1]);
91+
92+
}).catch(fail).then(done);
93+
94+
});
95+
6896
it('transitions a transform', function(done) {
6997
Plotly.restyle(gd, {
7098
'transforms[0]': {

0 commit comments

Comments
 (0)