From 80256a6042278b64e73091dce9cb3120f6f4e06b Mon Sep 17 00:00:00 2001 From: "DESKTOP-I3JPKHK\\wy" <1111> Date: Fri, 18 Apr 2025 14:40:30 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E6=88=90=E4=BA=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/question_paper_view.dart | 39 ++++++++++--------- .../configuration_files/zoom_logic.dart | 9 +++++ 2 files changed, 29 insertions(+), 19 deletions(-) diff --git a/making_school_asignment_app/lib/page/home_page/children/homework_review/components/question_paper_view.dart b/making_school_asignment_app/lib/page/home_page/children/homework_review/components/question_paper_view.dart index ed29b06..d576c7d 100644 --- a/making_school_asignment_app/lib/page/home_page/children/homework_review/components/question_paper_view.dart +++ b/making_school_asignment_app/lib/page/home_page/children/homework_review/components/question_paper_view.dart @@ -417,37 +417,38 @@ class QuestionImageView extends HookWidget with EventBusMixin zoomState.zoomFile.value!.imageHeightOffsetend!) return; // 检查笔记是否超出图片范围 + print(zoomFile.getZoomFileHeightOffsetEnd(zoomState.initScale.value ?? 1)); + if (dy < imageHeightOffsetStart || dy > zoomFile.getZoomFileHeightOffsetEnd(zoomState.initScale.value ?? 1)) return; // 检查笔记是否超出图片范围 + + var theScale = zoomState.initScale.value ?? 1; + // if (theScale != 1) { + // print("PPPPPPPPPPPPPPPPPPPPPPPP ${(zoomFile.imageHeightOffsetStart ?? 0)}"); + // localPosition = Offset(localPosition.dx, localPosition.dy + (zoomFile.imageHeightOffsetStart ?? 0)); + + // // localPosition = Offset(localPosition.dx / theScale, localPosition.dy / theScale); + // // var theZoomOffset = sateData.zoomOffset; + // // if (theZoomOffset != null) { + // // var dx = theZoomOffset.dx; + // // var dy = theZoomOffset.dy; + // // localPosition = Offset(localPosition.dx + dx, localPosition.dy + dy); + // // } + // } // 说明:“- imageHeightOffsetStart” 由于显示笔记的位置是以图片的位置开始,手势坐标是以左上角开始 所以需要减去上面空白位置 - print("向上距离:$imageHeightOffsetStart"); - localPosition = Offset(localPosition.dx, localPosition.dy - imageHeightOffsetStart); - - // var theScale = sateData.initScale.value ?? 1; - - // print("}}}}}}}}}}}}}}}}}}}}}}}}}}}}}} $theScale"); - - // /// 缩放后的基数 - // if (theScale != 1) { - // print("PPPPPPPPPPPPPPPPPPPPPPPP"); - // localPosition = Offset(localPosition.dx / theScale, localPosition.dy / theScale); - // var theZoomOffset = sateData.zoomOffset; - // if (theZoomOffset != null) { - // var dx = theZoomOffset.dx; - // var dy = theZoomOffset.dy; - // localPosition = Offset(localPosition.dx + dx, localPosition.dy + dy); - // } + // if (theScale == 1) { // } + localPosition = Offset((localPosition.dx+(sateData.zoomOffset?.dx.abs()??0)) / theScale, (dy / theScale) - (imageHeightOffsetStart/ theScale)); print("最终位置 : $localPosition"); vnHandWritings.value = List.from(vnHandWritings.value)..add(localPosition); sateData.handwritings = vnHandWritings.value; - print(sateData.handwritings); }, child: Obx(() { var isPen = annotationState.pen.value; diff --git a/making_school_asignment_app/lib/page/home_page/children/homework_review/configuration_files/zoom_logic.dart b/making_school_asignment_app/lib/page/home_page/children/homework_review/configuration_files/zoom_logic.dart index 76d6dcb..ac4a40f 100644 --- a/making_school_asignment_app/lib/page/home_page/children/homework_review/configuration_files/zoom_logic.dart +++ b/making_school_asignment_app/lib/page/home_page/children/homework_review/configuration_files/zoom_logic.dart @@ -189,6 +189,15 @@ class ZoomFileModel extends Object { if (zoom == 1 || actualHeight == null) return imageHeightOffsetStart ?? 0; return (viewHeight - (actualHeight! * zoom)) / 2; } + + /// 获取缩放比例后的底部图片位置 + /// zoom 缩放比例 + double getZoomFileHeightOffsetEnd(double zoom) { + if (zoom == 1 || actualHeight == null) return imageHeightOffsetend ?? 0; + var topSpaceDimensions = getZoomFileOffsetStart(zoom); + return topSpaceDimensions + (actualHeight! * zoom); + } + } // 最终版