Pinch zooming speed gets faster when page width gets smaller than view width
It seems that the animation for zooming in is scaling a lot in landscape mode - causing a small pinch to zoom a lot.
https://github.com/espresso3389/pdfrx/assets/156050023/33cb555f-09e1-4258-8fa9-82b5bc2f66c6
@espresso3389 Hey, can you fix this? Zoom is a little bit fast and/or not smooth.
Ah, zoom suddenly gets speed-up when the page width gets smaller than the screen width. It occurrs not only on landscape mode but also on portrait mode The sample's page 3 has the same issue...
I could not determine the mechanism behind the behavior so far.
Please prioritize the task and fix it as soon as possible.
Hi, is there any fixing or workaround? I have the same issue
Could you please share the fix?
Maybe the bug is the normalizeMatrix pre-settings. I set the bellow code and zoom gets smooth, but the viewer do not respect the document limits and the user can slide the pdf out of the viewer.
normalizeMatrix: (matrix, viewSize, layout, controller) => matrix,
@espresso3389 can you check this?
Maybe the bug is the normalizeMatrix pre-settings. I set the bellow code and zoom gets smooth, but the viewer do not respect the document limits and the user can slide the pdf out of the viewer.
normalizeMatrix: (matrix, viewSize, layout, controller) => matrix,@espresso3389 can you check this?
Actually I found out a great solution using the normalize example in documentation:
The problem is in the z axis of the third line in controller.calcMatrizFor method that always return 1.0.
I just change the result matrix with .scaled(1.0,1.0,newzoom).
// before [0] zoom, 0.0, 0.0, X axis [1] 0.0, zoom, 0.0, Y axis [2] 0.0, 0.0, 1.0, 0.0 [3] 0.0, 0.0, 0.0, 1.0
// after .scaled method [0] zoom, 0.0, 0.0, X axis [1] 0.0, zoom, 0.0, Y axis [2] 0.0, 0.0, zoom, 0.0 [3] 0.0, 0.0, 0.0, 1.0
// code // (do not forget to copy the extension on num [_RangeDouble] to use the range method.)
normalizeMatrix: (matrix, viewSize, layout, controller) {
// If the controller is not ready, just return the input matrix.
if (controller == null || !controller.isReady) return matrix;
final newValue = Matrix4.copy(matrix);
final position = newValue.calcPosition(viewSize);
final newZoom = controller.params.boundaryMargin != null
? newValue.zoom
: max(newValue.zoom, controller.minScale);
final hw = viewSize.width / 2 / newZoom;
final hh = viewSize.height / 2 / newZoom;
final x = position.dx.range(hw, layout.documentSize.width - hw);
final y =
position.dy.range(hh, layout.documentSize.height - hh);
return controller
.calcMatrixFor(Offset(x, y),
zoom: newZoom, viewSize: viewSize)
.scaled(1.0, 1.0, newZoom);
},
extension _RangeDouble<T extends num> on T {
/// Identical to [num.clamp] but it does nothing if [a] is larger or equal to [b].
T range(T a, T b) => a < b ? clamp(a, b) as T : (a + b) / 2 as T;
}
Very interesting. I'll check it later.
@espresso3389 please fix this asap
1.1.27 applies the proposed fix by @jeffpontocom but I' not sure if it works well or not. Personally, I don't feel any difference...
1.1.27 applies the proposed fix by @jeffpontocom but I' not sure if it works well or not. Personally, I don't feel any difference...
works great! thank you guys!