@pacem/pacem-core 1.0.0-bernoulli → 1.0.0-bessel
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/browser/pacem-core.js +50 -24
- package/dist/browser/pacem-core.js.map +1 -1
- package/dist/browser/pacem-core.min.js +2 -3
- package/dist/bundle/pacem-core.min.mjs +5 -5
- package/dist/bundle/pacem-core.mjs +44 -22
- package/dist/bundle/pacem-core.mjs.map +2 -2
- package/dist/esm/adapter.js +1 -1
- package/dist/esm/command.js +1 -1
- package/dist/esm/comparers.js +1 -1
- package/dist/esm/converters.js +1 -1
- package/dist/esm/decorators-next.js +1 -1
- package/dist/esm/decorators.js +1 -1
- package/dist/esm/defaults.js +1 -1
- package/dist/esm/events.js +15 -1
- package/dist/esm/eventtarget.js +1 -1
- package/dist/esm/expression.js +1 -1
- package/dist/esm/index-animations.js +1 -1
- package/dist/esm/index-behaviors.js +1 -1
- package/dist/esm/index-components.js +1 -1
- package/dist/esm/index-iife.js +1 -1
- package/dist/esm/index-logging.js +1 -1
- package/dist/esm/index-net.js +1 -1
- package/dist/esm/index-root.js +1 -1
- package/dist/esm/index-ui.js +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/logger.js +1 -1
- package/dist/esm/prefix.js +1 -1
- package/dist/esm/promise.js +1 -1
- package/dist/esm/regex.js +1 -1
- package/dist/esm/storage.js +1 -1
- package/dist/esm/template.js +1 -1
- package/dist/esm/transforms.js +1 -1
- package/dist/esm/types.js +1 -1
- package/dist/esm/utils-customelement.js +1 -1
- package/dist/esm/utils-customevent.js +1 -1
- package/dist/esm/utils.js +8 -1
- package/package.json +1 -1
- package/typings/index.d.ts +16 -10
- package/dist/browser/pacem-core.min.js.map +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* @pacem/pacem-core v1.0.0-
|
|
2
|
+
* @pacem/pacem-core v1.0.0-bessel (https://js.pacem.it)
|
|
3
3
|
* Pacem (https://pacem.it)
|
|
4
4
|
* Licensed under Apache-2.0
|
|
5
5
|
*/
|
|
@@ -1048,6 +1048,13 @@
|
|
|
1048
1048
|
static set scrollLeft(x) {
|
|
1049
1049
|
window.scrollTo(x, Utils.scrollTop);
|
|
1050
1050
|
}
|
|
1051
|
+
static scrollTo(x, y = true, smooth = true) {
|
|
1052
|
+
const yFirst = Utils.isNull(y) || typeof y === 'boolean';
|
|
1053
|
+
const left = yFirst ? Utils.scrollLeft : x;
|
|
1054
|
+
const top = yFirst ? x : y;
|
|
1055
|
+
const behavior = (yFirst ? y : smooth) ? 'smooth' : 'instant';
|
|
1056
|
+
window.scrollTo({ behavior, left, top });
|
|
1057
|
+
}
|
|
1051
1058
|
static get scrollTop() {
|
|
1052
1059
|
return window.scrollY /*window.pageYOffset*/ || document.documentElement.scrollTop || document.body.scrollTop || 0;
|
|
1053
1060
|
}
|
|
@@ -1490,6 +1497,20 @@
|
|
|
1490
1497
|
super(PropertyChangeEventName, args);
|
|
1491
1498
|
}
|
|
1492
1499
|
}
|
|
1500
|
+
// #region NAVIGATING
|
|
1501
|
+
const RouterNavigatingEventName = 'navigating';
|
|
1502
|
+
const RouterNavigateEventName = 'navigate';
|
|
1503
|
+
class RouterNavigateEvent extends CustomTypedEvent {
|
|
1504
|
+
constructor(path) {
|
|
1505
|
+
super(RouterNavigateEventName, typeof path === 'string' ? { path } : path, { cancelable: false, bubbles: false });
|
|
1506
|
+
}
|
|
1507
|
+
}
|
|
1508
|
+
class RouterNavigatingEvent extends CustomTypedEvent {
|
|
1509
|
+
constructor(path) {
|
|
1510
|
+
super(RouterNavigatingEventName, path, { cancelable: true, bubbles: false });
|
|
1511
|
+
}
|
|
1512
|
+
}
|
|
1513
|
+
// #endregion
|
|
1493
1514
|
//}
|
|
1494
1515
|
|
|
1495
1516
|
class AnimationEvent extends CustomTypedEvent {
|
|
@@ -6152,28 +6173,24 @@
|
|
|
6152
6173
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6153
6174
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6154
6175
|
};
|
|
6155
|
-
//namespace Pacem {
|
|
6156
|
-
const RouterNavigatingEventName = 'navigating';
|
|
6157
|
-
const RouterNavigateEventName = 'navigate';
|
|
6158
|
-
class RouterNavigateEvent extends CustomTypedEvent {
|
|
6159
|
-
constructor(path) {
|
|
6160
|
-
super(RouterNavigateEventName, typeof path === 'string' ? { path } : path, { cancelable: false, bubbles: false });
|
|
6161
|
-
}
|
|
6162
|
-
}
|
|
6163
|
-
class RouterNavigatingEvent extends CustomTypedEvent {
|
|
6164
|
-
constructor(path) {
|
|
6165
|
-
super(RouterNavigatingEventName, path, { cancelable: true, bubbles: false });
|
|
6166
|
-
}
|
|
6167
|
-
}
|
|
6168
|
-
//}
|
|
6169
6176
|
//namespace Pacem.Components {
|
|
6170
6177
|
const CHECK_PATTERN = /^([\w\.]:)?\/\/[^\/]+/;
|
|
6171
6178
|
let PacemRouterElement = class PacemRouterElement extends PacemEventTarget {
|
|
6172
6179
|
constructor() {
|
|
6173
6180
|
super(...arguments);
|
|
6181
|
+
this._onScroll = (e) => {
|
|
6182
|
+
const scrollRestoration = this.scrollRestoration ?? true;
|
|
6183
|
+
if (!scrollRestoration) {
|
|
6184
|
+
return;
|
|
6185
|
+
}
|
|
6186
|
+
const y = Math.floor(Utils.scrollTop);
|
|
6187
|
+
window.history.replaceState(Utils.extend({}, window.history.state, { $scrollY: y }), document.title);
|
|
6188
|
+
};
|
|
6174
6189
|
this._onPopState = (evt) => {
|
|
6175
6190
|
if (!Utils.isNull(evt.state) && !this.#cancelingNavigation) {
|
|
6176
|
-
|
|
6191
|
+
const state = evt.state;
|
|
6192
|
+
// navigate and scroll, just in case
|
|
6193
|
+
this.path = state.$path;
|
|
6177
6194
|
}
|
|
6178
6195
|
};
|
|
6179
6196
|
}
|
|
@@ -6225,14 +6242,18 @@
|
|
|
6225
6242
|
// exiting
|
|
6226
6243
|
return;
|
|
6227
6244
|
}
|
|
6245
|
+
const newState = !poppingState
|
|
6246
|
+
? Utils.extend({ $scrollY: 0 }, state)
|
|
6247
|
+
: Utils.extend({ $scrollY: 0 }, window.history.state /* < may include `$scrollY` */, state);
|
|
6228
6248
|
// this one actually does trigger the navigation in the outer world
|
|
6229
|
-
|
|
6249
|
+
// 'cause it is usually bound to a PacemViewElement 'url'
|
|
6250
|
+
this.state = newState;
|
|
6251
|
+
window.history.scrollRestoration = (this.scrollRestoration ?? true) ? 'manual' : 'auto';
|
|
6230
6252
|
if (poppingState) {
|
|
6231
|
-
window.history.
|
|
6232
|
-
window.history.replaceState(state, title);
|
|
6253
|
+
window.history.replaceState(newState, document.title);
|
|
6233
6254
|
}
|
|
6234
6255
|
else {
|
|
6235
|
-
window.history.pushState(
|
|
6256
|
+
window.history.pushState(newState, title, path);
|
|
6236
6257
|
}
|
|
6237
6258
|
if (!Utils.isNullOrEmpty(title)) {
|
|
6238
6259
|
document.title = title;
|
|
@@ -6257,6 +6278,7 @@
|
|
|
6257
6278
|
connectedCallback() {
|
|
6258
6279
|
super.connectedCallback();
|
|
6259
6280
|
window.addEventListener('popstate', this._onPopState, false);
|
|
6281
|
+
document.addEventListener('scroll', this._onScroll, false);
|
|
6260
6282
|
}
|
|
6261
6283
|
viewActivatedCallback() {
|
|
6262
6284
|
super.viewActivatedCallback();
|
|
@@ -6266,6 +6288,7 @@
|
|
|
6266
6288
|
}
|
|
6267
6289
|
}
|
|
6268
6290
|
disconnectedCallback() {
|
|
6291
|
+
document.removeEventListener('scroll', this._onScroll, false);
|
|
6269
6292
|
window.removeEventListener('popstate', this._onPopState, false);
|
|
6270
6293
|
super.disconnectedCallback();
|
|
6271
6294
|
}
|
|
@@ -6320,6 +6343,9 @@
|
|
|
6320
6343
|
__decorate$l([
|
|
6321
6344
|
Watch({ emit: false, converter: PropertyConverters.String })
|
|
6322
6345
|
], PacemRouterElement.prototype, "path", void 0);
|
|
6346
|
+
__decorate$l([
|
|
6347
|
+
Watch({ emit: false, reflectBack: true, converter: PropertyConverters.Boolean })
|
|
6348
|
+
], PacemRouterElement.prototype, "scrollRestoration", void 0);
|
|
6323
6349
|
PacemRouterElement = __decorate$l([
|
|
6324
6350
|
CustomElement({ tagName: P + '-router' })
|
|
6325
6351
|
], PacemRouterElement);
|
|
@@ -8762,10 +8788,6 @@
|
|
|
8762
8788
|
RepeaterItemRemoveEventName: RepeaterItemRemoveEventName,
|
|
8763
8789
|
ResizeEvent: ResizeEvent,
|
|
8764
8790
|
ResizeEventName: ResizeEventName,
|
|
8765
|
-
RouterNavigateEvent: RouterNavigateEvent,
|
|
8766
|
-
RouterNavigateEventName: RouterNavigateEventName,
|
|
8767
|
-
RouterNavigatingEvent: RouterNavigatingEvent,
|
|
8768
|
-
RouterNavigatingEventName: RouterNavigatingEventName,
|
|
8769
8791
|
ScrollEvent: ScrollEvent,
|
|
8770
8792
|
ScrollEventName: ScrollEventName,
|
|
8771
8793
|
StateEvent: StateEvent,
|
|
@@ -9097,6 +9119,10 @@
|
|
|
9097
9119
|
Regex: Regex,
|
|
9098
9120
|
Repeater: Repeater,
|
|
9099
9121
|
RepeaterItem: RepeaterItem$1,
|
|
9122
|
+
RouterNavigateEvent: RouterNavigateEvent,
|
|
9123
|
+
RouterNavigateEventName: RouterNavigateEventName,
|
|
9124
|
+
RouterNavigatingEvent: RouterNavigatingEvent,
|
|
9125
|
+
RouterNavigatingEventName: RouterNavigatingEventName,
|
|
9100
9126
|
Storage: Storage,
|
|
9101
9127
|
TemplateElement: TemplateElement,
|
|
9102
9128
|
Throttle: Throttle,
|