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

#2498: Don't show cooperativeGestures messages when scrollZoom is dis… #3240

Closed
wants to merge 14 commits into from

Conversation

arekgotfryd
Copy link

Launch Checklist

@codecov-commenter
Copy link

codecov-commenter commented Oct 20, 2023

Codecov Report

Attention: 2 lines in your changes are missing coverage. Please review.

Comparison is base (efdb76c) 75.23% compared to head (3da57ef) 75.27%.
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3240      +/-   ##
==========================================
+ Coverage   75.23%   75.27%   +0.03%     
==========================================
  Files         241      242       +1     
  Lines       19256    19277      +21     
  Branches     4339     4339              
==========================================
+ Hits        14488    14511      +23     
+ Misses       4768     4766       -2     
Files Coverage Δ
src/ui/control/fullscreen_control.ts 75.51% <ø> (ø)
src/ui/handler/scroll_zoom.ts 94.15% <100.00%> (+1.48%) ⬆️
src/ui/handler/touch_pan.ts 100.00% <ø> (ø)
src/ui/map.ts 83.02% <100.00%> (-0.21%) ⬇️
src/ui/control/cooperative_gesture_contol.ts 95.65% <95.65%> (ø)

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@arekgotfryd
Copy link
Author

Ready for review

src/ui/map.test.ts Outdated Show resolved Hide resolved
src/ui/map.test.ts Outdated Show resolved Hide resolved
@arekgotfryd
Copy link
Author

Ready for review.

@HarelM HarelM self-assigned this Oct 28, 2023
@arekgotfryd
Copy link
Author

Ready for review.

@@ -4,7 +4,7 @@ import type {Map} from '../map';
* A position defintion for the control to be placed, can be in one of the corners of the map.
* When two or more controls are places in the same location they are stacked toward the center of the map.
*/
export type ControlPosition = 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right';
export type ControlPosition = 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right' | 'full';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure how I feel about this, since there isn't another control that is full and I'm not sure what would be the expected behavior.
Can this control simply ignore this input maybe?
IDK...

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reason for 'full' position to be there is following method in map.ts
https://github.com/arekgotfryd/maplibre-gl-js/blob/3da57effa8c864fd7cad9682f5a84816eed42f33/src/ui/map.ts#L717
if I remove getDefaultPosition implementation from CooperativeGestureControl class addControl method will assume top-right position for it.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While not "accurate" the default seems to be OK I think.
Otherwise we'll need to support configuring the scale control, or zoom control to be full screen, which is not what we want I believe.

@@ -147,14 +150,15 @@ export class ScrollZoomHandler implements Handler {
* ```
*/
disable() {
this._map.setCooperativeGestures(false);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't this disable cooperative gesture even if it was enabled to begin with when disabling scroll zoom?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't follow...
What is the point of cooperative gestures message when zooming is disabled?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can enable and disable scroll zoom after the map is initialized, this will "forget" the initial state I think.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok I get it now but in that case I would need two additional methods on Map class:
enableCooperativeGestures
disableCooperativeGestures
Are you fine with that?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Having these separate methods would avoid cluttering of setCooperativeGestures method.

}

touchstart(e: TouchEvent, points: Array<Point>, mapTouches: Array<Touch>) {
return this._calculateTransform(e, points, mapTouches);
}

touchmove(e: TouchEvent, points: Array<Point>, mapTouches: Array<Touch>) {
if (this._map._cooperativeGestures) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't seen this code moved to the controller, am I missing something?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because you removed it...

touchmove(e: TouchEvent, points: Array<Point>, mapTouches: Array<Touch>) {

@@ -1176,9 +1157,14 @@ export class Map extends Camera {
setCooperativeGestures(gestureOptions?: GestureOptions | boolean | null): Map {
this._cooperativeGestures = gestureOptions;
if (this._cooperativeGestures) {
this._setupCooperativeGestures();
if (this._cooperativeGesturesControl) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a more elegant way instead of remove and then add - simply keep it as is, or call some enable method...?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I couldn't come up with better way to handle this without changing public interface of Map class but I'm open to any suggestions.

@HarelM
Copy link
Collaborator

HarelM commented Nov 16, 2023

@arekgotfryd Are you no longer interested in this feature?

@arekgotfryd
Copy link
Author

@HarelM I just don't have time at the moment to look into this. I decided to close it in order to give someone else possibility to pick it up.

@HarelM HarelM mentioned this pull request Nov 30, 2023
8 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants