More kinetic panning optimizations
This commit is contained in:
@@ -374,6 +374,16 @@ export default class MapComponent extends Component {
|
|||||||
? new Kinetic(-0.005, 0.05, 100)
|
? new Kinetic(-0.005, 0.05, 100)
|
||||||
: false;
|
: false;
|
||||||
|
|
||||||
|
// Fix for "sticky" touches on mobile:
|
||||||
|
// If we're on mobile (width <= 768) AND using kinetic,
|
||||||
|
// we increase the minimum velocity required to trigger kinetic panning.
|
||||||
|
// This prevents slow drags from being interpreted as a "throw"
|
||||||
|
if (this.settings.mapKinetic && window.innerWidth <= 768) {
|
||||||
|
// Default minVelocity is 0.05. We bump it up significantly.
|
||||||
|
// This means the user has to really "flick" the map to get inertia.
|
||||||
|
kinetic.minVelocity_ = 0.25;
|
||||||
|
}
|
||||||
|
|
||||||
this.mapInstance.addInteraction(
|
this.mapInstance.addInteraction(
|
||||||
new DragPan({
|
new DragPan({
|
||||||
kinetic: kinetic,
|
kinetic: kinetic,
|
||||||
|
|||||||
@@ -28,13 +28,8 @@ export default class SettingsService extends Service {
|
|||||||
const savedKinetic = localStorage.getItem('marco:map-kinetic');
|
const savedKinetic = localStorage.getItem('marco:map-kinetic');
|
||||||
if (savedKinetic !== null) {
|
if (savedKinetic !== null) {
|
||||||
this.mapKinetic = savedKinetic === 'true';
|
this.mapKinetic = savedKinetic === 'true';
|
||||||
} else {
|
|
||||||
// Default: disabled on small screens (mobile), enabled on desktop
|
|
||||||
// We check for typical mobile width (<= 768px)
|
|
||||||
if (typeof window !== 'undefined') {
|
|
||||||
this.mapKinetic = window.innerWidth > 768;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
// Default is true (initialized in class field)
|
||||||
}
|
}
|
||||||
|
|
||||||
updateOverpassApi(url) {
|
updateOverpassApi(url) {
|
||||||
|
|||||||
Reference in New Issue
Block a user