Skip to content

Gesture detector scale and pan should work together #49025

Closed

Description

@Faiyyaz

Use case

Currently in GestureDetector we are unable to use pan and scale together since pan is super of scale, but in reality pan happens when there is one finger on a component and scaling happens when there are multiple fingers. So i don't know why such issue should happens.

Our use case is that we have containers in stack which we want to pan & zoom & rotate using gestures.

Proposal

The gesture detector should be able to call pan related functions on one finger movement and should call scale related function when there is more than on finger movement.

Activity

  1. changed the title [-]Gesture detetctor scale and pan should work together[/-] [+]Gesture detector scale and pan should work together[/+] on Jan 17, 2020
  2. added
    f: gesturesflutter/packages/flutter/gestures repository.
    frameworkflutter/packages/flutter repository. See also f: labels.
    c: new featureNothing broken; request for a new capability
    on Jan 17, 2020
  3. Faiyyaz commented on Jan 21, 2020

    @Faiyyaz
    Author

    Also i have another finding that in iOS environment onPanUpdate is also call one more time when we leave/end pan

  4. yati989 commented on Apr 28, 2020

    @yati989

    Also i have another finding that in iOS environment onPanUpdate is also call one more time when we leave/end pan

    Did you find any workaround for your use case? It seems like it is still not possible to use both simultaneously! I want to create a drawing canvas that wants scale gestures (for zooming, panning and rotating) and pan gestures (for drawing) to work simultaneously together. Please help!

  5. Faiyyaz commented on Apr 29, 2020

    @Faiyyaz
    Author

    No its not possible to use both that's why i asked them to help me!

  6. wanjm commented on Jul 20, 2020

    @wanjm

    any one follow this? many people ask for it;

  7. MandarinSmell commented on Jul 25, 2020

    @MandarinSmell

    I'm making my own widget, so I need both scaling and panning gestures at the same time. I won't complain that Scaling is superset of Panning gesture... if I can distinguish if users are touching screen with 2 fingers or 1 finger. Even though Flutter says scaling is super set of panning, but there is no way to distinguish if user is trying to scaling or panning. I've never developed iOS, but there are codes which tell how many fingers are on the screen in Android for sure.

    So I agree that Flutter must have codes which tells how many fingers on the screen, so developers can know number of fingers on the screen, then we will be able to performing both panning and scaling by checking number of fingers. If number of fingers tells 1, then perform panning by using focalPoint or localFocalPoint. If number of fingers tells 2 or higher, then perform scaling by using scale/horizontalScale/verticalScale factor.

    This may cause conflict when users put 2 fingers at first, and suddenly release only 1 finger, so Flutter must update number of fingers too when onScaleUpdate is called, then developers will handle rest of it.

  8. taodo2291 commented on Sep 11, 2020

    @taodo2291

    but there is no way to distinguish if user is trying to scaling or panning

    As I have known we can use the Listener widget for the listens pointer event, then bases on the pointer id to detect how many fingers are touching the screen.

    checkout the package gesture_x_detector for more detail.
    we can listen to both scale and pan events.

    Anyways, it is better if the Gesture detector can support scale and pan together, so we don't need to build our own custom gesture detector.

  9. dancamdev commented on Sep 26, 2020

    @dancamdev

    This is a huge flaw in the GestureDetector Widget IMO. The one mentioned is a common use case, and I don't expect two extremely different gestures to collide because one is a superset of the othe.

    On top of that, the message isn't clear and onScaleUpdate being used for dragging results in bad naming.

    We should strive for having both working at the same time without colliding, handling two different gestures.

  10. xu-baolin commented on Jan 8, 2021

    @xu-baolin
    Member

    Hi, everyone,
    #73474 This PR will expand the detail parameter of the scale gesture so that developers can get the number of tracking fingers when the event be triggered. I think this can meet the purpose.

  11. xu-baolin commented on Jan 12, 2021

    @xu-baolin
    Member

    Scale is a superset so that you can put one finger down, pan, then without lifting that finger put a second down and switch to zooming.
    See Also #49025 (comment)

    I will close this issue as solved.
    Feel free to leave comments to request a reopen or file a new issue if it does not meet your purpose.

  12. github-actions commented on Aug 7, 2021

    @github-actions

    This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

  13. locked as resolved and limited conversation to collaborators on Aug 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    c: new featureNothing broken; request for a new capabilityf: gesturesflutter/packages/flutter/gestures repository.frameworkflutter/packages/flutter repository. See also f: labels.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions