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

Since v0.40.0, touch event MoveUpdate cannot be called continuously after tap #1127

Closed
htsuruo opened this issue Aug 23, 2022 · 9 comments
Closed

Comments

@htsuruo
Copy link
Contributor

htsuruo commented Aug 23, 2022

Hi, thanks to your awesome chart package.

Since v0.40.0, touch event MoveUpdate cannot be called continuously after tap(= required longPress).
Difference in behavior is here.

v0.36.4 v0.40.0~
need_not_to_longpress required_longpress

Is the behavior expected?

I think, it's change is not good for users.
Some users cannot aware that the chart enable for them to trace line and show tooltip because of need to wait for certain amount of time.
Therefore, I would like to revert to v0.36.0 behavior.

To Reproduce

Just use line_chart_sample_1.dart
https://github.com/imaNNeoFighT/fl_chart/blob/master/example/lib/line_chart/samples/line_chart_sample1.dart

Thanks.

@Divinoart
Copy link

I suggest we have a flag for this, to set the long press to be true or false.
user are not mostly aware that they need to longPress

@Divinoart
Copy link

Divinoart commented Aug 24, 2022

Found a fix for it,
Not the best practice but you'll need to edit the package.

Goto lib/src/chart/base/base_chart/render_base_chart.dart

then update line 72 to this:

Screenshot 2022-08-23 at 9 44 21 PM

_longPressGestureRecognizer = LongPressGestureRecognizer(duration: const Duration(milliseconds: 0));

The trick is, it sets the LongPressGestureRecognizer.duration to be 0 milliseconds instead of 500 from kLongPressTimeout.

Suggestion to the dev team is to make this a feature flag so people can enable or disable LongPress feature

@htsuruo
Copy link
Contributor Author

htsuruo commented Aug 24, 2022

@Divinoart

Hi, thanks for your response.

I suggest we have a flag for this, to set the long press to be true or false.

Your approach is better, so I agree with you.

@htsuruo
Copy link
Contributor Author

htsuruo commented Aug 24, 2022

@Divinoart

_longPressGestureRecognizer = LongPressGestureRecognizer(duration: const Duration(milliseconds: 0));
The trick is, it sets the LongPressGestureRecognizer.duration to be 0 milliseconds instead of 500 from kLongPressTimeout.

Good Job👍
Your solution works expected behavior.

_longPressGestureRecognizer = LongPressGestureRecognizer(duration: Duration.zero);
Duration.zero(v0.55.1)
duration zero

@Divinoart
Copy link

Divinoart commented Aug 24, 2022

Great!

@htsuruo
Copy link
Contributor Author

htsuruo commented Aug 24, 2022

Added longPressDuration optional property.
https://github.com/HTsuruo/fl_chart/tree/feature/tsuruo/enable-customize-longpress-duration

I hesitated that whether optional property should take a boolean true/false or duration, but finally decided that Duration property because it's better for flexibility.

LineTouchData(
  handleBuiltInTouches: true,
  touchTooltipData: LineTouchTooltipData(
    tooltipBgColor: Colors.blueGrey.withOpacity(0.8),
  ),
  
  // Here is additional property.
  // You can customize how long it takes for tooltips to appear.
  longPressDuration: Duration.zero,
);

@htsuruo
Copy link
Contributor Author

htsuruo commented Jan 19, 2023

Resolved by #1128

@htsuruo htsuruo closed this as completed Jan 19, 2023
@imaNNeo
Copy link
Owner

imaNNeo commented Jan 19, 2023

Resolved by #1128

Thank you for contributing.
It will be available in the next version soon.

@imaNNeo
Copy link
Owner

imaNNeo commented Jan 26, 2023

0.60.0 is just released. Check it out!

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

No branches or pull requests

3 participants