完成了
This commit is contained in:
parent
e239ad8710
commit
80256a6042
|
|
@ -417,37 +417,38 @@ class QuestionImageView extends HookWidget with EventBusMixin<BottomOperationBar
|
|||
if (!annotationState.pen.value) return;
|
||||
|
||||
Offset localPosition = event.localPosition; // 相对
|
||||
var zoomFile = zoomState.zoomFile.value!;
|
||||
// var imageHeightOffsetStart = zoomFile.imageHeightOffsetStart??0;
|
||||
var imageHeightOffsetStart = zoomState.zoomFile.value!.getZoomFileOffsetStart(zoomState.initScale.value ?? 1);
|
||||
print("位置:$localPosition; 图片所在位置:$imageHeightOffsetStart");
|
||||
if (imageHeightOffsetStart == 0) return;
|
||||
|
||||
var dy = localPosition.dy;
|
||||
if (dy < imageHeightOffsetStart || dy > 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;
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// 最终版
|
||||
|
|
|
|||
Loading…
Reference in New Issue