Skip to content

Commit

Permalink
feat: manually linked scrolling for touchpad scrolls
Browse files Browse the repository at this point in the history
  • Loading branch information
squidrye committed Oct 10, 2023
1 parent de3df1f commit e93618a
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 46 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -348,13 +348,14 @@ class _HomeBodyState extends State<HomeBody> {
onPointerPanZoomEnd: (event) {
_timer?.cancel();

_timer = Timer(const Duration(milliseconds: 500), () {
_timer = Timer(const Duration(milliseconds: 600), () {
absorbTapsNotifier.value = true;
_timer?.cancel();
});
},
onPointerPanZoomStart: (event) {
absorbTapsNotifier.value = false;
_timer?.cancel();
},
onPointerSignal: (signal) {
if (signal is PointerScrollEvent) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,55 +52,58 @@ class _FlowyPaneState extends State<FlowyPane> {
child: SingleChildScrollView(
controller: verticalController,
scrollDirection: Axis.vertical,
child: SingleChildScrollView(
controller: horizontalController,
scrollDirection: Axis.horizontal,
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
children: [
DraggablePaneItem(
size: widget.size,
paneContext: widget.paneContext,
pane: CrossDraggablesEntity(draggable: widget.node),
feedback: (context) =>
widget.node.tabs.currentPageManager.title(),
child: Column(
children: [
Padding(
padding: EdgeInsets.only(
left: widget.layout.menuSpacing,
child: NotificationListener<ScrollNotification>(
onNotification: _proportionalScroll,
child: SingleChildScrollView(
controller: horizontalController,
scrollDirection: Axis.horizontal,
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
children: [
DraggablePaneItem(
size: widget.size,
paneContext: widget.paneContext,
pane: CrossDraggablesEntity(draggable: widget.node),
feedback: (context) =>
widget.node.tabs.currentPageManager.title(),
child: Column(
children: [
Padding(
padding: EdgeInsets.only(
left: widget.layout.menuSpacing,
),
child: TabsManager(
pane: widget.node,
pageController: pageController,
tabs: value,
),
),
child: TabsManager(
pane: widget.node,
pageController: pageController,
tabs: value,
value.currentPageManager.stackTopBar(
layout: widget.layout,
paneId: widget.node.paneId,
),
),
value.currentPageManager.stackTopBar(
layout: widget.layout,
paneId: widget.node.paneId,
),
],
],
),
),
),
Expanded(
child: PageView(
physics: const NeverScrollableScrollPhysics(),
controller: pageController,
children: value.pageManagers
.map(
(pm) => PageStack(
pageManager: pm,
delegate: widget.delegate,
),
)
.toList(),
Expanded(
child: PageView(
physics: const NeverScrollableScrollPhysics(),
controller: pageController,
children: value.pageManagers
.map(
(pm) => PageStack(
pageManager: pm,
delegate: widget.delegate,
),
)
.toList(),
),
),
),
],
).constrained(
width: widget.layout.homePageWidth,
height: widget.layout.homePageHeight,
],
).constrained(
width: widget.layout.homePageWidth,
height: widget.layout.homePageHeight,
),
),
),
),
Expand All @@ -111,6 +114,23 @@ class _FlowyPaneState extends State<FlowyPane> {
);
}

bool _proportionalScroll(ScrollNotification notification) {
if (notification is ScrollEndNotification &&
notification.metrics.axis == Axis.vertical) {
final scrollPercentage =
notification.metrics.pixels / notification.metrics.maxScrollExtent;

final outerScrollExtent = scrollPercentage * widget.size.height;

verticalController.animateTo(
outerScrollExtent,
duration: const Duration(milliseconds: 300),
curve: Curves.easeInOut,
);
}
return false;
}

@override
void dispose() {
horizontalController.dispose();
Expand Down

0 comments on commit e93618a

Please sign in to comment.