Comparing version 3.2.2 to 3.2.3
{ | ||
"name": "vue-pdf", | ||
"version": "3.2.2", | ||
"version": "3.2.3", | ||
"description": "vue.js pdf viewer", | ||
@@ -5,0 +5,0 @@ "main": "src/vuePdfNoSss.vue", |
@@ -16,10 +16,8 @@ import resizeSensor from 'vue-resize-sensor' | ||
}, [ | ||
h('canvas', { | ||
style: { | ||
display: 'block', | ||
width: '100%', | ||
}, | ||
ref:'canvas' | ||
}), | ||
h('div', { | ||
ref: 'canvasParent' | ||
}, [ | ||
]), | ||
h('div', { | ||
class: 'annotationLayer', | ||
@@ -62,3 +60,2 @@ ref:'annotationLayer' | ||
rotate: function() { | ||
this.pdf.renderPage(this.rotate); | ||
@@ -75,4 +72,3 @@ }, | ||
// on IE10- canvas height must be set | ||
this.$refs.canvas.style.height = this.$refs.canvas.offsetWidth * (this.$refs.canvas.height / this.$refs.canvas.width) + 'px'; | ||
this.pdf.setCanvasHeight(this.pdf.getCanvas().offsetWidth * (this.pdf.getCanvas().height / this.pdf.getCanvas().width) + 'px'); | ||
// update the page when the resolution is too poor | ||
@@ -82,3 +78,6 @@ var resolutionScale = this.pdf.getResolutionScale(); | ||
if ( resolutionScale < 0.85 || resolutionScale > 1.15 ) | ||
{ | ||
this.pdf.renderPage(this.rotate); | ||
} | ||
@@ -96,3 +95,3 @@ this.$refs.annotationLayer.style.transform = 'scale('+resolutionScale+')'; | ||
this.pdf = new PDFJSWrapper(this.$refs.canvas, this.$refs.annotationLayer, this.$emit.bind(this)); | ||
this.pdf = new PDFJSWrapper(this.$refs.canvasParent, this.$refs.annotationLayer, this.$emit.bind(this)); | ||
@@ -105,4 +104,3 @@ this.$on('loaded', function() { | ||
this.$on('page-size', function(width, height) { | ||
this.$refs.canvas.style.height = this.$refs.canvas.offsetWidth * (height / width) + 'px'; | ||
this.pdf.setCanvasHeight(this.pdf.getCanvas().offsetWidth * (height / width) + 'px'); | ||
}); | ||
@@ -109,0 +107,0 @@ |
@@ -51,3 +51,3 @@ import { CMapCompressionType } from 'pdfjs-dist/lib/shared/util'; | ||
function PDFJSWrapper(canvasElt, annotationLayerElt, emitEvent) { | ||
function PDFJSWrapper(canvasParent, annotationLayerElt, emitEvent) { | ||
@@ -58,2 +58,6 @@ var pdfDoc = null; | ||
var canceling = false; | ||
var canvasElt = document.createElement('canvas'); | ||
canvasElt.style.display = 'block'; | ||
canvasElt.style.width = '100%'; | ||
canvasParent.appendChild(canvasElt); | ||
@@ -78,2 +82,10 @@ function clearCanvas() { | ||
} | ||
this.setCanvasHeight = function(h) { | ||
canvasElt.style.height = h | ||
} | ||
this.getCanvas = function() { | ||
return canvasElt; | ||
} | ||
@@ -192,3 +204,2 @@ this.getResolutionScale = function() { | ||
this.renderPage = function(rotate) { | ||
if ( pdfRender !== null ) { | ||
@@ -214,2 +225,10 @@ | ||
canvasElt = canvasElt.cloneNode(true); | ||
const previousCanvas = canvasParent.firstChild; | ||
if (previousCanvas) { | ||
canvasParent.replaceChild(canvasElt, previousCanvas); | ||
} else { | ||
canvasParent.appendChild(canvasElt); | ||
} | ||
var scale = canvasElt.offsetWidth / pdfPage.getViewport(1).width * (window.devicePixelRatio || 1); | ||
@@ -246,3 +265,2 @@ var viewport = pdfPage.getViewport(scale, rotate); | ||
.then(function() { | ||
annotationLayerElt.style.visibility = ''; | ||
@@ -249,0 +267,0 @@ canceling = false; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
26666
497