Skip to content

Commit 0a52980

Browse files
committed
v1.1.5 - the first "update()" should occur after load, fixes #7
1 parent b10528a commit 0a52980

File tree

6 files changed

+13
-9
lines changed

6 files changed

+13
-9
lines changed

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "image-map",
3-
"version": "1.1.4",
3+
"version": "1.1.5",
44
"author": {
55
"name": "Travis Clarke",
66
"email": "[email protected]",

dist/image-map.es.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,13 @@ function _nonIterableSpread() {
4949
throw new TypeError("Invalid attempt to spread non-iterable instance");
5050
}
5151

52-
var version = "1.1.4";
52+
var version = "1.1.5";
5353

5454
var RESIZE = "resize";
5555
var LOAD = "load";
5656
var USEMAP = "usemap";
5757
var COORDS = "coords";
58+
var COMPLETE = "complete";
5859
/**
5960
* ImageMap main library constructor
6061
*
@@ -70,7 +71,7 @@ function () {
7071
_classCallCheck(this, ImageMap);
7172

7273
this.selector = selector instanceof Array ? selector : _toConsumableArray(document.querySelectorAll(selector));
73-
this.update();
74+
if (document.readyState !== COMPLETE) window.addEventListener(LOAD, this.update.bind(this));else this.update();
7475
window.addEventListener(RESIZE, this.debounce(this.update, wait).bind(this));
7576
}
7677

dist/image-map.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,13 @@
5555
throw new TypeError("Invalid attempt to spread non-iterable instance");
5656
}
5757

58-
var version = "1.1.4";
58+
var version = "1.1.5";
5959

6060
var RESIZE = "resize";
6161
var LOAD = "load";
6262
var USEMAP = "usemap";
6363
var COORDS = "coords";
64+
var COMPLETE = "complete";
6465
/**
6566
* ImageMap main library constructor
6667
*
@@ -76,7 +77,7 @@
7677
_classCallCheck(this, ImageMap);
7778

7879
this.selector = selector instanceof Array ? selector : _toConsumableArray(document.querySelectorAll(selector));
79-
this.update();
80+
if (document.readyState !== COMPLETE) window.addEventListener(LOAD, this.update.bind(this));else this.update();
8081
window.addEventListener(RESIZE, this.debounce(this.update, wait).bind(this));
8182
}
8283

dist/image-map.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "image-map",
3-
"version": "1.1.4",
3+
"version": "1.1.5",
44
"description": "Response, dynamic image maps",
55
"main": "dist/image-map.js",
66
"module": "dist/image-map.es.js",

src/image-map.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ const RESIZE = "resize";
55
const LOAD = "load";
66
const USEMAP = "usemap";
77
const COORDS = "coords";
8+
const COMPLETE = "complete";
89

910
/**
1011
* ImageMap main library constructor
@@ -16,7 +17,8 @@ const COORDS = "coords";
1617
class ImageMap {
1718
constructor(selector, wait) {
1819
this.selector = selector instanceof Array ? selector : [...document.querySelectorAll(selector)];
19-
this.update();
20+
if (document.readyState !== COMPLETE) window.addEventListener(LOAD, this.update.bind(this));
21+
else this.update();
2022
window.addEventListener(RESIZE, this.debounce(this.update, wait).bind(this));
2123
}
2224

0 commit comments

Comments
 (0)