@vaadin-component-factory/vcf-pdf-viewer 1.0.1 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,8 +1,6 @@
1
1
  import { PolymerElement, html } from '@polymer/polymer/polymer-element';
2
2
  import { ThemableMixin } from '@vaadin/vaadin-themable-mixin';
3
3
  import { ElementMixin } from '@vaadin/component-base/src/element-mixin.js';
4
- import { IronResizableBehavior } from '@polymer/iron-resizable-behavior';
5
- import { mixinBehaviors } from '@polymer/polymer/lib/legacy/class.js';
6
4
  import '@vaadin/polymer-legacy-adapter/template-renderer.js';
7
5
  import '@vaadin/text-field';
8
6
  import '@vaadin/select';
@@ -34,8 +32,7 @@ pdfjsLib.GlobalWorkerOptions.workerSrc = pdfjsWorker;
34
32
  */
35
33
  class PdfViewerElement extends
36
34
  ElementMixin(
37
- ThemableMixin(
38
- mixinBehaviors([IronResizableBehavior], PolymerElement))) {
35
+ ThemableMixin(PolymerElement)) {
39
36
 
40
37
  static get template() {
41
38
  return html`
@@ -469,8 +466,15 @@ class PdfViewerElement extends
469
466
  }
470
467
  });
471
468
 
472
- this.addEventListener('iron-resize', this.__recalculateSizes);
473
- this.__recalculateSizes();
469
+ this.__resizeObserver = new ResizeObserver(() => {
470
+ requestAnimationFrame(() => this.__recalculateSizes());
471
+ });
472
+ this.__resizeObserver.observe(this);
473
+ }
474
+
475
+ connectedCallback() {
476
+ super.connectedCallback();
477
+ this.__recalculateSizes();
474
478
  }
475
479
 
476
480
  __updateCurrentPageValue(pageNumber){
@@ -513,7 +517,7 @@ class PdfViewerElement extends
513
517
  return;
514
518
  }
515
519
  this.__setFilename(src);
516
- this.__document = pdfjsLib.getDocument(src);
520
+ this.__document = pdfjsLib.getDocument(new URL(src, document.baseURI).href);
517
521
  return this.__document.promise.then((pdfDocument) => {
518
522
  // Document loaded, specifying document for the viewer.
519
523
  this.__thumbnailViewer.setDocument(pdfDocument);