Commit Graph

536 Commits

Author SHA1 Message Date
John Firebaugh
7d90dc152e Clean up pixel bounds calculations 2015-02-02 10:50:18 -08:00
Vladimir Agafonkin
e749d1915b add ESLint rules; various code style fixes 2015-01-28 17:27:31 +02:00
Tom MacWright
a28c9508be Don't mutate this._defaultLocateOptions. 2015-01-25 19:27:24 -05:00
Bernhard Eder
cc750d43ae fixed error in _tryAnimatedPan when options is undefined 2015-01-18 23:45:38 +01:00
Vladimir Agafonkin
e653cbe864 Merge pull request #3143 from bcamper/flyto-3139
flyTo: convert targetCenter to latLng
2015-01-18 11:18:53 +02:00
Chris Laidlaw
48a374db05 BUG: _tryAnimatedPan lies to setView about whether or not an animation was initiated. 2015-01-15 15:42:54 -08:00
Brett Camper
c656e3f993 flyTo: convert targetCenter to latLng
see #3139
2015-01-14 19:47:46 -05:00
Vladimir Agafonkin
c3a39f50cf fix accidentally broken build 2015-01-13 13:31:46 +02:00
Vladimir Agafonkin
4dfbcc46dd remove inertiaThreshold option, ref #3063 2015-01-13 13:31:11 +02:00
Vladimir Agafonkin
646d83608f Merge pull request #3063 from RickMohr/improve-inertial-scrolling
Improve inertial scrolling
2015-01-13 13:29:41 +02:00
Rick Mohr
08d828f519 Improve inertial scrolling
[This post](http://stackoverflow.com/a/3628949/362702) claims that in Apple's kinetic scrolling, "The velocity of the touch is measured at the exact moment that the finger is lifted."

I tried both this "final velocity" approach and the "max velocity" approach proposed in #2987. Both allow a stronger "fling" than the current "average velocity" approach, but "max velocity" can feel wrong if you slow down at the end of your swipe.

But because the "final velocity" approach uses just one data point it can be unstable, occasionally giving a too-large velocity from a small time delta.

Best is to stabilize that by averaging a few data points, so we're back to "average velocity" but using a shorter time period. Averaging over 50 ms instead of 100 ms gives good results, usually 4 data points on both my iPhone 4s and Chrome on my Windows laptop.

Another reason the current code has a weak fling is that the velocity was being calculated incorrectly. Because `delay` was added to the time delta, time was computed from n+1 points but distance from n points.

I also changed the default value of `inertiaThreshold` (intended to prevent unwanted additional movement if you stop dragging and then lift your finger) to `Infinity`, for two reasons:

1) A fling gesture often failed on my iPhone because the measured `delay` was higher than `inertiaThreshold` (current default 32), sometimes by hundreds of ms.
2) With the updated velocity code I don't see unwanted additional movement when I stop dragging and then lift my finger.

There is a remaining issue (with both the original and updated code). If you fling the map and try to fling it again before it stops moving, no drag events are generated for the second fling so it has no effect. I don't see this problem with e.g. Google or Apple maps. Entered as #3062.

Fixes #2987
2014-11-26 11:34:28 -05:00
Kenny Shepard
86a3e0cc8c Initialize _sizeChanged to prevent async issues
When asynchronously initializing a map, the series of events can
create a scenario where _size is incorrectly initialized, and
therefore calls to getSize will not cause a new value to be generated.

This fix sets _sizeChanged to true upon map initialization, which
allows the following first call to getSize to work properly.

Closes #3031
2014-11-21 17:54:46 -05:00
kdeloach
c97c48325a Remove global variable that disables dragging for all maps during zoom
Starting a zoom animation will disable dragging for all maps on the
page. Only the map that is being zoomed should have dragging disabled.

This fix removes a global static variable which is redundant since
the map pane already has a css class assigned to it for the duration of
the zoom animation.

