@witchcraft/layout 0.5.2 → 0.5.3
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/module.json
CHANGED
|
@@ -208,9 +208,14 @@ export function useFrames(win, handler) {
|
|
|
208
208
|
function cancel() {
|
|
209
209
|
moveEnd(void 0, { apply: false });
|
|
210
210
|
}
|
|
211
|
-
function resolve({
|
|
211
|
+
function resolve({ updateEdges, result: value }) {
|
|
212
212
|
moveResult = value;
|
|
213
|
-
|
|
213
|
+
if (updateEdges) {
|
|
214
|
+
for (const frame of touchingFramesArrays.value.flat()) {
|
|
215
|
+
win.value.frames[frame.id] = frame;
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
controller?.abort();
|
|
214
219
|
}
|
|
215
220
|
const keydownController = new AbortController();
|
|
216
221
|
const wrappedKeydownHandler = (e) => {
|
|
@@ -1929,7 +1929,7 @@ export interface IAction {
|
|
|
1929
1929
|
onMoveChange: <T extends "start" | "move" | "end">(type: T, e: T extends "end" ? PointerEvent | undefined : PointerEvent, state: MoveState, forceRecalculateEdges: () => void,
|
|
1930
1930
|
/** Calls moveEnd with updateEdges: false. This can technically be called from "end", it should still work. */
|
|
1931
1931
|
cancel: (e: PointerEvent | KeyboardEvent | undefined, state: MoveState) => void,
|
|
1932
|
-
/** Saves result to resolve moveStart promise
|
|
1932
|
+
/** Saves result to resolve moveStart promise, updates edges if you passed updateEdges then aborts the handler (only onMoveEnded will fire after) . Not available during "end" event. It's designed for resolving from other external evente (e.g. key events). */
|
|
1933
1933
|
resolve: T extends "end" ? undefined : ((opts: ActionResolve) => void)) => ActionChangeResult;
|
|
1934
1934
|
/**
|
|
1935
1935
|
* Is called after `onMoveChange("end")` with the same event. Will not be called if the request was cancelled.
|
|
@@ -2010,10 +2010,7 @@ export type ActionHandlerApplyResult = {
|
|
|
2010
2010
|
export type ActionApplyResult = ActionHandlerApplyResult & {
|
|
2011
2011
|
wasApplied: boolean;
|
|
2012
2012
|
};
|
|
2013
|
-
export type ActionResolve =
|
|
2014
|
-
apply: boolean;
|
|
2015
|
-
result?: any;
|
|
2016
|
-
};
|
|
2013
|
+
export type ActionResolve = ActionHandlerApplyResult;
|
|
2017
2014
|
/**
|
|
2018
2015
|
* Handler interface for drag actions.
|
|
2019
2016
|
*/
|
|
@@ -2029,15 +2026,12 @@ export interface IActionHandler {
|
|
|
2029
2026
|
* - onMoveChange("move", ...)
|
|
2030
2027
|
* - onMoveChange("end", ...)
|
|
2031
2028
|
* - onMoveApply(...) (IF moveEnd was called with apply: true, otherwise this is skipped)
|
|
2032
|
-
*
|
|
2033
|
-
* - onMoveEnded() // do cleanup here
|
|
2034
|
-
*
|
|
2035
|
-
* Note also that resolve just resolves the promise value (after onMoveApply("end") and before onMoveEnded()). Depending on what you're doing you might still have to apply the result, remember onMoveApply will still be called if you do `resolve({ apply:true })`.
|
|
2029
|
+
* - onMoveEnded() // do cleanup here, always called at the very end
|
|
2036
2030
|
*/
|
|
2037
2031
|
onMoveChange<T extends "start" | "move" | "end">(type: T, e: T extends "end" ? PointerEvent | undefined : PointerEvent, state: MoveState, forceRecalculateEdges: () => void,
|
|
2038
2032
|
/** Calls moveEnd with apply: false. This can technically be called from "end", it should still work. */
|
|
2039
2033
|
cancel: (e: PointerEvent | KeyboardEvent | undefined, state: MoveState) => void,
|
|
2040
|
-
/** Saves result to resolve moveStart promise
|
|
2034
|
+
/** Saves result to resolve moveStart promise, updates edges if you passed updateEdges then aborts the handler (only onMoveEnded will fire after) . Not available during "end" event. It's designed for resolving from other external evente (e.g. key events). */
|
|
2041
2035
|
resolve: T extends "end" ? undefined : ((opts: ActionResolve) => void)): MoveChangeResult;
|
|
2042
2036
|
/**
|
|
2043
2037
|
* Called when drag will be applied. If moveEnd was called with apply false, it will not be called.
|
package/package.json
CHANGED
|
@@ -281,10 +281,15 @@ export function useFrames(
|
|
|
281
281
|
function cancel(): void {
|
|
282
282
|
moveEnd(undefined, { apply: false })
|
|
283
283
|
}
|
|
284
|
-
|
|
285
|
-
function resolve({ apply, result: value }: ActionResolve): void {
|
|
284
|
+
function resolve({ updateEdges, result: value }: ActionResolve): void {
|
|
286
285
|
moveResult = value
|
|
287
|
-
|
|
286
|
+
|
|
287
|
+
if (updateEdges) {
|
|
288
|
+
for (const frame of touchingFramesArrays.value.flat()) {
|
|
289
|
+
win!.value.frames[frame.id] = frame
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
controller?.abort()
|
|
288
293
|
}
|
|
289
294
|
|
|
290
295
|
const keydownController = new AbortController()
|
|
@@ -536,7 +536,7 @@ export interface IAction {
|
|
|
536
536
|
forceRecalculateEdges: () => void,
|
|
537
537
|
/** Calls moveEnd with updateEdges: false. This can technically be called from "end", it should still work. */
|
|
538
538
|
cancel: (e: PointerEvent | KeyboardEvent | undefined, state: MoveState) => void,
|
|
539
|
-
/** Saves result to resolve moveStart promise
|
|
539
|
+
/** Saves result to resolve moveStart promise, updates edges if you passed updateEdges then aborts the handler (only onMoveEnded will fire after) . Not available during "end" event. It's designed for resolving from other external evente (e.g. key events). */
|
|
540
540
|
resolve: T extends "end" ? undefined : ((opts: ActionResolve) => void)
|
|
541
541
|
) => ActionChangeResult
|
|
542
542
|
/**
|
|
@@ -621,7 +621,7 @@ export type ActionHandlerApplyResult = {
|
|
|
621
621
|
|
|
622
622
|
export type ActionApplyResult = ActionHandlerApplyResult & { wasApplied: boolean }
|
|
623
623
|
|
|
624
|
-
export type ActionResolve =
|
|
624
|
+
export type ActionResolve = ActionHandlerApplyResult
|
|
625
625
|
|
|
626
626
|
/**
|
|
627
627
|
* Handler interface for drag actions.
|
|
@@ -640,10 +640,7 @@ export interface IActionHandler {
|
|
|
640
640
|
* - onMoveChange("move", ...)
|
|
641
641
|
* - onMoveChange("end", ...)
|
|
642
642
|
* - onMoveApply(...) (IF moveEnd was called with apply: true, otherwise this is skipped)
|
|
643
|
-
*
|
|
644
|
-
* - onMoveEnded() // do cleanup here
|
|
645
|
-
*
|
|
646
|
-
* Note also that resolve just resolves the promise value (after onMoveApply("end") and before onMoveEnded()). Depending on what you're doing you might still have to apply the result, remember onMoveApply will still be called if you do `resolve({ apply:true })`.
|
|
643
|
+
* - onMoveEnded() // do cleanup here, always called at the very end
|
|
647
644
|
*/
|
|
648
645
|
onMoveChange<T extends "start" | "move" | "end">(
|
|
649
646
|
type: T,
|
|
@@ -652,7 +649,7 @@ export interface IActionHandler {
|
|
|
652
649
|
forceRecalculateEdges: () => void,
|
|
653
650
|
/** Calls moveEnd with apply: false. This can technically be called from "end", it should still work. */
|
|
654
651
|
cancel: (e: PointerEvent | KeyboardEvent | undefined, state: MoveState) => void,
|
|
655
|
-
/** Saves result to resolve moveStart promise
|
|
652
|
+
/** Saves result to resolve moveStart promise, updates edges if you passed updateEdges then aborts the handler (only onMoveEnded will fire after) . Not available during "end" event. It's designed for resolving from other external evente (e.g. key events). */
|
|
656
653
|
resolve: T extends "end" ? undefined : ((opts: ActionResolve) => void)
|
|
657
654
|
): MoveChangeResult
|
|
658
655
|
/**
|