mirror of
https://github.com/venera-app/venera.git
synced 2025-09-27 07:47:24 +00:00
add more js api & improve ui
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
part of 'components.dart';
|
||||
|
||||
class SmoothCustomScrollView extends StatelessWidget {
|
||||
const SmoothCustomScrollView({super.key, required this.slivers, this.controller});
|
||||
const SmoothCustomScrollView(
|
||||
{super.key, required this.slivers, this.controller});
|
||||
|
||||
final ScrollController? controller;
|
||||
|
||||
@@ -22,9 +23,9 @@ class SmoothCustomScrollView extends StatelessWidget {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class SmoothScrollProvider extends StatefulWidget {
|
||||
const SmoothScrollProvider({super.key, this.controller, required this.builder});
|
||||
const SmoothScrollProvider(
|
||||
{super.key, this.controller, required this.builder});
|
||||
|
||||
final ScrollController? controller;
|
||||
|
||||
@@ -51,7 +52,7 @@ class _SmoothScrollProviderState extends State<SmoothScrollProvider> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if(App.isMacOS) {
|
||||
if (App.isMacOS) {
|
||||
return widget.builder(
|
||||
context,
|
||||
_controller,
|
||||
@@ -77,13 +78,15 @@ class _SmoothScrollProviderState extends State<SmoothScrollProvider> {
|
||||
}
|
||||
if (!_isMouseScroll) return;
|
||||
var currentLocation = _controller.position.pixels;
|
||||
var old = _futurePosition;
|
||||
_futurePosition ??= currentLocation;
|
||||
double k = (_futurePosition! - currentLocation).abs() / 1600 + 1;
|
||||
_futurePosition =
|
||||
_futurePosition! + pointerSignal.scrollDelta.dy * k;
|
||||
_futurePosition = _futurePosition! + pointerSignal.scrollDelta.dy * k;
|
||||
_futurePosition = _futurePosition!.clamp(
|
||||
_controller.position.minScrollExtent,
|
||||
_controller.position.maxScrollExtent);
|
||||
_controller.position.minScrollExtent,
|
||||
_controller.position.maxScrollExtent,
|
||||
);
|
||||
if(_futurePosition == old) return;
|
||||
_controller.animateTo(_futurePosition!,
|
||||
duration: _fastAnimationDuration, curve: Curves.linear);
|
||||
}
|
||||
|
Reference in New Issue
Block a user