Merge pull request #1676 from dmcalpin/master

allow reference strip to work in a web component
This commit is contained in:
Ian Gilman 2019-07-22 14:48:52 -07:00 committed by GitHub
commit 704ac9bae4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 31 additions and 1 deletions

View File

@ -236,7 +236,7 @@ $.extend( $.ReferenceStrip.prototype, $.EventSource.prototype, $.Viewer.prototyp
* @function * @function
*/ */
setFocus: function ( page ) { setFocus: function ( page ) {
var element = $.getElement( this.element.id + '-' + page ), var element = this.element.querySelector('#' + this.element.id + '-' + page ),
viewerSize = $.getElementSize( this.viewer.canvas ), viewerSize = $.getElementSize( this.viewer.canvas ),
scrollWidth = Number( this.element.style.width.replace( 'px', '' ) ), scrollWidth = Number( this.element.style.width.replace( 'px', '' ) ),
scrollHeight = Number( this.element.style.height.replace( 'px', '' ) ), scrollHeight = Number( this.element.style.height.replace( 'px', '' ) ),

View File

@ -44,4 +44,34 @@
done(); done();
}); });
// ----------
QUnit.test('shadow dom', function(assert) {
if (document.head && document.head.attachShadow) {
var done = assert.async();
var shadowDiv = document.createElement('div');
shadowDiv.attachShadow({
mode: 'open'
});
shadowDiv.shadowRoot.innerHTML = `<div id="shadow-example"></div>`
createViewer({
element: shadowDiv.shadowRoot.querySelector('#shadow-example'),
sequenceMode: true,
showReferenceStrip: true,
tileSources: [
'/test/data/tall.dzi',
'/test/data/wide.dzi'
]
});
$(shadowDiv).appendTo("#qunit-fixture");
assert.ok(viewer.referenceStrip, 'referenceStrip exists');
done();
} else {
assert.expect(0);
}
})
})(); })();