FLUTTER ECOSYSTEM

alesimula/dyn_mouse_scroll

Flutter 패키지. 모든 플랫폼에서 마우스로 부드러운 스크롤을 가능하게 하는 스크롤 가능한 위젯용 래퍼입니다.

dyn_mouse_scroll 프로젝트 이미지
Stars
7
Forks
10
최근 푸시(UTC)
2023. 10. 12.
프로젝트 상태
활성
alesimula GitHub avatar
GITHUB User

alesimula ↗

언어Dart

이 저장소가 배포한 패키지

사용 중인 의존성

의존성 목록 4 개
  • flutter{"sdk":"flutter"}
  • provider^6.0.3
  • flutter_test개발 의존성{"sdk":"flutter"}
  • flutter_lints개발 의존성^2.0.0

원본 README

아래는 영문 원문 스냅샷입니다. 최신 내용은 GitHub에서 확인하세요.

README 펼치기 / 접기

Multiplatform Smooth Scroll

A fork of the dyn_mouse_scroll package, including Wizzel1's fixes and my own fixes; Provides wrapper for scrollable widgets that enables smooth scrolling with a mouse wheel, trackpad or touch screen on all platforms; This fork fixes all issues regarding trackpad, mouse/trackpad switching and animations, fixing the slippery effect when changing scroll direction; The fork also changes the default mouse scroll animation to look smoother; Additionally, it allows to change the scroll speed, on top of the duration and animation curve.

First gif: Scrolling slowly.
Second gif: Scrolling quickly (flick scroll).
Third gif: Mobile drag scroll detected, physics change.

https://raw.githubusercontent.com/Bluebar1/dyn_mouse_scroll/main/assets/slow_scroll.gif https://raw.githubusercontent.com/Bluebar1/dyn_mouse_scroll/main/assets/fast_scroll.gif https://raw.githubusercontent.com/Bluebar1/dyn_mouse_scroll/main/assets/drag_scroll.gif

Features

  • Animate smooth scroll based on speed of user's scroll.
  • Automatically detect if the wrong ScrollPhysics is being used and update using provider.
  • Adjust the duration of your scroll events.
  • Choose what mobile physics you would like to use.

Basic Usage

DynMouseScroll(
  builder: (context, controller, physics) => ListView(
    controller: controller,
    physics: physics,
    children: ...
    )
)

With additional settings:

DynMouseScroll(
  durationMS: 500,
  scrollSpeed: 4.4,
  animationCurve: Curves.easeOutQuart,
  builder: (context, controller, physics) => ListView(
    controller: controller,
    physics: physics,
    children: ...
    )
)

Problem:

Flutter does not animate smooth scrolls for pointers, causing choppy experiences for the end user. One package, web_smooth_scroll, attempts to fix this problem by disabling default scrolling entirely (mobile can't drag now) and listening for pointer events to animate the scroll controller that can only move at one speed.

Solution:

To allow mobile default scrolling to still be accessible I detect the user's platform and automatically update if the detection was wrong. When the user scrolls, the 'futurePosition' variable is updated and the animation is started I set the mobile scroll physics as the default one, switching to desktop scroll physics as the mouse wheel scroll is initiated and only starting the animation after the widget is rebuilt; the desktop scroll physics then takes priority over mobile physics, switching back to mobile physics only after the last scroll animation has ended, only if no new scroll wheel action had been initiated in the meantime.