Go to file
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
build Merge pull request #3028 from tomhughes/jshint 2014-11-17 13:54:31 -08:00
debug add interactive option on ImageOverlay 2014-11-09 13:23:19 -06:00
dist Merged css declarations 2014-09-03 21:07:30 +02:00
spec No-op Control#remove if not on a map (fixes #2877) 2014-11-13 11:25:49 -08:00
src Improve inertial scrolling 2014-11-26 11:34:28 -05:00
.gitignore add publish script for component and bower 2014-03-19 20:29:41 -04:00
.npmignore Add .npmignore 2013-04-14 13:22:58 -07:00
.travis.yml fix travis build uploads, ref travis-ci/travis-artifacts#23 2014-03-19 17:47:12 -07:00
CHANGELOG.md add 0.7.3 changelog 2014-05-23 12:23:46 +03:00
CONTRIBUTING.md Fix typos in CONTRIBUTING 2014-06-30 18:46:20 -05:00
FAQ.md Changed language referring to layers 2014-07-05 20:17:57 -07:00
Jakefile.js Fixed jake build if leaflet copy is not a git repository 2014-06-24 22:58:54 +02:00
LICENSE update year to 2014 2014-01-08 20:40:04 +02:00
package.json update package.json & deps 2014-10-29 17:20:55 +02:00
PLUGIN-GUIDE.md simplify AMD definition 2014-10-21 12:32:06 -05:00
README.md fix readme link 2013-11-08 01:49:41 +02:00

Leaflet

Leaflet is an open source JavaScript library for mobile-friendly interactive maps. It is developed by Vladimir Agafonkin of MapBox with a team of dedicated contributors. Weighing just about 30 KB of gzipped JS code, it has all the features most developers ever need for online maps.

Leaflet is designed with simplicity, performance and usability in mind. It works efficiently across all major desktop and mobile platforms out of the box, taking advantage of HTML5 and CSS3 on modern browsers while being accessible on older ones too. It can be extended with a huge amount of plugins, has a beautiful, easy to use and well-documented API and a simple, readable source code that is a joy to contribute to.

For more info, docs and tutorials, check out the official website.
For Leaflet downloads (including the built master version), check out the download page.

We're happy to meet new contributors. If you want to get involved with Leaflet development, check out the contribution guide. Let's make the best mapping library that will ever exist, and push the limits of what's possible with online maps!

Build Status