aw-front-helpers 2.5.19 → 2.5.20

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.
@@ -1,4 +1,5 @@
1
1
  import Symbol from 'es6-symbol/polyfill';
2
+ import { Loader } from '@googlemaps/js-api-loader';
2
3
 
3
4
  // singleton
4
5
  const singleton = Symbol();
@@ -11,6 +12,7 @@ class bootstraperMaps {
11
12
  if (pEnforcer !== singletonEnforcer) {
12
13
  throw 'Cannot construct singleton';
13
14
  }
15
+ this._loading = false;
14
16
  this._initialized = false;
15
17
  this._promise = new Promise((resolve, reject) => {
16
18
  this._resolve = resolve;
@@ -24,25 +26,22 @@ class bootstraperMaps {
24
26
  return this[singleton];
25
27
  }
26
28
 
27
- _init() {
28
- const tag = document.createElement('script'),
29
- firstScriptTag = document.getElementsByTagName('script')[0],
30
- libs = this._libraries ? `&libraries=${this._libraries.join(',')}` : ``;
31
- tag.src = `https://maps.googleapis.com/maps/api/js?key=${this._googleAPIKey}${libs}&callback=onMapsReady`;
32
- firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
33
- }
34
-
35
29
  load(googleAPIKey, libraries = null) {
36
- this._googleAPIKey = googleAPIKey;
37
- this._libraries = libraries;
38
-
39
- window.onMapsReady = () => {
40
- this._initialized = true;
41
- this._resolve();
42
- };
43
- if (this._initialized) this._resolve();
44
- else this._init();
45
-
30
+ if(this._initialized) this._resolve();
31
+ else if (!this._loading) {
32
+ const options = {
33
+ apiKey: googleAPIKey,
34
+ version: "weekly",
35
+ }
36
+ if( libraries ) options.libraries = libraries;
37
+ const loader = new Loader(options);
38
+ this._loading = true;
39
+ loader.load().then(() => {
40
+ this._initialized = true;
41
+ this._loading = false;
42
+ this._resolve()
43
+ }).catch(console.error);
44
+ }
46
45
  return this._promise;
47
46
  }
48
47
  }
package/classes/sticky.js CHANGED
@@ -55,7 +55,7 @@ export default class Sticky extends EventEmitter {
55
55
  //________________________________________________________ events
56
56
  // -
57
57
  _onScrollHandler() {
58
- if (this._isDisabled) return;
58
+ if (this._isDisabled || !this._vars) return;
59
59
  this._vars.scrollY = window.scrollY;
60
60
  requestAnimationFrame(this._onScroll);
61
61
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aw-front-helpers",
3
- "version": "2.5.19",
3
+ "version": "2.5.20",
4
4
  "description": "Assets helpers for projects",
5
5
  "author": "Yoann Le Poupon",
6
6
  "license": "ISC",
@@ -10,6 +10,7 @@
10
10
  "url": "git@gitlab.com:awstudio/front-helpers.git"
11
11
  },
12
12
  "dependencies": {
13
+ "@googlemaps/js-api-loader": "^1.16.6",
13
14
  "es6-symbol": "^3.1.3",
14
15
  "exif-js": "^2.3.0",
15
16
  "debounce": "^1.2.1",