-
-
Notifications
You must be signed in to change notification settings - Fork 757
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
Conversation
Codecov ReportAttention:
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
☔ View full report in Codecov by Sentry. |
Ready for review |
Ready for review. |
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'; |
There was a problem hiding this comment.
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...
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't see that line in touch_pan.ts file.
https://github.com/arekgotfryd/maplibre-gl-js/blob/3da57effa8c864fd7cad9682f5a84816eed42f33/src/ui/handler/touch_pan.ts#L40
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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...?
There was a problem hiding this comment.
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.
@arekgotfryd Are you no longer interested in this feature? |
@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. |
Launch Checklist
CooperativeGesture message will not get show when scrollZoom is disbaled
Don't show cooperativeGestures messages when scrollZoom is disabled #2498