Skip to content

Commit

Permalink
Correct way of solving the issue in dccac24
Browse files Browse the repository at this point in the history
  • Loading branch information
micromaomao committed Sep 15, 2018
1 parent 2b9e69d commit 09ff89e
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 20 deletions.
41 changes: 21 additions & 20 deletions view/paperviewer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -812,28 +812,30 @@ class PDFJSViewer extends React.Component {
if (Math.abs(sw - w) <= 1) w = sw
if (Math.abs(sh - h) <= 1) h = sh
ctx.drawImage(p.renderedCanvas, Math.round(sx), Math.round(sy), Math.round(sw), Math.round(sh), Math.round(x), Math.round(y), Math.round(w), Math.round(h))
if (p.textLayer) {
if (this.textLayers[i] != p.textLayer) {
if (!stage.currentAnimation && !stage.pressState) {
if (p.textLayer) {
if (this.textLayers[i] != p.textLayer) {
if (this.textLayers[i]) {
this.textLayers[i].remove()
}
this.textLayers[i] = p.textLayer
this.textLayersContain.appendChild(p.textLayer)
}
if (!stage.pressState && !stage.currentAnimation) {
let cssTScale = cssW / sw
Object.assign(this.textLayers[i].style, {
position: 'absolute',
left: cssX + 'px',
top: cssY + 'px',
transformOrigin: 'top left',
transform: 'scale(' + cssTScale + ')'
})
}
} else {
if (this.textLayers[i]) {
this.textLayers[i].remove()
this.textLayers[i] = null
}
this.textLayers[i] = p.textLayer
this.textLayersContain.appendChild(p.textLayer)
}
if (!stage.pressState && !stage.currentAnimation) {
let cssTScale = cssW / sw
Object.assign(this.textLayers[i].style, {
position: 'absolute',
left: cssX + 'px',
top: cssY + 'px',
transformOrigin: 'top left',
transform: 'scale(' + cssTScale + ')'
})
}
} else {
if (this.textLayers[i]) {
this.textLayers[i].remove()
this.textLayers[i] = null
}
}
}
Expand Down Expand Up @@ -865,7 +867,6 @@ class PDFJSViewer extends React.Component {
}

updatePages () {
let stage = this.stage
if (!this.pages) return
for (let p of this.pages) {
if (this.pageInView(p)) {
Expand Down
4 changes: 4 additions & 0 deletions view/transformationstage.js
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,7 @@ class TransformationStage {
let velocity = new TransformVelocity(this.pressState.lastTransforms)
velocity.applyInertia(this).then(() => {
if (this.onAfterUserInteration) {
new PendingTransform(this.translate, this.scale, this).boundInContentBox().startAnimation()
this.onAfterUserInteration()
}
})
Expand All @@ -320,6 +321,9 @@ class TransformationStage {
return finish()
} else if (evt.touches.length === 1) {
this.initMove(evt.touches[0])
if (this.onAfterUserInteration) {
this.onAfterUserInteration()
}
} else {
return finish()
}
Expand Down

0 comments on commit 09ff89e

Please sign in to comment.