@ethlete/core 5.0.0-next.43 → 5.0.0-next.44
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/CHANGELOG.md +7 -0
- package/fesm2022/ethlete-core.mjs +28 -6
- package/fesm2022/ethlete-core.mjs.map +1 -1
- package/package.json +1 -1
- package/types/ethlete-core.d.ts +14 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# @ethlete/core
|
|
2
2
|
|
|
3
|
+
## 5.0.0-next.44
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#3050](https://github.com/ethlete-io/ethdk/pull/3050) [`2d44597`](https://github.com/ethlete-io/ethdk/commit/2d44597f07b165a83c19f049a022c4247a8e3eb1) Thanks [@github-actions](https://github.com/apps/github-actions)! - Slider and rating now drag on `dragGestureFrom`, so a gesture the browser takes away reverts
|
|
8
|
+
instead of committing. `dragEnded` carries the release position.
|
|
9
|
+
|
|
3
10
|
## 5.0.0-next.43
|
|
4
11
|
|
|
5
12
|
### Minor Changes
|
|
@@ -5055,12 +5055,28 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.7", ngImpor
|
|
|
5055
5055
|
}]
|
|
5056
5056
|
}], ctorParameters: () => [] });
|
|
5057
5057
|
|
|
5058
|
+
// jsdom and other non-browser DOMs ship no pointer capture; the document listeners track the
|
|
5059
|
+
// gesture either way, so a failure here only costs events over a cross-origin frame.
|
|
5060
|
+
const capturePointer = (el, pointerId) => {
|
|
5061
|
+
try {
|
|
5062
|
+
el.setPointerCapture(pointerId);
|
|
5063
|
+
}
|
|
5064
|
+
catch {
|
|
5065
|
+
return;
|
|
5066
|
+
}
|
|
5067
|
+
};
|
|
5058
5068
|
const setupDragObservable = (startEvent, el, commitThreshold) => {
|
|
5059
5069
|
const { pointerId, clientX: startX, clientY: startY } = startEvent;
|
|
5060
5070
|
let cancelled = false;
|
|
5071
|
+
let endX = startX;
|
|
5072
|
+
let endY = startY;
|
|
5061
5073
|
const end$ = merge(fromEvent(document, 'pointerup'), fromEvent(document, 'pointercancel')).pipe(filter((e) => e.pointerId === pointerId), take(1),
|
|
5062
5074
|
// Read below by the terminating `defer`, which only runs once this has completed the moves.
|
|
5063
|
-
tap((e) =>
|
|
5075
|
+
tap((e) => {
|
|
5076
|
+
cancelled = e.type === 'pointercancel';
|
|
5077
|
+
endX = e.clientX;
|
|
5078
|
+
endY = e.clientY;
|
|
5079
|
+
}));
|
|
5064
5080
|
let lastX = startX;
|
|
5065
5081
|
let lastY = startY;
|
|
5066
5082
|
let committed = false;
|
|
@@ -5070,7 +5086,7 @@ const setupDragObservable = (startEvent, el, commitThreshold) => {
|
|
|
5070
5086
|
return EMPTY;
|
|
5071
5087
|
}
|
|
5072
5088
|
committed = true;
|
|
5073
|
-
el
|
|
5089
|
+
capturePointer(el, pointerId);
|
|
5074
5090
|
lastX = e.clientX;
|
|
5075
5091
|
lastY = e.clientY;
|
|
5076
5092
|
// Emit the catch-up move together with start so consumers snap to the pointer
|
|
@@ -5108,15 +5124,21 @@ const setupDragObservable = (startEvent, el, commitThreshold) => {
|
|
|
5108
5124
|
return concat(moves$, defer(() => {
|
|
5109
5125
|
if (cancelled)
|
|
5110
5126
|
return of({ type: 'cancelled' });
|
|
5111
|
-
|
|
5127
|
+
if (!committed)
|
|
5128
|
+
return of({ type: 'tapped' });
|
|
5129
|
+
return of({
|
|
5130
|
+
type: 'end',
|
|
5131
|
+
data: { clientX: endX, clientY: endY, totalDx: endX - startX, totalDy: endY - startY },
|
|
5132
|
+
});
|
|
5112
5133
|
}));
|
|
5113
5134
|
};
|
|
5114
5135
|
/**
|
|
5115
5136
|
* Observe one drag gesture, starting from a `pointerdown` on `element`.
|
|
5116
5137
|
*
|
|
5117
5138
|
* Emits `start` once the pointer has travelled `commitThreshold` px (so a click is not a drag),
|
|
5118
|
-
* immediately followed by a catch-up `move`, then a `move` per pointer move, and finally `end
|
|
5119
|
-
* pointer released before crossing the threshold emits a single
|
|
5139
|
+
* immediately followed by a catch-up `move`, then a `move` per pointer move, and finally `end`
|
|
5140
|
+
* carrying the release position. A pointer released before crossing the threshold emits a single
|
|
5141
|
+
* `tapped` instead - its position is the `pointerdown` the caller already holds. The stream
|
|
5120
5142
|
* completes with the gesture, so there is nothing to unsubscribe on the happy path.
|
|
5121
5143
|
*
|
|
5122
5144
|
* A gesture the browser takes away - a `pointercancel` from a system gesture, an incoming call, the
|
|
@@ -5140,7 +5162,7 @@ class DragHandleDirective {
|
|
|
5140
5162
|
this.dragTapped = outputFromObservable(this.gesture$.pipe(filter((e) => e.type === 'tapped'), map(() => undefined)));
|
|
5141
5163
|
this.dragStarted = outputFromObservable(this.gesture$.pipe(filter((e) => e.type === 'start'), map((e) => e.data)));
|
|
5142
5164
|
this.dragMoved = outputFromObservable(this.gesture$.pipe(filter((e) => e.type === 'move'), map((e) => e.data)));
|
|
5143
|
-
this.dragEnded = outputFromObservable(this.gesture$.pipe(filter((e) => e.type === 'end'), map(() =>
|
|
5165
|
+
this.dragEnded = outputFromObservable(this.gesture$.pipe(filter((e) => e.type === 'end'), map((e) => e.data)));
|
|
5144
5166
|
/**
|
|
5145
5167
|
* The browser took the gesture away mid-drag (a system gesture, an incoming call, the tab going to
|
|
5146
5168
|
* the background). Revert to where the drag started - the user never chose a drop position. A
|