diff --git a/lib/Viewer.js b/lib/Viewer.js index 0c691e34..b342e68b 100644 --- a/lib/Viewer.js +++ b/lib/Viewer.js @@ -379,6 +379,8 @@ Viewer.prototype.attachTo = function(parentNode) { parentNode.appendChild(this._container); this._emit('attach', {}); + + this.get('canvas').resized(); }; Viewer.prototype.getDefinitions = function() { diff --git a/test/spec/ViewerSpec.js b/test/spec/ViewerSpec.js index 01dc9913..86a243df 100644 --- a/test/spec/ViewerSpec.js +++ b/test/spec/ViewerSpec.js @@ -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); }); });