fix(Viewer): trigger resized on attach
Ensure components get notified on `canvas.resized`, whenever the Viewer instance gets attached.
This commit is contained in:
parent
029c3d76aa
commit
50da47e1e1
|
@ -379,6 +379,8 @@ Viewer.prototype.attachTo = function(parentNode) {
|
|||
parentNode.appendChild(this._container);
|
||||
|
||||
this._emit('attach', {});
|
||||
|
||||
this.get('canvas').resized();
|
||||
};
|
||||
|
||||
Viewer.prototype.getDefinitions = function() {
|
||||
|
|
|
@ -962,12 +962,20 @@ describe('Viewer', function() {
|
|||
// assume
|
||||
expect(viewer._container.parentNode).not.to.exist;
|
||||
|
||||
/* global sinon */
|
||||
var resizedSpy = sinon.spy();
|
||||
|
||||
viewer.on('canvas.resized', resizedSpy);
|
||||
|
||||
// when
|
||||
viewer.attachTo(container);
|
||||
|
||||
// then
|
||||
expect(viewer._container.parentNode).to.equal(container);
|
||||
|
||||
// should trigger resized
|
||||
expect(resizedSpy).to.have.been.called;
|
||||
|
||||
done(err, warnings);
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue