Fix, cursor position, scall origin, scrollbar (#6612)

Signed-off-by: fufesou <shuanglongchen@yeah.net>
This commit is contained in:
fufesou
2023-12-04 22:35:14 +08:00
committed by GitHub
parent ebe044aee8
commit 3a82bddcd3
2 changed files with 51 additions and 27 deletions

View File

@@ -1205,6 +1205,9 @@ class CanvasModel with ChangeNotifier {
ScrollStyle _scrollStyle = ScrollStyle.scrollauto;
ViewStyle _lastViewStyle = ViewStyle.defaultViewStyle();
final ScrollController _horizontal = ScrollController();
final ScrollController _vertical = ScrollController();
final _imageOverflow = false.obs;
WeakReference<FFI> parent;
@@ -1229,6 +1232,8 @@ class CanvasModel with ChangeNotifier {
_scrollY = y;
}
ScrollController get scrollHorizontal => _horizontal;
ScrollController get scrollVertical => _vertical;
double get scrollX => _scrollX;
double get scrollY => _scrollY;
@@ -1289,6 +1294,7 @@ class CanvasModel with ChangeNotifier {
if (refreshMousePos) {
parent.target?.inputModel.refreshMousePos();
}
updateScrollPercent();
}
updateScrollStyle() async {
@@ -1424,6 +1430,22 @@ class CanvasModel with ChangeNotifier {
_scale = 1.0;
if (notify) notifyListeners();
}
updateScrollPercent() {
final percentX = _horizontal.hasClients
? _horizontal.position.extentBefore /
(_horizontal.position.extentBefore +
_horizontal.position.extentInside +
_horizontal.position.extentAfter)
: 0.0;
final percentY = _vertical.hasClients
? _vertical.position.extentBefore /
(_vertical.position.extentBefore +
_vertical.position.extentInside +
_vertical.position.extentAfter)
: 0.0;
setScrollPercent(percentX, percentY);
}
}
// data for cursor