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

disable map scroll when map zoom Exceeding Zoom limits #2444

Merged
merged 1 commit into from
Oct 23, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion src/map/handler/Map.ScrollWheelZoom.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { isNil } from '../../core/util';
import { isNil, isNumber } from '../../core/util';
import { addDomEvent, removeDomEvent, getEventContainerPoint, preventDefault, stopPropagation } from '../../core/util/dom';
import Handler from '../../handler/Handler';
import Map from '../Map';
Expand Down Expand Up @@ -65,6 +65,23 @@ class MapScrollWheelZoomHandler extends Handler {
removeDomEvent(this.target._containerDOM, 'wheel', this._onWheelScroll);
}

//@internal
_currentZoomCanScroll(value: number) {
if (isNumber(value)) {
const map = this.target;
const zoom = map.getZoom();
const minZoom = map.getMinZoom();
const maxZoom = map.getMaxZoom();
if (zoom === minZoom && value > 0) {
return false;
}
if (zoom === maxZoom && value < 0) {
return false;
}
}
return true;
}

//@internal
_onWheelScroll(evt) {
const map = this.target;
Expand Down Expand Up @@ -119,6 +136,9 @@ class MapScrollWheelZoomHandler extends Handler {
this._delta = 0;
}
this._delta -= value;
if (!this._currentZoomCanScroll(value)) {
return;
}
if (!this._zooming && this._delta) {
const map = this.target;
this._zoomOrigin = origin;
Expand Down