Skip to content

Commit

Permalink
[pdf][thumbnails] Resize after move
Browse files Browse the repository at this point in the history
  • Loading branch information
KhromovNikita committed Feb 11, 2025
1 parent a2436fb commit caecd26
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 5 deletions.
3 changes: 3 additions & 0 deletions pdf/src/document.js
Original file line number Diff line number Diff line change
Expand Up @@ -2391,8 +2391,11 @@ var CPresentation = CPresentation || function(){};
for (let i = nStart; i <= nEnd; i++) {
oThumbnails._repaintPage(i);
}

oThumbnails.setNeedResize(true);
}

this.Viewer.resize(true);
this.Viewer.paint();
return true;
};
Expand Down
3 changes: 3 additions & 0 deletions pdf/src/history/documentChanges.js
Original file line number Diff line number Diff line change
Expand Up @@ -1125,7 +1125,10 @@ CChangesPDFDocumentMovePage.prototype.private_SetValue = function(nNewPos)
for (let i = nStart; i <= nEnd; i++) {
oThumbnails._repaintPage(i);
}

oThumbnails.setNeedResize(true);
}

oDoc.Viewer.resize(true);
oDoc.Viewer.paint();
};
21 changes: 16 additions & 5 deletions pdf/src/thumbnails.js
Original file line number Diff line number Diff line change
Expand Up @@ -618,7 +618,11 @@

// rendering
CDocument.prototype._paint= function() {
if (!this.canvas) return;
if (!this.canvas || !this.viewer.canInteract()) return;
if (this.isNeedResize()) {
this.resize();
}

let ctx= this.canvas.getContext("2d");
this.canvas.width= this.canvas.width;
ctx.fillStyle= ThumbnailsStyle.backgroundColor;
Expand Down Expand Up @@ -654,6 +658,12 @@
this.resize();
};

CDocument.prototype.setNeedResize = function(bResize) {
this.needResize = bResize;
};
CDocument.prototype.isNeedResize = function() {
return !!this.needResize;
};
CDocument.prototype._resize = function(isZoomUpdated)
{
var element = document.getElementById(this.id);
Expand Down Expand Up @@ -769,6 +779,7 @@

this.documentHeight = blockTop;

this.setNeedResize(false);
this.updateScroll(scrollV);
this.calculateVisibleBlocks();
this.repaint();
Expand Down Expand Up @@ -1153,8 +1164,11 @@
this.dragCanvas.height = h + 15;
this.dragCanvas.style.display = "block";

// Set opacity
this.dragCanvas.style.opacity = 0.95;

// Clear the canvas
this.dragCtx.clearRect(0, 0, w, h);
this.dragCtx.clearRect(0, 0, this.dragCanvas.width, this.dragCanvas.height);

// If a stack of pages needs to be created
if (countPages && countPages > 1) {
Expand Down Expand Up @@ -1185,9 +1199,6 @@
}
this.dragCtx.strokeRect(0, 0, w, h);

// Set opacity
this.dragCanvas.style.opacity = 0.95;

// If more than one page is being dragged, display text with the number of pages
if (countPages && countPages > 1) {
let text = countPages + " pages";
Expand Down

0 comments on commit caecd26

Please sign in to comment.