swup 2.0.15 → 2.0.18
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/dist/swup.js +384 -257
- package/dist/swup.min.js +1 -1
- package/lib/helpers/cleanupAnimationClasses.js +18 -0
- package/lib/helpers/getDataFromHtml.js +11 -18
- package/lib/helpers/index.js +17 -2
- package/lib/helpers/markSwupElements.js +6 -10
- package/lib/helpers/normalizeUrl.js +17 -0
- package/lib/helpers/transitionEnd.js +4 -15
- package/lib/helpers/transitionProperty.js +14 -0
- package/lib/index.js +17 -4
- package/lib/modules/Cache.js +7 -1
- package/lib/modules/getAnchorElement.js +25 -0
- package/lib/modules/getAnimationPromises.js +17 -1
- package/lib/modules/renderPage.js +9 -16
- package/lib/utils/index.js +8 -0
- package/package.json +1 -1
package/dist/swup.js
CHANGED
|
@@ -91,7 +91,7 @@ return /******/ (function(modules) { // webpackBootstrap
|
|
|
91
91
|
/******/
|
|
92
92
|
/******/
|
|
93
93
|
/******/ // Load entry module and return exports
|
|
94
|
-
/******/ return __webpack_require__(__webpack_require__.s =
|
|
94
|
+
/******/ return __webpack_require__(__webpack_require__.s = 3);
|
|
95
95
|
/******/ })
|
|
96
96
|
/************************************************************************/
|
|
97
97
|
/******/ ([
|
|
@@ -104,7 +104,7 @@ return /******/ (function(modules) { // webpackBootstrap
|
|
|
104
104
|
Object.defineProperty(exports, "__esModule", {
|
|
105
105
|
value: true
|
|
106
106
|
});
|
|
107
|
-
exports.Link = exports.markSwupElements = exports.getCurrentUrl = exports.transitionEnd = exports.fetch = exports.getDataFromHtml = exports.createHistoryRecord = exports.classify = undefined;
|
|
107
|
+
exports.cleanupAnimationClasses = exports.Link = exports.markSwupElements = exports.normalizeUrl = exports.getCurrentUrl = exports.transitionProperty = exports.transitionEnd = exports.fetch = exports.getDataFromHtml = exports.createHistoryRecord = exports.classify = undefined;
|
|
108
108
|
|
|
109
109
|
var _classify = __webpack_require__(7);
|
|
110
110
|
|
|
@@ -126,18 +126,30 @@ var _transitionEnd = __webpack_require__(11);
|
|
|
126
126
|
|
|
127
127
|
var _transitionEnd2 = _interopRequireDefault(_transitionEnd);
|
|
128
128
|
|
|
129
|
-
var
|
|
129
|
+
var _transitionProperty = __webpack_require__(12);
|
|
130
|
+
|
|
131
|
+
var _transitionProperty2 = _interopRequireDefault(_transitionProperty);
|
|
132
|
+
|
|
133
|
+
var _getCurrentUrl = __webpack_require__(13);
|
|
130
134
|
|
|
131
135
|
var _getCurrentUrl2 = _interopRequireDefault(_getCurrentUrl);
|
|
132
136
|
|
|
133
|
-
var
|
|
137
|
+
var _normalizeUrl = __webpack_require__(14);
|
|
138
|
+
|
|
139
|
+
var _normalizeUrl2 = _interopRequireDefault(_normalizeUrl);
|
|
140
|
+
|
|
141
|
+
var _markSwupElements = __webpack_require__(15);
|
|
134
142
|
|
|
135
143
|
var _markSwupElements2 = _interopRequireDefault(_markSwupElements);
|
|
136
144
|
|
|
137
|
-
var _Link = __webpack_require__(
|
|
145
|
+
var _Link = __webpack_require__(2);
|
|
138
146
|
|
|
139
147
|
var _Link2 = _interopRequireDefault(_Link);
|
|
140
148
|
|
|
149
|
+
var _cleanupAnimationClasses = __webpack_require__(16);
|
|
150
|
+
|
|
151
|
+
var _cleanupAnimationClasses2 = _interopRequireDefault(_cleanupAnimationClasses);
|
|
152
|
+
|
|
141
153
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
142
154
|
|
|
143
155
|
var classify = exports.classify = _classify2.default;
|
|
@@ -145,9 +157,12 @@ var createHistoryRecord = exports.createHistoryRecord = _createHistoryRecord2.de
|
|
|
145
157
|
var getDataFromHtml = exports.getDataFromHtml = _getDataFromHtml2.default;
|
|
146
158
|
var fetch = exports.fetch = _fetch2.default;
|
|
147
159
|
var transitionEnd = exports.transitionEnd = _transitionEnd2.default;
|
|
160
|
+
var transitionProperty = exports.transitionProperty = _transitionProperty2.default;
|
|
148
161
|
var getCurrentUrl = exports.getCurrentUrl = _getCurrentUrl2.default;
|
|
162
|
+
var normalizeUrl = exports.normalizeUrl = _normalizeUrl2.default;
|
|
149
163
|
var markSwupElements = exports.markSwupElements = _markSwupElements2.default;
|
|
150
164
|
var Link = exports.Link = _Link2.default;
|
|
165
|
+
var cleanupAnimationClasses = exports.cleanupAnimationClasses = _cleanupAnimationClasses2.default;
|
|
151
166
|
|
|
152
167
|
/***/ }),
|
|
153
168
|
/* 1 */
|
|
@@ -179,6 +194,14 @@ var queryAll = exports.queryAll = function queryAll(selector) {
|
|
|
179
194
|
return Array.prototype.slice.call(context.querySelectorAll(selector));
|
|
180
195
|
};
|
|
181
196
|
|
|
197
|
+
var escapeCssIdentifier = exports.escapeCssIdentifier = function escapeCssIdentifier(ident) {
|
|
198
|
+
if (window.CSS && window.CSS.escape) {
|
|
199
|
+
return CSS.escape(ident);
|
|
200
|
+
} else {
|
|
201
|
+
return ident;
|
|
202
|
+
}
|
|
203
|
+
};
|
|
204
|
+
|
|
182
205
|
/***/ }),
|
|
183
206
|
/* 2 */
|
|
184
207
|
/***/ (function(module, exports, __webpack_require__) {
|
|
@@ -186,7 +209,69 @@ var queryAll = exports.queryAll = function queryAll(selector) {
|
|
|
186
209
|
"use strict";
|
|
187
210
|
|
|
188
211
|
|
|
189
|
-
|
|
212
|
+
Object.defineProperty(exports, "__esModule", {
|
|
213
|
+
value: true
|
|
214
|
+
});
|
|
215
|
+
|
|
216
|
+
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
|
217
|
+
|
|
218
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
219
|
+
|
|
220
|
+
var Link = function () {
|
|
221
|
+
function Link(elementOrUrl) {
|
|
222
|
+
_classCallCheck(this, Link);
|
|
223
|
+
|
|
224
|
+
if (elementOrUrl instanceof Element || elementOrUrl instanceof SVGElement) {
|
|
225
|
+
this.link = elementOrUrl;
|
|
226
|
+
} else {
|
|
227
|
+
this.link = document.createElement('a');
|
|
228
|
+
this.link.href = elementOrUrl;
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
_createClass(Link, [{
|
|
233
|
+
key: 'getPath',
|
|
234
|
+
value: function getPath() {
|
|
235
|
+
var path = this.link.pathname;
|
|
236
|
+
if (path[0] !== '/') {
|
|
237
|
+
path = '/' + path;
|
|
238
|
+
}
|
|
239
|
+
return path;
|
|
240
|
+
}
|
|
241
|
+
}, {
|
|
242
|
+
key: 'getAddress',
|
|
243
|
+
value: function getAddress() {
|
|
244
|
+
var path = this.link.pathname + this.link.search;
|
|
245
|
+
|
|
246
|
+
if (this.link.getAttribute('xlink:href')) {
|
|
247
|
+
path = this.link.getAttribute('xlink:href');
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
if (path[0] !== '/') {
|
|
251
|
+
path = '/' + path;
|
|
252
|
+
}
|
|
253
|
+
return path;
|
|
254
|
+
}
|
|
255
|
+
}, {
|
|
256
|
+
key: 'getHash',
|
|
257
|
+
value: function getHash() {
|
|
258
|
+
return this.link.hash;
|
|
259
|
+
}
|
|
260
|
+
}]);
|
|
261
|
+
|
|
262
|
+
return Link;
|
|
263
|
+
}();
|
|
264
|
+
|
|
265
|
+
exports.default = Link;
|
|
266
|
+
|
|
267
|
+
/***/ }),
|
|
268
|
+
/* 3 */
|
|
269
|
+
/***/ (function(module, exports, __webpack_require__) {
|
|
270
|
+
|
|
271
|
+
"use strict";
|
|
272
|
+
|
|
273
|
+
|
|
274
|
+
var _index = __webpack_require__(4);
|
|
190
275
|
|
|
191
276
|
var _index2 = _interopRequireDefault(_index);
|
|
192
277
|
|
|
@@ -195,7 +280,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
195
280
|
module.exports = _index2.default; // this is here for webpack to expose Swup as window.Swup
|
|
196
281
|
|
|
197
282
|
/***/ }),
|
|
198
|
-
/*
|
|
283
|
+
/* 4 */
|
|
199
284
|
/***/ (function(module, exports, __webpack_require__) {
|
|
200
285
|
|
|
201
286
|
"use strict";
|
|
@@ -212,47 +297,51 @@ var _createClass = function () { function defineProperties(target, props) { for
|
|
|
212
297
|
// modules
|
|
213
298
|
|
|
214
299
|
|
|
215
|
-
var _delegateIt = __webpack_require__(
|
|
300
|
+
var _delegateIt = __webpack_require__(5);
|
|
216
301
|
|
|
217
302
|
var _delegateIt2 = _interopRequireDefault(_delegateIt);
|
|
218
303
|
|
|
219
|
-
var _Cache = __webpack_require__(
|
|
304
|
+
var _Cache = __webpack_require__(6);
|
|
220
305
|
|
|
221
306
|
var _Cache2 = _interopRequireDefault(_Cache);
|
|
222
307
|
|
|
223
|
-
var _loadPage = __webpack_require__(
|
|
308
|
+
var _loadPage = __webpack_require__(17);
|
|
224
309
|
|
|
225
310
|
var _loadPage2 = _interopRequireDefault(_loadPage);
|
|
226
311
|
|
|
227
|
-
var _renderPage = __webpack_require__(
|
|
312
|
+
var _renderPage = __webpack_require__(18);
|
|
228
313
|
|
|
229
314
|
var _renderPage2 = _interopRequireDefault(_renderPage);
|
|
230
315
|
|
|
231
|
-
var _triggerEvent = __webpack_require__(
|
|
316
|
+
var _triggerEvent = __webpack_require__(19);
|
|
232
317
|
|
|
233
318
|
var _triggerEvent2 = _interopRequireDefault(_triggerEvent);
|
|
234
319
|
|
|
235
|
-
var _on = __webpack_require__(
|
|
320
|
+
var _on = __webpack_require__(20);
|
|
236
321
|
|
|
237
322
|
var _on2 = _interopRequireDefault(_on);
|
|
238
323
|
|
|
239
|
-
var _off = __webpack_require__(
|
|
324
|
+
var _off = __webpack_require__(21);
|
|
240
325
|
|
|
241
326
|
var _off2 = _interopRequireDefault(_off);
|
|
242
327
|
|
|
243
|
-
var _updateTransition = __webpack_require__(
|
|
328
|
+
var _updateTransition = __webpack_require__(22);
|
|
244
329
|
|
|
245
330
|
var _updateTransition2 = _interopRequireDefault(_updateTransition);
|
|
246
331
|
|
|
247
|
-
var
|
|
332
|
+
var _getAnchorElement = __webpack_require__(23);
|
|
333
|
+
|
|
334
|
+
var _getAnchorElement2 = _interopRequireDefault(_getAnchorElement);
|
|
335
|
+
|
|
336
|
+
var _getAnimationPromises = __webpack_require__(24);
|
|
248
337
|
|
|
249
338
|
var _getAnimationPromises2 = _interopRequireDefault(_getAnimationPromises);
|
|
250
339
|
|
|
251
|
-
var _getPageData = __webpack_require__(
|
|
340
|
+
var _getPageData = __webpack_require__(25);
|
|
252
341
|
|
|
253
342
|
var _getPageData2 = _interopRequireDefault(_getPageData);
|
|
254
343
|
|
|
255
|
-
var _plugins = __webpack_require__(
|
|
344
|
+
var _plugins = __webpack_require__(26);
|
|
256
345
|
|
|
257
346
|
var _utils = __webpack_require__(1);
|
|
258
347
|
|
|
@@ -310,7 +399,7 @@ var Swup = function () {
|
|
|
310
399
|
willReplaceContent: []
|
|
311
400
|
};
|
|
312
401
|
|
|
313
|
-
// variable for
|
|
402
|
+
// variable for anchor to scroll to after render
|
|
314
403
|
this.scrollToElement = null;
|
|
315
404
|
// variable for promise used for preload, so no new loading of the same page starts while page is loading
|
|
316
405
|
this.preloadPromise = null;
|
|
@@ -336,10 +425,13 @@ var Swup = function () {
|
|
|
336
425
|
this.updateTransition = _updateTransition2.default;
|
|
337
426
|
this.getAnimationPromises = _getAnimationPromises2.default;
|
|
338
427
|
this.getPageData = _getPageData2.default;
|
|
428
|
+
this.getAnchorElement = _getAnchorElement2.default;
|
|
339
429
|
this.log = function () {}; // here so it can be used by plugins
|
|
340
430
|
this.use = _plugins.use;
|
|
341
431
|
this.unuse = _plugins.unuse;
|
|
342
432
|
this.findPlugin = _plugins.findPlugin;
|
|
433
|
+
this.getCurrentUrl = _helpers.getCurrentUrl;
|
|
434
|
+
this.cleanupAnimationClasses = _helpers.cleanupAnimationClasses;
|
|
343
435
|
|
|
344
436
|
// enable swup
|
|
345
437
|
this.enable();
|
|
@@ -361,9 +453,9 @@ var Swup = function () {
|
|
|
361
453
|
window.addEventListener('popstate', this.boundPopStateHandler);
|
|
362
454
|
|
|
363
455
|
// initial save to cache
|
|
364
|
-
var page = (0, _helpers.getDataFromHtml)(document.documentElement.outerHTML, this.options.containers);
|
|
365
|
-
page.url = page.responseURL = (0, _helpers.getCurrentUrl)();
|
|
366
456
|
if (this.options.cache) {
|
|
457
|
+
var page = (0, _helpers.getDataFromHtml)(document.documentElement.outerHTML, this.options.containers);
|
|
458
|
+
page.url = page.responseURL = (0, _helpers.getCurrentUrl)();
|
|
367
459
|
this.cache.cacheUrl(page);
|
|
368
460
|
}
|
|
369
461
|
|
|
@@ -439,7 +531,7 @@ var Swup = function () {
|
|
|
439
531
|
if (link.getHash() != '') {
|
|
440
532
|
// link to the same URL with hash
|
|
441
533
|
this.triggerEvent('samePageWithHash', event);
|
|
442
|
-
var element =
|
|
534
|
+
var element = (0, _getAnchorElement2.default)(link.getHash());
|
|
443
535
|
if (element != null) {
|
|
444
536
|
history.replaceState({
|
|
445
537
|
url: link.getAddress() + link.getHash(),
|
|
@@ -483,6 +575,12 @@ var Swup = function () {
|
|
|
483
575
|
event.preventDefault();
|
|
484
576
|
}
|
|
485
577
|
this.triggerEvent('popState', event);
|
|
578
|
+
|
|
579
|
+
if (!this.options.animateHistoryBrowsing) {
|
|
580
|
+
document.documentElement.classList.remove('is-animating');
|
|
581
|
+
(0, _helpers.cleanupAnimationClasses)();
|
|
582
|
+
}
|
|
583
|
+
|
|
486
584
|
this.loadPage({ url: link.getAddress() }, event);
|
|
487
585
|
}
|
|
488
586
|
}]);
|
|
@@ -493,7 +591,7 @@ var Swup = function () {
|
|
|
493
591
|
exports.default = Swup;
|
|
494
592
|
|
|
495
593
|
/***/ }),
|
|
496
|
-
/*
|
|
594
|
+
/* 5 */
|
|
497
595
|
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
498
596
|
|
|
499
597
|
"use strict";
|
|
@@ -586,7 +684,7 @@ function delegate(base, selector, type, callback, options) {
|
|
|
586
684
|
|
|
587
685
|
|
|
588
686
|
/***/ }),
|
|
589
|
-
/*
|
|
687
|
+
/* 6 */
|
|
590
688
|
/***/ (function(module, exports, __webpack_require__) {
|
|
591
689
|
|
|
592
690
|
"use strict";
|
|
@@ -595,9 +693,12 @@ function delegate(base, selector, type, callback, options) {
|
|
|
595
693
|
Object.defineProperty(exports, "__esModule", {
|
|
596
694
|
value: true
|
|
597
695
|
});
|
|
696
|
+
exports.Cache = undefined;
|
|
598
697
|
|
|
599
698
|
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
|
600
699
|
|
|
700
|
+
var _helpers = __webpack_require__(0);
|
|
701
|
+
|
|
601
702
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
602
703
|
|
|
603
704
|
var Cache = exports.Cache = function () {
|
|
@@ -611,6 +712,7 @@ var Cache = exports.Cache = function () {
|
|
|
611
712
|
_createClass(Cache, [{
|
|
612
713
|
key: 'cacheUrl',
|
|
613
714
|
value: function cacheUrl(page) {
|
|
715
|
+
page.url = (0, _helpers.normalizeUrl)(page.url);
|
|
614
716
|
if (page.url in this.pages === false) {
|
|
615
717
|
this.pages[page.url] = page;
|
|
616
718
|
}
|
|
@@ -620,16 +722,18 @@ var Cache = exports.Cache = function () {
|
|
|
620
722
|
}, {
|
|
621
723
|
key: 'getPage',
|
|
622
724
|
value: function getPage(url) {
|
|
725
|
+
url = (0, _helpers.normalizeUrl)(url);
|
|
623
726
|
return this.pages[url];
|
|
624
727
|
}
|
|
625
728
|
}, {
|
|
626
729
|
key: 'getCurrentPage',
|
|
627
730
|
value: function getCurrentPage() {
|
|
628
|
-
return this.getPage(
|
|
731
|
+
return this.getPage((0, _helpers.getCurrentUrl)());
|
|
629
732
|
}
|
|
630
733
|
}, {
|
|
631
734
|
key: 'exists',
|
|
632
735
|
value: function exists(url) {
|
|
736
|
+
url = (0, _helpers.normalizeUrl)(url);
|
|
633
737
|
return url in this.pages;
|
|
634
738
|
}
|
|
635
739
|
}, {
|
|
@@ -651,130 +755,6 @@ var Cache = exports.Cache = function () {
|
|
|
651
755
|
|
|
652
756
|
exports.default = Cache;
|
|
653
757
|
|
|
654
|
-
/***/ }),
|
|
655
|
-
/* 6 */
|
|
656
|
-
/***/ (function(module, exports, __webpack_require__) {
|
|
657
|
-
|
|
658
|
-
"use strict";
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
Object.defineProperty(exports, "__esModule", {
|
|
662
|
-
value: true
|
|
663
|
-
});
|
|
664
|
-
|
|
665
|
-
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
|
|
666
|
-
|
|
667
|
-
var _helpers = __webpack_require__(0);
|
|
668
|
-
|
|
669
|
-
var loadPage = function loadPage(data, popstate) {
|
|
670
|
-
var _this = this;
|
|
671
|
-
|
|
672
|
-
// create array for storing animation promises
|
|
673
|
-
var animationPromises = [],
|
|
674
|
-
xhrPromise = void 0;
|
|
675
|
-
var animateOut = function animateOut() {
|
|
676
|
-
_this.triggerEvent('animationOutStart');
|
|
677
|
-
|
|
678
|
-
// handle classes
|
|
679
|
-
document.documentElement.classList.add('is-changing');
|
|
680
|
-
document.documentElement.classList.add('is-leaving');
|
|
681
|
-
document.documentElement.classList.add('is-animating');
|
|
682
|
-
if (popstate) {
|
|
683
|
-
document.documentElement.classList.add('is-popstate');
|
|
684
|
-
}
|
|
685
|
-
document.documentElement.classList.add('to-' + (0, _helpers.classify)(data.url));
|
|
686
|
-
|
|
687
|
-
// animation promise stuff
|
|
688
|
-
animationPromises = _this.getAnimationPromises('out');
|
|
689
|
-
Promise.all(animationPromises).then(function () {
|
|
690
|
-
_this.triggerEvent('animationOutDone');
|
|
691
|
-
});
|
|
692
|
-
|
|
693
|
-
// create history record if this is not a popstate call
|
|
694
|
-
if (!popstate) {
|
|
695
|
-
// create pop element with or without anchor
|
|
696
|
-
var state = void 0;
|
|
697
|
-
if (_this.scrollToElement != null) {
|
|
698
|
-
state = data.url + _this.scrollToElement;
|
|
699
|
-
} else {
|
|
700
|
-
state = data.url;
|
|
701
|
-
}
|
|
702
|
-
|
|
703
|
-
(0, _helpers.createHistoryRecord)(state);
|
|
704
|
-
}
|
|
705
|
-
};
|
|
706
|
-
|
|
707
|
-
this.triggerEvent('transitionStart', popstate);
|
|
708
|
-
|
|
709
|
-
// set transition object
|
|
710
|
-
if (data.customTransition != null) {
|
|
711
|
-
this.updateTransition(window.location.pathname, data.url, data.customTransition);
|
|
712
|
-
document.documentElement.classList.add('to-' + (0, _helpers.classify)(data.customTransition));
|
|
713
|
-
} else {
|
|
714
|
-
this.updateTransition(window.location.pathname, data.url);
|
|
715
|
-
}
|
|
716
|
-
|
|
717
|
-
// start/skip animation
|
|
718
|
-
if (!popstate || this.options.animateHistoryBrowsing) {
|
|
719
|
-
animateOut();
|
|
720
|
-
} else {
|
|
721
|
-
this.triggerEvent('animationSkipped');
|
|
722
|
-
}
|
|
723
|
-
|
|
724
|
-
// start/skip loading of page
|
|
725
|
-
if (this.cache.exists(data.url)) {
|
|
726
|
-
xhrPromise = new Promise(function (resolve) {
|
|
727
|
-
resolve();
|
|
728
|
-
});
|
|
729
|
-
this.triggerEvent('pageRetrievedFromCache');
|
|
730
|
-
} else {
|
|
731
|
-
if (!this.preloadPromise || this.preloadPromise.route != data.url) {
|
|
732
|
-
xhrPromise = new Promise(function (resolve, reject) {
|
|
733
|
-
(0, _helpers.fetch)(_extends({}, data, { headers: _this.options.requestHeaders }), function (response) {
|
|
734
|
-
if (response.status === 500) {
|
|
735
|
-
_this.triggerEvent('serverError');
|
|
736
|
-
reject(data.url);
|
|
737
|
-
return;
|
|
738
|
-
} else {
|
|
739
|
-
// get json data
|
|
740
|
-
var page = _this.getPageData(response);
|
|
741
|
-
if (page != null) {
|
|
742
|
-
page.url = data.url;
|
|
743
|
-
} else {
|
|
744
|
-
reject(data.url);
|
|
745
|
-
return;
|
|
746
|
-
}
|
|
747
|
-
// render page
|
|
748
|
-
_this.cache.cacheUrl(page);
|
|
749
|
-
_this.triggerEvent('pageLoaded');
|
|
750
|
-
}
|
|
751
|
-
resolve();
|
|
752
|
-
});
|
|
753
|
-
});
|
|
754
|
-
} else {
|
|
755
|
-
xhrPromise = this.preloadPromise;
|
|
756
|
-
}
|
|
757
|
-
}
|
|
758
|
-
|
|
759
|
-
// when everything is ready, handle the outcome
|
|
760
|
-
Promise.all(animationPromises.concat([xhrPromise])).then(function () {
|
|
761
|
-
// render page
|
|
762
|
-
_this.renderPage(_this.cache.getPage(data.url), popstate);
|
|
763
|
-
_this.preloadPromise = null;
|
|
764
|
-
}).catch(function (errorUrl) {
|
|
765
|
-
// rewrite the skipPopStateHandling function to redirect manually when the history.go is processed
|
|
766
|
-
_this.options.skipPopStateHandling = function () {
|
|
767
|
-
window.location = errorUrl;
|
|
768
|
-
return true;
|
|
769
|
-
};
|
|
770
|
-
|
|
771
|
-
// go back to the actual page were still at
|
|
772
|
-
window.history.go(-1);
|
|
773
|
-
});
|
|
774
|
-
};
|
|
775
|
-
|
|
776
|
-
exports.default = loadPage;
|
|
777
|
-
|
|
778
758
|
/***/ }),
|
|
779
759
|
/* 7 */
|
|
780
760
|
/***/ (function(module, exports, __webpack_require__) {
|
|
@@ -830,8 +810,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
830
810
|
value: true
|
|
831
811
|
});
|
|
832
812
|
|
|
833
|
-
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
|
|
834
|
-
|
|
835
813
|
var _utils = __webpack_require__(1);
|
|
836
814
|
|
|
837
815
|
var getDataFromHtml = function getDataFromHtml(html, containers) {
|
|
@@ -839,25 +817,20 @@ var getDataFromHtml = function getDataFromHtml(html, containers) {
|
|
|
839
817
|
fakeDom.innerHTML = html;
|
|
840
818
|
var blocks = [];
|
|
841
819
|
|
|
842
|
-
|
|
843
|
-
if (
|
|
844
|
-
|
|
845
|
-
return
|
|
846
|
-
v: null
|
|
847
|
-
};
|
|
820
|
+
containers.forEach(function (selector) {
|
|
821
|
+
if ((0, _utils.query)(selector, fakeDom) == null) {
|
|
822
|
+
console.error('Container ' + selector + ' not found on page.');
|
|
823
|
+
return null;
|
|
848
824
|
} else {
|
|
849
|
-
(0, _utils.queryAll)(
|
|
850
|
-
|
|
851
|
-
|
|
825
|
+
if ((0, _utils.queryAll)(selector).length !== (0, _utils.queryAll)(selector, fakeDom).length) {
|
|
826
|
+
console.warn('Mismatched number of containers found on new page.');
|
|
827
|
+
}
|
|
828
|
+
(0, _utils.queryAll)(selector).forEach(function (item, index) {
|
|
829
|
+
(0, _utils.queryAll)(selector, fakeDom)[index].setAttribute('data-swup', blocks.length);
|
|
830
|
+
blocks.push((0, _utils.queryAll)(selector, fakeDom)[index].outerHTML);
|
|
852
831
|
});
|
|
853
832
|
}
|
|
854
|
-
};
|
|
855
|
-
|
|
856
|
-
for (var i = 0; i < containers.length; i++) {
|
|
857
|
-
var _ret = _loop(i);
|
|
858
|
-
|
|
859
|
-
if ((typeof _ret === 'undefined' ? 'undefined' : _typeof(_ret)) === "object") return _ret.v;
|
|
860
|
-
}
|
|
833
|
+
});
|
|
861
834
|
|
|
862
835
|
var json = {
|
|
863
836
|
title: fakeDom.querySelector('title').innerText,
|
|
@@ -933,22 +906,11 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
933
906
|
value: true
|
|
934
907
|
});
|
|
935
908
|
var transitionEnd = function transitionEnd() {
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
MozTransition: 'transitionend',
|
|
941
|
-
OTransition: 'oTransitionEnd otransitionend',
|
|
942
|
-
transition: 'transitionend'
|
|
943
|
-
};
|
|
944
|
-
|
|
945
|
-
for (var name in transEndEventNames) {
|
|
946
|
-
if (el.style[name] !== undefined) {
|
|
947
|
-
return transEndEventNames[name];
|
|
948
|
-
}
|
|
909
|
+
if (window.ontransitionend === undefined && window.onwebkittransitionend !== undefined) {
|
|
910
|
+
return 'webkitTransitionEnd';
|
|
911
|
+
} else {
|
|
912
|
+
return 'transitionend';
|
|
949
913
|
}
|
|
950
|
-
|
|
951
|
-
return false;
|
|
952
914
|
};
|
|
953
915
|
|
|
954
916
|
exports.default = transitionEnd;
|
|
@@ -960,6 +922,26 @@ exports.default = transitionEnd;
|
|
|
960
922
|
"use strict";
|
|
961
923
|
|
|
962
924
|
|
|
925
|
+
Object.defineProperty(exports, "__esModule", {
|
|
926
|
+
value: true
|
|
927
|
+
});
|
|
928
|
+
var transitionProperty = function transitionProperty() {
|
|
929
|
+
if (window.ontransitionend === undefined && window.onwebkittransitionend !== undefined) {
|
|
930
|
+
return 'WebkitTransition';
|
|
931
|
+
} else {
|
|
932
|
+
return 'transition';
|
|
933
|
+
}
|
|
934
|
+
};
|
|
935
|
+
|
|
936
|
+
exports.default = transitionProperty;
|
|
937
|
+
|
|
938
|
+
/***/ }),
|
|
939
|
+
/* 13 */
|
|
940
|
+
/***/ (function(module, exports, __webpack_require__) {
|
|
941
|
+
|
|
942
|
+
"use strict";
|
|
943
|
+
|
|
944
|
+
|
|
963
945
|
Object.defineProperty(exports, "__esModule", {
|
|
964
946
|
value: true
|
|
965
947
|
});
|
|
@@ -970,7 +952,30 @@ var getCurrentUrl = function getCurrentUrl() {
|
|
|
970
952
|
exports.default = getCurrentUrl;
|
|
971
953
|
|
|
972
954
|
/***/ }),
|
|
973
|
-
/*
|
|
955
|
+
/* 14 */
|
|
956
|
+
/***/ (function(module, exports, __webpack_require__) {
|
|
957
|
+
|
|
958
|
+
"use strict";
|
|
959
|
+
|
|
960
|
+
|
|
961
|
+
Object.defineProperty(exports, "__esModule", {
|
|
962
|
+
value: true
|
|
963
|
+
});
|
|
964
|
+
|
|
965
|
+
var _Link = __webpack_require__(2);
|
|
966
|
+
|
|
967
|
+
var _Link2 = _interopRequireDefault(_Link);
|
|
968
|
+
|
|
969
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
970
|
+
|
|
971
|
+
var normalizeUrl = function normalizeUrl(url) {
|
|
972
|
+
return new _Link2.default(url).getAddress();
|
|
973
|
+
};
|
|
974
|
+
|
|
975
|
+
exports.default = normalizeUrl;
|
|
976
|
+
|
|
977
|
+
/***/ }),
|
|
978
|
+
/* 15 */
|
|
974
979
|
/***/ (function(module, exports, __webpack_require__) {
|
|
975
980
|
|
|
976
981
|
"use strict";
|
|
@@ -985,26 +990,46 @@ var _utils = __webpack_require__(1);
|
|
|
985
990
|
var markSwupElements = function markSwupElements(element, containers) {
|
|
986
991
|
var blocks = 0;
|
|
987
992
|
|
|
988
|
-
|
|
989
|
-
if (
|
|
990
|
-
console.
|
|
993
|
+
containers.forEach(function (selector) {
|
|
994
|
+
if ((0, _utils.query)(selector, element) == null) {
|
|
995
|
+
console.error('Container ' + selector + ' not found on page.');
|
|
991
996
|
} else {
|
|
992
|
-
(0, _utils.queryAll)(
|
|
993
|
-
(0, _utils.queryAll)(
|
|
997
|
+
(0, _utils.queryAll)(selector).forEach(function (item, index) {
|
|
998
|
+
(0, _utils.queryAll)(selector, element)[index].setAttribute('data-swup', blocks);
|
|
994
999
|
blocks++;
|
|
995
1000
|
});
|
|
996
1001
|
}
|
|
997
|
-
};
|
|
998
|
-
|
|
999
|
-
for (var i = 0; i < containers.length; i++) {
|
|
1000
|
-
_loop(i);
|
|
1001
|
-
}
|
|
1002
|
+
});
|
|
1002
1003
|
};
|
|
1003
1004
|
|
|
1004
1005
|
exports.default = markSwupElements;
|
|
1005
1006
|
|
|
1006
1007
|
/***/ }),
|
|
1007
|
-
/*
|
|
1008
|
+
/* 16 */
|
|
1009
|
+
/***/ (function(module, exports, __webpack_require__) {
|
|
1010
|
+
|
|
1011
|
+
"use strict";
|
|
1012
|
+
|
|
1013
|
+
|
|
1014
|
+
Object.defineProperty(exports, "__esModule", {
|
|
1015
|
+
value: true
|
|
1016
|
+
});
|
|
1017
|
+
var cleanupAnimationClasses = function cleanupAnimationClasses() {
|
|
1018
|
+
document.documentElement.className.split(' ').forEach(function (classItem) {
|
|
1019
|
+
if (
|
|
1020
|
+
// remove "to-{page}" classes
|
|
1021
|
+
new RegExp('^to-').test(classItem) ||
|
|
1022
|
+
// remove all other classes
|
|
1023
|
+
classItem === 'is-changing' || classItem === 'is-rendering' || classItem === 'is-popstate') {
|
|
1024
|
+
document.documentElement.classList.remove(classItem);
|
|
1025
|
+
}
|
|
1026
|
+
});
|
|
1027
|
+
};
|
|
1028
|
+
|
|
1029
|
+
exports.default = cleanupAnimationClasses;
|
|
1030
|
+
|
|
1031
|
+
/***/ }),
|
|
1032
|
+
/* 17 */
|
|
1008
1033
|
/***/ (function(module, exports, __webpack_require__) {
|
|
1009
1034
|
|
|
1010
1035
|
"use strict";
|
|
@@ -1014,59 +1039,121 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
1014
1039
|
value: true
|
|
1015
1040
|
});
|
|
1016
1041
|
|
|
1017
|
-
var
|
|
1042
|
+
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
|
|
1018
1043
|
|
|
1019
|
-
|
|
1044
|
+
var _helpers = __webpack_require__(0);
|
|
1020
1045
|
|
|
1021
|
-
var
|
|
1022
|
-
|
|
1023
|
-
_classCallCheck(this, Link);
|
|
1046
|
+
var loadPage = function loadPage(data, popstate) {
|
|
1047
|
+
var _this = this;
|
|
1024
1048
|
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
}
|
|
1031
|
-
}
|
|
1049
|
+
// create array for storing animation promises
|
|
1050
|
+
var animationPromises = [],
|
|
1051
|
+
xhrPromise = void 0;
|
|
1052
|
+
var animateOut = function animateOut() {
|
|
1053
|
+
_this.triggerEvent('animationOutStart');
|
|
1032
1054
|
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
}
|
|
1040
|
-
return path;
|
|
1055
|
+
// handle classes
|
|
1056
|
+
document.documentElement.classList.add('is-changing');
|
|
1057
|
+
document.documentElement.classList.add('is-leaving');
|
|
1058
|
+
document.documentElement.classList.add('is-animating');
|
|
1059
|
+
if (popstate) {
|
|
1060
|
+
document.documentElement.classList.add('is-popstate');
|
|
1041
1061
|
}
|
|
1042
|
-
|
|
1043
|
-
key: 'getAddress',
|
|
1044
|
-
value: function getAddress() {
|
|
1045
|
-
var path = this.link.pathname + this.link.search;
|
|
1062
|
+
document.documentElement.classList.add('to-' + (0, _helpers.classify)(data.url));
|
|
1046
1063
|
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1064
|
+
// animation promise stuff
|
|
1065
|
+
animationPromises = _this.getAnimationPromises('out');
|
|
1066
|
+
Promise.all(animationPromises).then(function () {
|
|
1067
|
+
_this.triggerEvent('animationOutDone');
|
|
1068
|
+
});
|
|
1050
1069
|
|
|
1051
|
-
|
|
1052
|
-
|
|
1070
|
+
// create history record if this is not a popstate call
|
|
1071
|
+
if (!popstate) {
|
|
1072
|
+
// create pop element with or without anchor
|
|
1073
|
+
var state = void 0;
|
|
1074
|
+
if (_this.scrollToElement != null) {
|
|
1075
|
+
state = data.url + _this.scrollToElement;
|
|
1076
|
+
} else {
|
|
1077
|
+
state = data.url;
|
|
1053
1078
|
}
|
|
1054
|
-
|
|
1079
|
+
|
|
1080
|
+
(0, _helpers.createHistoryRecord)(state);
|
|
1055
1081
|
}
|
|
1056
|
-
}
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1082
|
+
};
|
|
1083
|
+
|
|
1084
|
+
this.triggerEvent('transitionStart', popstate);
|
|
1085
|
+
|
|
1086
|
+
// set transition object
|
|
1087
|
+
if (data.customTransition != null) {
|
|
1088
|
+
this.updateTransition(window.location.pathname, data.url, data.customTransition);
|
|
1089
|
+
document.documentElement.classList.add('to-' + (0, _helpers.classify)(data.customTransition));
|
|
1090
|
+
} else {
|
|
1091
|
+
this.updateTransition(window.location.pathname, data.url);
|
|
1092
|
+
}
|
|
1093
|
+
|
|
1094
|
+
// start/skip animation
|
|
1095
|
+
if (!popstate || this.options.animateHistoryBrowsing) {
|
|
1096
|
+
animateOut();
|
|
1097
|
+
} else {
|
|
1098
|
+
this.triggerEvent('animationSkipped');
|
|
1099
|
+
}
|
|
1100
|
+
|
|
1101
|
+
// start/skip loading of page
|
|
1102
|
+
if (this.cache.exists(data.url)) {
|
|
1103
|
+
xhrPromise = new Promise(function (resolve) {
|
|
1104
|
+
resolve();
|
|
1105
|
+
});
|
|
1106
|
+
this.triggerEvent('pageRetrievedFromCache');
|
|
1107
|
+
} else {
|
|
1108
|
+
if (!this.preloadPromise || this.preloadPromise.route != data.url) {
|
|
1109
|
+
xhrPromise = new Promise(function (resolve, reject) {
|
|
1110
|
+
(0, _helpers.fetch)(_extends({}, data, { headers: _this.options.requestHeaders }), function (response) {
|
|
1111
|
+
if (response.status === 500) {
|
|
1112
|
+
_this.triggerEvent('serverError');
|
|
1113
|
+
reject(data.url);
|
|
1114
|
+
return;
|
|
1115
|
+
} else {
|
|
1116
|
+
// get json data
|
|
1117
|
+
var page = _this.getPageData(response);
|
|
1118
|
+
if (page != null) {
|
|
1119
|
+
page.url = data.url;
|
|
1120
|
+
} else {
|
|
1121
|
+
reject(data.url);
|
|
1122
|
+
return;
|
|
1123
|
+
}
|
|
1124
|
+
// render page
|
|
1125
|
+
_this.cache.cacheUrl(page);
|
|
1126
|
+
_this.triggerEvent('pageLoaded');
|
|
1127
|
+
}
|
|
1128
|
+
resolve();
|
|
1129
|
+
});
|
|
1130
|
+
});
|
|
1131
|
+
} else {
|
|
1132
|
+
xhrPromise = this.preloadPromise;
|
|
1060
1133
|
}
|
|
1061
|
-
}
|
|
1134
|
+
}
|
|
1062
1135
|
|
|
1063
|
-
|
|
1064
|
-
|
|
1136
|
+
// when everything is ready, handle the outcome
|
|
1137
|
+
Promise.all(animationPromises.concat([xhrPromise])).then(function () {
|
|
1138
|
+
// render page
|
|
1139
|
+
_this.renderPage(_this.cache.getPage(data.url), popstate);
|
|
1140
|
+
_this.preloadPromise = null;
|
|
1141
|
+
}).catch(function (errorUrl) {
|
|
1142
|
+
// rewrite the skipPopStateHandling function to redirect manually when the history.go is processed
|
|
1143
|
+
_this.options.skipPopStateHandling = function () {
|
|
1144
|
+
window.location = errorUrl;
|
|
1145
|
+
return true;
|
|
1146
|
+
};
|
|
1065
1147
|
|
|
1066
|
-
|
|
1148
|
+
// go back to the actual page were still at
|
|
1149
|
+
window.history.go(-1);
|
|
1150
|
+
});
|
|
1151
|
+
};
|
|
1152
|
+
|
|
1153
|
+
exports.default = loadPage;
|
|
1067
1154
|
|
|
1068
1155
|
/***/ }),
|
|
1069
|
-
/*
|
|
1156
|
+
/* 18 */
|
|
1070
1157
|
/***/ (function(module, exports, __webpack_require__) {
|
|
1071
1158
|
|
|
1072
1159
|
"use strict";
|
|
@@ -1078,8 +1165,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
1078
1165
|
|
|
1079
1166
|
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
|
|
1080
1167
|
|
|
1081
|
-
var _utils = __webpack_require__(1);
|
|
1082
|
-
|
|
1083
1168
|
var _helpers = __webpack_require__(0);
|
|
1084
1169
|
|
|
1085
1170
|
var renderPage = function renderPage(page, popstate) {
|
|
@@ -1087,17 +1172,20 @@ var renderPage = function renderPage(page, popstate) {
|
|
|
1087
1172
|
|
|
1088
1173
|
document.documentElement.classList.remove('is-leaving');
|
|
1089
1174
|
|
|
1175
|
+
var isCurrentPage = this.getCurrentUrl() === page.url;
|
|
1176
|
+
if (!isCurrentPage) return;
|
|
1177
|
+
|
|
1090
1178
|
// replace state in case the url was redirected
|
|
1091
|
-
var
|
|
1092
|
-
if (window.location.pathname !==
|
|
1179
|
+
var url = new _helpers.Link(page.responseURL).getPath();
|
|
1180
|
+
if (window.location.pathname !== url) {
|
|
1093
1181
|
window.history.replaceState({
|
|
1094
|
-
url:
|
|
1182
|
+
url: url,
|
|
1095
1183
|
random: Math.random(),
|
|
1096
1184
|
source: 'swup'
|
|
1097
|
-
}, document.title,
|
|
1185
|
+
}, document.title, url);
|
|
1098
1186
|
|
|
1099
1187
|
// save new record for redirected url
|
|
1100
|
-
this.cache.cacheUrl(_extends({}, page, { url:
|
|
1188
|
+
this.cache.cacheUrl(_extends({}, page, { url: url }));
|
|
1101
1189
|
}
|
|
1102
1190
|
|
|
1103
1191
|
// only add for non-popstate transitions
|
|
@@ -1106,15 +1194,12 @@ var renderPage = function renderPage(page, popstate) {
|
|
|
1106
1194
|
}
|
|
1107
1195
|
|
|
1108
1196
|
this.triggerEvent('willReplaceContent', popstate);
|
|
1109
|
-
|
|
1110
1197
|
// replace blocks
|
|
1111
1198
|
for (var i = 0; i < page.blocks.length; i++) {
|
|
1112
1199
|
document.body.querySelector('[data-swup="' + i + '"]').outerHTML = page.blocks[i];
|
|
1113
1200
|
}
|
|
1114
|
-
|
|
1115
1201
|
// set title
|
|
1116
1202
|
document.title = page.title;
|
|
1117
|
-
|
|
1118
1203
|
this.triggerEvent('contentReplaced', popstate);
|
|
1119
1204
|
this.triggerEvent('pageView', popstate);
|
|
1120
1205
|
|
|
@@ -1137,12 +1222,7 @@ var renderPage = function renderPage(page, popstate) {
|
|
|
1137
1222
|
Promise.all(animationPromises).then(function () {
|
|
1138
1223
|
_this.triggerEvent('animationInDone');
|
|
1139
1224
|
_this.triggerEvent('transitionEnd', popstate);
|
|
1140
|
-
|
|
1141
|
-
document.documentElement.className.split(' ').forEach(function (classItem) {
|
|
1142
|
-
if (new RegExp('^to-').test(classItem) || classItem === 'is-changing' || classItem === 'is-rendering' || classItem === 'is-popstate') {
|
|
1143
|
-
document.documentElement.classList.remove(classItem);
|
|
1144
|
-
}
|
|
1145
|
-
});
|
|
1225
|
+
_this.cleanupAnimationClasses();
|
|
1146
1226
|
});
|
|
1147
1227
|
} else {
|
|
1148
1228
|
this.triggerEvent('transitionEnd', popstate);
|
|
@@ -1155,7 +1235,7 @@ var renderPage = function renderPage(page, popstate) {
|
|
|
1155
1235
|
exports.default = renderPage;
|
|
1156
1236
|
|
|
1157
1237
|
/***/ }),
|
|
1158
|
-
/*
|
|
1238
|
+
/* 19 */
|
|
1159
1239
|
/***/ (function(module, exports, __webpack_require__) {
|
|
1160
1240
|
|
|
1161
1241
|
"use strict";
|
|
@@ -1182,7 +1262,7 @@ var triggerEvent = function triggerEvent(eventName, originalEvent) {
|
|
|
1182
1262
|
exports.default = triggerEvent;
|
|
1183
1263
|
|
|
1184
1264
|
/***/ }),
|
|
1185
|
-
/*
|
|
1265
|
+
/* 20 */
|
|
1186
1266
|
/***/ (function(module, exports, __webpack_require__) {
|
|
1187
1267
|
|
|
1188
1268
|
"use strict";
|
|
@@ -1202,7 +1282,7 @@ var on = function on(event, handler) {
|
|
|
1202
1282
|
exports.default = on;
|
|
1203
1283
|
|
|
1204
1284
|
/***/ }),
|
|
1205
|
-
/*
|
|
1285
|
+
/* 21 */
|
|
1206
1286
|
/***/ (function(module, exports, __webpack_require__) {
|
|
1207
1287
|
|
|
1208
1288
|
"use strict";
|
|
@@ -1242,7 +1322,7 @@ var off = function off(event, handler) {
|
|
|
1242
1322
|
exports.default = off;
|
|
1243
1323
|
|
|
1244
1324
|
/***/ }),
|
|
1245
|
-
/*
|
|
1325
|
+
/* 22 */
|
|
1246
1326
|
/***/ (function(module, exports, __webpack_require__) {
|
|
1247
1327
|
|
|
1248
1328
|
"use strict";
|
|
@@ -1263,7 +1343,38 @@ var updateTransition = function updateTransition(from, to, custom) {
|
|
|
1263
1343
|
exports.default = updateTransition;
|
|
1264
1344
|
|
|
1265
1345
|
/***/ }),
|
|
1266
|
-
/*
|
|
1346
|
+
/* 23 */
|
|
1347
|
+
/***/ (function(module, exports, __webpack_require__) {
|
|
1348
|
+
|
|
1349
|
+
"use strict";
|
|
1350
|
+
|
|
1351
|
+
|
|
1352
|
+
Object.defineProperty(exports, "__esModule", {
|
|
1353
|
+
value: true
|
|
1354
|
+
});
|
|
1355
|
+
|
|
1356
|
+
var _utils = __webpack_require__(1);
|
|
1357
|
+
|
|
1358
|
+
var getAnchorElement = function getAnchorElement(hash) {
|
|
1359
|
+
if (!hash) {
|
|
1360
|
+
return null;
|
|
1361
|
+
}
|
|
1362
|
+
|
|
1363
|
+
if (hash.charAt(0) === '#') {
|
|
1364
|
+
hash = hash.substring(1);
|
|
1365
|
+
}
|
|
1366
|
+
|
|
1367
|
+
hash = decodeURIComponent(hash);
|
|
1368
|
+
hash = (0, _utils.escapeCssIdentifier)(hash);
|
|
1369
|
+
|
|
1370
|
+
// https://html.spec.whatwg.org/#find-a-potential-indicated-element
|
|
1371
|
+
return (0, _utils.query)('#' + hash) || (0, _utils.query)('a[name=\'' + hash + '\']');
|
|
1372
|
+
};
|
|
1373
|
+
|
|
1374
|
+
exports.default = getAnchorElement;
|
|
1375
|
+
|
|
1376
|
+
/***/ }),
|
|
1377
|
+
/* 24 */
|
|
1267
1378
|
/***/ (function(module, exports, __webpack_require__) {
|
|
1268
1379
|
|
|
1269
1380
|
"use strict";
|
|
@@ -1278,9 +1389,24 @@ var _utils = __webpack_require__(1);
|
|
|
1278
1389
|
var _helpers = __webpack_require__(0);
|
|
1279
1390
|
|
|
1280
1391
|
var getAnimationPromises = function getAnimationPromises() {
|
|
1392
|
+
var _this = this;
|
|
1393
|
+
|
|
1281
1394
|
var promises = [];
|
|
1282
|
-
var animatedElements = (0, _utils.queryAll)(this.options.animationSelector);
|
|
1395
|
+
var animatedElements = (0, _utils.queryAll)(this.options.animationSelector, document.body);
|
|
1396
|
+
|
|
1397
|
+
if (!animatedElements.length) {
|
|
1398
|
+
console.error('No animated elements found by selector ' + this.options.animationSelector);
|
|
1399
|
+
return [Promise.resolve()];
|
|
1400
|
+
}
|
|
1401
|
+
|
|
1283
1402
|
animatedElements.forEach(function (element) {
|
|
1403
|
+
var transitionDuration = window.getComputedStyle(element)[(0, _helpers.transitionProperty)() + 'Duration'];
|
|
1404
|
+
// Resolve immediately if no transition defined
|
|
1405
|
+
if (!transitionDuration || transitionDuration == '0s') {
|
|
1406
|
+
console.error('No CSS transition duration defined for element of selector ' + _this.options.animationSelector);
|
|
1407
|
+
promises.push(Promise.resolve());
|
|
1408
|
+
return;
|
|
1409
|
+
}
|
|
1284
1410
|
var promise = new Promise(function (resolve) {
|
|
1285
1411
|
element.addEventListener((0, _helpers.transitionEnd)(), function (event) {
|
|
1286
1412
|
if (element == event.target) {
|
|
@@ -1290,13 +1416,14 @@ var getAnimationPromises = function getAnimationPromises() {
|
|
|
1290
1416
|
});
|
|
1291
1417
|
promises.push(promise);
|
|
1292
1418
|
});
|
|
1419
|
+
|
|
1293
1420
|
return promises;
|
|
1294
1421
|
};
|
|
1295
1422
|
|
|
1296
1423
|
exports.default = getAnimationPromises;
|
|
1297
1424
|
|
|
1298
1425
|
/***/ }),
|
|
1299
|
-
/*
|
|
1426
|
+
/* 25 */
|
|
1300
1427
|
/***/ (function(module, exports, __webpack_require__) {
|
|
1301
1428
|
|
|
1302
1429
|
"use strict";
|
|
@@ -1328,7 +1455,7 @@ var getPageData = function getPageData(request) {
|
|
|
1328
1455
|
exports.default = getPageData;
|
|
1329
1456
|
|
|
1330
1457
|
/***/ }),
|
|
1331
|
-
/*
|
|
1458
|
+
/* 26 */
|
|
1332
1459
|
/***/ (function(module, exports, __webpack_require__) {
|
|
1333
1460
|
|
|
1334
1461
|
"use strict";
|