@wemap/providers 4.0.8 → 4.0.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -8,16 +8,16 @@
8
8
  "Guillaume Pannetier <guillaume.pannetier@getwemap.com>"
9
9
  ],
10
10
  "dependencies": {
11
- "@wemap/geo": "^4.0.4",
11
+ "@wemap/geo": "^4.0.10",
12
12
  "@wemap/geomagnetism": "^0.1.1",
13
13
  "@wemap/logger": "^4.0.0",
14
- "@wemap/map": "^4.0.4",
14
+ "@wemap/map": "^4.0.10",
15
15
  "@wemap/maths": "^4.0.3",
16
16
  "@wemap/utils": "^4.0.0"
17
17
  },
18
18
  "description": "A package using different geoloc systems",
19
19
  "devDependencies": {
20
- "@wemap/osm": "^4.0.4",
20
+ "@wemap/osm": "^4.0.10",
21
21
  "mapbox-gl": "^1.11.1"
22
22
  },
23
23
  "homepage": "https://github.com/wemap/wemap-modules-js#readme",
@@ -39,6 +39,6 @@
39
39
  "url": "git+https://github.com/wemap/wemap-modules-js.git"
40
40
  },
41
41
  "type": "module",
42
- "version": "4.0.8",
43
- "gitHead": "d0b114fb1991cbc5682ef8d8b1a758972a514673"
42
+ "version": "4.0.10",
43
+ "gitHead": "684e1328f164054572b32f241e3e3b85cc3b1362"
44
44
  }
@@ -100,8 +100,14 @@ class AbsolutePosition extends Provider {
100
100
 
101
101
  if (lastPosition) {
102
102
 
103
- // Reject if the new position accuracy is not twice better than the last position accuracy
104
- if (newPosition.accuracy * AbsolutePosition.ACCURACY_RELOC_RATIO > lastPosition.accuracy) {
103
+ // Is the new position accuracy is better enough than the last position accuracy
104
+ const isBetterEnough = newPosition.accuracy * AbsolutePosition.ACCURACY_RELOC_RATIO < lastPosition.accuracy;
105
+
106
+ // Is the new position is far from the new one (regarding accuracy)
107
+ // This is important if the person put the current page in the background during a while
108
+ const isFarEnough = lastPosition.distanceTo(newPosition) > lastPosition.accuracy + newPosition.accuracy;
109
+
110
+ if (!isBetterEnough && !isFarEnough) {
105
111
  return;
106
112
  }
107
113