fix pinch to zoom

This commit is contained in:
2024-12-26 10:55:31 +08:00
parent 1ae33c43b1
commit 99454041d3

View File

@@ -356,6 +356,7 @@ class _ContinuousModeState extends State<_ContinuousMode>
var isCTRLPressed = false; var isCTRLPressed = false;
static var _isMouseScrolling = false; static var _isMouseScrolling = false;
var fingers = 0; var fingers = 0;
bool disableScroll = false;
@override @override
void initState() { void initState() {
@@ -426,7 +427,7 @@ class _ContinuousModeState extends State<_ContinuousMode>
? Axis.vertical ? Axis.vertical
: Axis.horizontal, : Axis.horizontal,
reverse: reader.mode == ReaderMode.continuousRightToLeft, reverse: reader.mode == ReaderMode.continuousRightToLeft,
physics: isCTRLPressed || _isMouseScrolling physics: isCTRLPressed || _isMouseScrolling || disableScroll
? const NeverScrollableScrollPhysics() ? const NeverScrollableScrollPhysics()
: const ClampingScrollPhysics(), : const ClampingScrollPhysics(),
itemBuilder: (context, index) { itemBuilder: (context, index) {
@@ -460,6 +461,11 @@ class _ContinuousModeState extends State<_ContinuousMode>
widget = Listener( widget = Listener(
onPointerDown: (event) { onPointerDown: (event) {
fingers++; fingers++;
if(fingers > 1 && !disableScroll) {
setState(() {
disableScroll = true;
});
}
futurePosition = null; futurePosition = null;
if (_isMouseScrolling) { if (_isMouseScrolling) {
setState(() { setState(() {
@@ -469,6 +475,11 @@ class _ContinuousModeState extends State<_ContinuousMode>
}, },
onPointerUp: (event) { onPointerUp: (event) {
fingers--; fingers--;
if(fingers <= 1 && disableScroll) {
setState(() {
disableScroll = false;
});
}
}, },
onPointerPanZoomUpdate: (event) { onPointerPanZoomUpdate: (event) {
if (event.scale == 1.0) { if (event.scale == 1.0) {