Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Desktop: scroll by mouse-wheel #10

Closed
espresso3389 opened this issue Dec 25, 2023 · 3 comments
Closed

Desktop: scroll by mouse-wheel #10

espresso3389 opened this issue Dec 25, 2023 · 3 comments
Labels
feature request New feature or request

Comments

@espresso3389
Copy link
Owner

Currently, PdfViewer does not support scroll by mouse-wheel on desktop platforms.
We'd better support scroll by mouse-wheel but we should investigate the way to implement it.

According to flutter/flutter#121961, they don't want to implement scroll by mouse-wheel on InteractiveViewer anyway.

So, the approach may be one of

  • Forking InteractiveViewer to implement our own scroll by mouse-wheel feature
  • Switching the container to TwoDimensionalScrollable
@mlican
Copy link

mlican commented Dec 26, 2023

You can refer to the following ideas, but I haven't written the specific code yet. First, set the scaleEnabled parameter of InteractiveViewer to false. Outside of InteractiveViewer, use a Listener to listen for onPointerSignal, for example:

Timer? _scrollTimer;  
bool isScrolled = false; 


return Listener(  
  onPointerSignal: (event) {
  isScrolled = true;  
  if (event is PointerScrollEvent) {  
    /// Set scroll position  
    jumpTo(  
        xOffset: currentOffset.dx + event.scrollDelta.dx,  
        yOffset: currentOffset.dy + event.scrollDelta.dy);  
  }  
  _scrollTimer?.cancel();  
  _scrollTimer = Timer(  
    const Duration(milliseconds: 100),  
    () {  
      isScrolled = false;  
    },  
  );  
  },  
  child: Container(  
    color: widget.params.backgroundColor,  
    child: Stack(  
      children: [  
        InteractiveViewer(
            scaleEnabled: false,
        ......

@espresso3389
Copy link
Owner Author

I'm just considering to fork the original InteractiveViewer to support scroll-by-mouse-wheel.
If we just simply wrap InteractiveViewer with Listener, it kills some of InteractiveViewer features such as touchpad support. I don't want to kill them but need better mouse-wheel support.

@espresso3389
Copy link
Owner Author

0.3.2 now supports PdfViewerParams.scrollByMouseWheel to specify wheel-delta to scroll ratio. If it is null, it defaults the InteractiveViewer's wheel-to-scale behavior.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants