fix: scroll alignment in remote page
This commit is contained in:
parent
672d5f31d0
commit
4b72b57428
@ -286,30 +286,35 @@ class ImagePaint extends StatelessWidget {
|
|||||||
child: child));
|
child: child));
|
||||||
|
|
||||||
if (c.scrollStyle == ScrollStyle.scrollbar) {
|
if (c.scrollStyle == ScrollStyle.scrollbar) {
|
||||||
|
final imageWidth = c.getDisplayWidth() * s;
|
||||||
|
final imageHeight = c.getDisplayHeight() * s;
|
||||||
final imageWidget = SizedBox(
|
final imageWidget = SizedBox(
|
||||||
width: c.getDisplayWidth() * s,
|
width: imageWidth,
|
||||||
height: c.getDisplayHeight() * s,
|
height: imageHeight,
|
||||||
child: CustomPaint(
|
child: CustomPaint(
|
||||||
painter: ImagePainter(image: m.image, x: 0, y: 0, scale: s),
|
painter: ImagePainter(image: m.image, x: 0, y: 0, scale: s),
|
||||||
));
|
));
|
||||||
|
|
||||||
return Center(
|
return NotificationListener<ScrollNotification>(
|
||||||
child: NotificationListener<ScrollNotification>(
|
|
||||||
onNotification: (notification) {
|
onNotification: (notification) {
|
||||||
final percentX = _horizontal.position.extentBefore /
|
final percentX = _horizontal.hasClients
|
||||||
|
? _horizontal.position.extentBefore /
|
||||||
(_horizontal.position.extentBefore +
|
(_horizontal.position.extentBefore +
|
||||||
_horizontal.position.extentInside +
|
_horizontal.position.extentInside +
|
||||||
_horizontal.position.extentAfter);
|
_horizontal.position.extentAfter)
|
||||||
final percentY = _vertical.position.extentBefore /
|
: 0.0;
|
||||||
|
final percentY = _vertical.hasClients
|
||||||
|
? _vertical.position.extentBefore /
|
||||||
(_vertical.position.extentBefore +
|
(_vertical.position.extentBefore +
|
||||||
_vertical.position.extentInside +
|
_vertical.position.extentInside +
|
||||||
_vertical.position.extentAfter);
|
_vertical.position.extentAfter)
|
||||||
|
: 0.0;
|
||||||
c.setScrollPercent(percentX, percentY);
|
c.setScrollPercent(percentX, percentY);
|
||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
child: mouseRegion(
|
child: mouseRegion(
|
||||||
child: _buildCrossScrollbar(_buildListener(imageWidget))),
|
child: _buildCrossScrollbar(context, _buildListener(imageWidget),
|
||||||
),
|
Size(imageWidth, imageHeight))),
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
final imageWidget = SizedBox(
|
final imageWidget = SizedBox(
|
||||||
@ -342,44 +347,96 @@ class ImagePaint extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildCrossScrollbar(Widget child) {
|
Widget _buildCrossScrollbarFromLayout(
|
||||||
|
BuildContext context, Widget child, Size layoutSize, Size size) {
|
||||||
final scrollConfig = CustomMouseWheelScrollConfig(
|
final scrollConfig = CustomMouseWheelScrollConfig(
|
||||||
scrollDuration: kDefaultScrollDuration,
|
scrollDuration: kDefaultScrollDuration,
|
||||||
scrollCurve: Curves.linearToEaseOut,
|
scrollCurve: Curves.linearToEaseOut,
|
||||||
mouseWheelTurnsThrottleTimeMs:
|
mouseWheelTurnsThrottleTimeMs:
|
||||||
kDefaultMouseWheelThrottleDuration.inMilliseconds,
|
kDefaultMouseWheelThrottleDuration.inMilliseconds,
|
||||||
scrollAmountMultiplier: kDefaultScrollAmountMultiplier);
|
scrollAmountMultiplier: kDefaultScrollAmountMultiplier);
|
||||||
return Obx(() => ImprovedScrolling(
|
var widget = child;
|
||||||
scrollController: _vertical,
|
if (layoutSize.width < size.width) {
|
||||||
enableCustomMouseWheelScrolling: cursorOverImage.isFalse,
|
widget = ScrollConfiguration(
|
||||||
customMouseWheelScrollConfig: scrollConfig,
|
behavior: ScrollConfiguration.of(context).copyWith(scrollbars: false),
|
||||||
child: ImprovedScrolling(
|
|
||||||
scrollController: _horizontal,
|
|
||||||
enableCustomMouseWheelScrolling: cursorOverImage.isFalse,
|
|
||||||
customMouseWheelScrollConfig: scrollConfig,
|
|
||||||
child: Scrollbar(
|
|
||||||
controller: _vertical,
|
|
||||||
thumbVisibility: false,
|
|
||||||
trackVisibility: false,
|
|
||||||
child: Scrollbar(
|
|
||||||
controller: _horizontal,
|
|
||||||
thumbVisibility: false,
|
|
||||||
trackVisibility: false,
|
|
||||||
notificationPredicate: (notif) => notif.depth == 1,
|
|
||||||
child: SingleChildScrollView(
|
|
||||||
controller: _vertical,
|
|
||||||
physics: cursorOverImage.isTrue
|
|
||||||
? const NeverScrollableScrollPhysics()
|
|
||||||
: null,
|
|
||||||
child: SingleChildScrollView(
|
child: SingleChildScrollView(
|
||||||
controller: _horizontal,
|
controller: _horizontal,
|
||||||
scrollDirection: Axis.horizontal,
|
scrollDirection: Axis.horizontal,
|
||||||
physics: cursorOverImage.isTrue
|
physics: cursorOverImage.isTrue
|
||||||
? const NeverScrollableScrollPhysics()
|
? const NeverScrollableScrollPhysics()
|
||||||
: null,
|
: null,
|
||||||
child: child,
|
child: widget,
|
||||||
),
|
),
|
||||||
))))));
|
);
|
||||||
|
} else {
|
||||||
|
widget = Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
children: [widget],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (layoutSize.height < size.height) {
|
||||||
|
widget = ScrollConfiguration(
|
||||||
|
behavior: ScrollConfiguration.of(context).copyWith(scrollbars: false),
|
||||||
|
child: SingleChildScrollView(
|
||||||
|
controller: _vertical,
|
||||||
|
physics: cursorOverImage.isTrue
|
||||||
|
? const NeverScrollableScrollPhysics()
|
||||||
|
: null,
|
||||||
|
child: widget,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
widget = Column(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
children: [widget],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (layoutSize.width < size.width) {
|
||||||
|
widget = ImprovedScrolling(
|
||||||
|
scrollController: _horizontal,
|
||||||
|
enableCustomMouseWheelScrolling: cursorOverImage.isFalse,
|
||||||
|
customMouseWheelScrollConfig: scrollConfig,
|
||||||
|
child: RawScrollbar(
|
||||||
|
thumbColor: Colors.grey,
|
||||||
|
controller: _horizontal,
|
||||||
|
thumbVisibility: false,
|
||||||
|
trackVisibility: false,
|
||||||
|
notificationPredicate: (notification) => notification.depth == 1,
|
||||||
|
child: widget,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (layoutSize.height < size.height) {
|
||||||
|
widget = ImprovedScrolling(
|
||||||
|
scrollController: _vertical,
|
||||||
|
enableCustomMouseWheelScrolling: cursorOverImage.isFalse,
|
||||||
|
customMouseWheelScrollConfig: scrollConfig,
|
||||||
|
child: RawScrollbar(
|
||||||
|
thumbColor: Colors.grey,
|
||||||
|
controller: _vertical,
|
||||||
|
thumbVisibility: false,
|
||||||
|
trackVisibility: false,
|
||||||
|
child: widget,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return widget;
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildCrossScrollbar(BuildContext context, Widget child, Size size) {
|
||||||
|
var layoutSize = MediaQuery.of(context).size;
|
||||||
|
layoutSize = Size(
|
||||||
|
layoutSize.width - kWindowBorderWidth * 2,
|
||||||
|
layoutSize.height -
|
||||||
|
kWindowBorderWidth * 2 -
|
||||||
|
kDesktopRemoteTabBarHeight);
|
||||||
|
bool overflow =
|
||||||
|
layoutSize.width < size.width || layoutSize.height < size.height;
|
||||||
|
return overflow
|
||||||
|
? Obx(() =>
|
||||||
|
_buildCrossScrollbarFromLayout(context, child, layoutSize, size))
|
||||||
|
: _buildCrossScrollbarFromLayout(context, child, layoutSize, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildListener(Widget child) {
|
Widget _buildListener(Widget child) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user