Fixes #2539
2014-11-21 14:41:00 -05:00
flemenach
8c606358cc Fix inertia animation with worldCopyJump enabled 2014-11-18 09:32:46 +01:00
Yohan Boniface
f41f37c9c0 More compact code 2014-11-14 17:12:15 +01:00
Yohan Boniface
86de51ed9e We don't need an option for the zoom factor 2014-11-14 14:16:41 +01:00
Yohan Boniface
44a10690a7 Implement fast zoom on minus/plus keydown with shiftKey 2014-11-14 12:38:09 +01:00
John Firebaugh
aa8be54513 stopPropagation of click event following drag operation (fixes #2930) 2014-11-11 17:08:27 -08:00
Vladimir Agafonkin
5f9321bac0 Merge pull request #3001 from snkashis/latlng_bounds_conversion
extract bounds conversion from Map.Geolocation.Also fix geolocation test...
2014-11-06 21:55:57 +02:00
Steve Kashishian
f3b132e414 extract bounds conversion from Map.Geolocation.Also fix geolocation test page. 2014-11-06 13:23:14 -06:00
Steve Kashishian
1eae1719bb no map._popup check needed 2014-11-06 13:02:21 -06:00
Steve Kashishian
ead96e500e closes an open popup with escape key 2014-11-06 12:48:13 -06:00
Vladimir Agafonkin
f10512f836 fix map.fitBounds race condition, close #2957
Fixes a situation where map.fitBounds(map.getBounds()) sometimes zoomed
out.
2014-10-31 13:57:23 +02:00
Vladimir Agafonkin
d93e828935 stop panning/fly animations when necessary 2014-10-21 12:21:32 +03:00
Vladimir Agafonkin
23998c1f9c ditch transition stopping code 2014-10-21 12:21:32 +03:00
Vladimir Agafonkin
70923e6604 rename zoomPanTo to flyTo 2014-10-21 12:21:32 +03:00
Vladimir Agafonkin
7a75d07d89 update inertia settings 2014-10-21 12:21:32 +03:00
Dave Leaver
b42500b48a Only stop the pan animation within pan animation. If there is a zoom animation going on we don't want to stop it. Otherwise big mouse wheel zooms are broken. 2014-10-21 12:21:31 +03:00
John Firebaugh
a34810cb85 Use Map#stop to stop all animations 2014-10-21 12:21:30 +03:00
Dave Leaver
a071f489a5 Removing comment out code and not needed todos 2014-10-21 12:21:30 +03:00
Dave Leaver
498aef4c31 Push getTransform up to L.DomUtil.getTransform rather than having it in ZoomAnimation and PosAnimation 2014-10-21 12:21:30 +03:00
Dave Leaver
b6c4ebdbca Move the proxy in to Map.ZoomAnimation as it is the only place that uses it. Use it to detect zoom animation finishing. 2014-10-21 12:21:30 +03:00
Dave Leaver
97598d4241 Move animated zoom stopping in to the place it belongs 2014-10-21 12:21:30 +03:00
Dave Leaver
a5552f4ed4 listen to moveend instead so we know where we are after a map drag 2014-10-21 12:21:30 +03:00
Dave Leaver
7aa9d95e9a Getting closer. project and unproject based on the current zoom seems to work in most cases. 2014-10-21 12:21:30 +03:00
Dave Leaver
c1bea627b0 stopAnimation -> stop 2014-10-21 12:21:30 +03:00
Dave Leaver
a0bc81cba8 Stop animating before starting a ZoomPan, otherwise they both run at the same time. 2014-10-21 12:21:30 +03:00
Dave Leaver
00a66b4731 Add an element for tracking zoom animations. Use it for trying to stop a map zoom. Still doesn't quite work right. Stopping a zoomPan or PanAnimation does work however. Code is all cludgy :)
refs #2560
2014-10-21 12:21:30 +03:00
Vladimir Agafonkin
5912c365b7 zoom to the nearest round zoom with pinch or dblclick 2014-10-21 12:21:29 +03:00
Vladimir Agafonkin
169b6a0e77 adjust zoomPan options, add a debug page 2014-10-21 12:21:29 +03:00
Vladimir Agafonkin
454552e694 fix zoomPan logic, cleaner code 2014-10-21 12:21:29 +03:00
Vladimir Agafonkin
dc04b9dbe2 add fromZoom arg to Map getZoomScale and getScaleZoom 2014-10-21 12:21:29 +03:00
Vladimir Agafonkin
1b8f68d806 simpler zoom anim calculations 2014-10-21 12:21:29 +03:00
Vladimir Agafonkin
bbb5a5a956 fix some positioning bugs 2014-10-21 12:21:28 +03:00
Vladimir Agafonkin
e26d148516 cleaner reset logic for GridLayer 2014-10-21 12:21:28 +03:00
Vladimir Agafonkin
790acad011 clean up zoomPanTo 2014-10-21 12:21:28 +03:00
Vladimir Agafonkin
4a344ae021 working zoomPanTo implementation 2014-10-21 12:21:28 +03:00
Vladimir Agafonkin
de4910f407 use offset when animating transform to avoid dividing by zero 2014-10-21 12:21:28 +03:00
Vladimir Agafonkin
e41d65fe66 fractional zoom code clean up an fixes 2014-10-21 12:21:28 +03:00
Vladimir Agafonkin
2be2cca49a basic linear zoomPanTo without intermediary tile loading 2014-10-21 12:21:28 +03:00