@ecopages/browser-router 0.2.0-beta.3 → 0.2.0-beta.4
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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ecopages/browser-router",
|
|
3
|
-
"version": "0.2.0-beta.
|
|
3
|
+
"version": "0.2.0-beta.4",
|
|
4
4
|
"description": "Client-side router for Ecopages with view transitions support",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ecopages",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"morphdom": "^2.7.8"
|
|
36
36
|
},
|
|
37
37
|
"peerDependencies": {
|
|
38
|
-
"@ecopages/core": "0.2.0-beta.
|
|
38
|
+
"@ecopages/core": "0.2.0-beta.4"
|
|
39
39
|
},
|
|
40
40
|
"types": "./src/index.d.ts"
|
|
41
41
|
}
|
|
@@ -13,7 +13,6 @@ export declare class EcoRouter {
|
|
|
13
13
|
private started;
|
|
14
14
|
private pendingNavigations;
|
|
15
15
|
private pendingPointerNavigation;
|
|
16
|
-
private pendingHoverNavigation;
|
|
17
16
|
private queuedNavigationHref;
|
|
18
17
|
private domSwapper;
|
|
19
18
|
private scrollManager;
|
|
@@ -23,7 +22,6 @@ export declare class EcoRouter {
|
|
|
23
22
|
private getLinkFromEvent;
|
|
24
23
|
private canInterceptLink;
|
|
25
24
|
private getRecoveredPointerHref;
|
|
26
|
-
private getRecoveredHoverHref;
|
|
27
25
|
private isAnotherNavigationRuntimeActive;
|
|
28
26
|
private getDocumentOwner;
|
|
29
27
|
private adoptDocumentOwner;
|
|
@@ -76,7 +74,6 @@ export declare class EcoRouter {
|
|
|
76
74
|
* Shadow DOM boundaries (Web Components).
|
|
77
75
|
*/
|
|
78
76
|
private handlePointerDown;
|
|
79
|
-
private handleHoverIntent;
|
|
80
77
|
private handleClick;
|
|
81
78
|
/**
|
|
82
79
|
* Handles browser back/forward navigation.
|
package/src/client/eco-router.js
CHANGED
|
@@ -12,7 +12,6 @@ class EcoRouter {
|
|
|
12
12
|
started = false;
|
|
13
13
|
pendingNavigations = 0;
|
|
14
14
|
pendingPointerNavigation = null;
|
|
15
|
-
pendingHoverNavigation = null;
|
|
16
15
|
queuedNavigationHref = null;
|
|
17
16
|
domSwapper;
|
|
18
17
|
scrollManager;
|
|
@@ -36,7 +35,6 @@ class EcoRouter {
|
|
|
36
35
|
});
|
|
37
36
|
}
|
|
38
37
|
this.handleClick = this.handleClick.bind(this);
|
|
39
|
-
this.handleHoverIntent = this.handleHoverIntent.bind(this);
|
|
40
38
|
this.handlePointerDown = this.handlePointerDown.bind(this);
|
|
41
39
|
this.handlePopState = this.handlePopState.bind(this);
|
|
42
40
|
}
|
|
@@ -72,17 +70,6 @@ class EcoRouter {
|
|
|
72
70
|
}
|
|
73
71
|
return href;
|
|
74
72
|
}
|
|
75
|
-
getRecoveredHoverHref() {
|
|
76
|
-
const href = recoverPendingNavigationHref(
|
|
77
|
-
this.pendingHoverNavigation,
|
|
78
|
-
this.pendingNavigations > 0,
|
|
79
|
-
performance.now()
|
|
80
|
-
);
|
|
81
|
-
if (!href) {
|
|
82
|
-
this.pendingHoverNavigation = null;
|
|
83
|
-
}
|
|
84
|
-
return href;
|
|
85
|
-
}
|
|
86
73
|
isAnotherNavigationRuntimeActive() {
|
|
87
74
|
const ownerState = getEcoNavigationRuntime(window).getOwnerState();
|
|
88
75
|
return ownerState.owner !== "none" && ownerState.owner !== "browser-router" && ownerState.canHandleSpaNavigation;
|
|
@@ -195,10 +182,6 @@ class EcoRouter {
|
|
|
195
182
|
return;
|
|
196
183
|
}
|
|
197
184
|
const navigationRuntime = getEcoNavigationRuntime(window);
|
|
198
|
-
document.addEventListener("mouseover", this.handleHoverIntent, true);
|
|
199
|
-
document.addEventListener("pointerover", this.handleHoverIntent, true);
|
|
200
|
-
document.addEventListener("mousemove", this.handleHoverIntent, true);
|
|
201
|
-
document.addEventListener("pointermove", this.handleHoverIntent, true);
|
|
202
185
|
document.addEventListener("pointerdown", this.handlePointerDown, true);
|
|
203
186
|
document.addEventListener("click", this.handleClick, true);
|
|
204
187
|
window.addEventListener("popstate", this.handlePopState);
|
|
@@ -254,10 +237,6 @@ class EcoRouter {
|
|
|
254
237
|
return;
|
|
255
238
|
}
|
|
256
239
|
this.cancelNavigationTransaction();
|
|
257
|
-
document.removeEventListener("mouseover", this.handleHoverIntent, true);
|
|
258
|
-
document.removeEventListener("pointerover", this.handleHoverIntent, true);
|
|
259
|
-
document.removeEventListener("mousemove", this.handleHoverIntent, true);
|
|
260
|
-
document.removeEventListener("pointermove", this.handleHoverIntent, true);
|
|
261
240
|
document.removeEventListener("pointerdown", this.handlePointerDown, true);
|
|
262
241
|
document.removeEventListener("click", this.handleClick, true);
|
|
263
242
|
window.removeEventListener("popstate", this.handlePopState);
|
|
@@ -265,7 +244,6 @@ class EcoRouter {
|
|
|
265
244
|
this.unregisterNavigationRuntime?.();
|
|
266
245
|
this.unregisterNavigationRuntime = null;
|
|
267
246
|
this.started = false;
|
|
268
|
-
this.pendingHoverNavigation = null;
|
|
269
247
|
this.pendingPointerNavigation = null;
|
|
270
248
|
this.queuedNavigationHref = null;
|
|
271
249
|
const win = window;
|
|
@@ -323,29 +301,11 @@ class EcoRouter {
|
|
|
323
301
|
this.queuedNavigationHref = href;
|
|
324
302
|
}
|
|
325
303
|
}
|
|
326
|
-
handleHoverIntent(event) {
|
|
327
|
-
const link = this.getLinkFromEvent(event);
|
|
328
|
-
if (!link) {
|
|
329
|
-
return;
|
|
330
|
-
}
|
|
331
|
-
const href = this.canInterceptLink(event, link);
|
|
332
|
-
if (!href) {
|
|
333
|
-
return;
|
|
334
|
-
}
|
|
335
|
-
this.pendingHoverNavigation = {
|
|
336
|
-
href,
|
|
337
|
-
timestamp: performance.now()
|
|
338
|
-
};
|
|
339
|
-
if (this.pendingNavigations > 0) {
|
|
340
|
-
this.queuedNavigationHref = href;
|
|
341
|
-
}
|
|
342
|
-
}
|
|
343
304
|
handleClick(event) {
|
|
344
305
|
const navigationRuntime = getEcoNavigationRuntime(window);
|
|
345
306
|
const link = this.getLinkFromEvent(event);
|
|
346
|
-
const href = link ? this.canInterceptLink(event, link) : this.getRecoveredPointerHref()
|
|
307
|
+
const href = link ? this.canInterceptLink(event, link) : this.getRecoveredPointerHref();
|
|
347
308
|
this.pendingPointerNavigation = null;
|
|
348
|
-
this.pendingHoverNavigation = null;
|
|
349
309
|
if (!href) return;
|
|
350
310
|
this.queuedNavigationHref = null;
|
|
351
311
|
if (this.isAnotherNavigationRuntimeActive()) {
|