Skip to content

🎥 Make videos programmatically with React

Move selected Studio items through keybindings

Jonny Burger50917537d19e
diff --git a/packages/studio/src/components/PlayPause.tsx b/packages/studio/src/components/PlayPause.tsx
index ab74bfc373..b7645d4efa 100644
--- a/packages/studio/src/components/PlayPause.tsx
+++ b/packages/studio/src/components/PlayPause.tsx
@@ -10,7 +10,7 @@ import {StepBack} from '../icons/step-back';
import {StepForward} from '../icons/step-forward';
import {useTimelineInOutFramePosition} from '../state/in-out';
import {ControlButton} from './ControlButton';
-import {getCurrentDuration, getCurrentFps} from './Timeline/imperative-state';
+import {getCurrentDuration} from './Timeline/imperative-state';
import {ensureFrameIsInViewport} from './Timeline/timeline-scroll-logic';
const backStyle = {
@@ -98,69 +98,6 @@ export const PlayPause: React.FC<{
[pauseAndReturnToPlayStart, playing],
);
- const onArrowLeft = useCallback(
- (e: KeyboardEvent) => {
- e.preventDefault();
-
- if (e.altKey) {
- seek(0);
- ensureFrameIsInViewport({
- direction: 'fit-left',
- durationInFrames: getCurrentDuration(),
- frame: 0,
- });
- } else if (e.shiftKey) {
- frameBack(getCurrentFps());
- ensureFrameIsInViewport({
- direction: 'fit-left',
- durationInFrames: getCurrentDuration(),
- frame: Math.max(0, getCurrentFrame() - getCurrentFps()),
- });
- } else {
- frameBack(1);
- ensureFrameIsInViewport({
- direction: 'fit-left',
- durationInFrames: getCurrentDuration(),
- frame: Math.max(0, getCurrentFrame() - 1),
- });
- }
- },
- [frameBack, seek, getCurrentFrame],
- );
-
- const onArrowRight = useCallback(
- (e: KeyboardEvent) => {
- if (e.altKey) {
- seek(getCurrentDuration() - 1);
- ensureFrameIsInViewport({
- direction: 'fit-right',
- durationInFrames: getCurrentDuration() - 1,
- frame: getCurrentDuration() - 1,
- });
- } else if (e.shiftKey) {
- frameForward(getCurrentFps());
- ensureFrameIsInViewport({
- direction: 'fit-right',
- durationInFrames: getCurrentDuration(),
- frame: Math.min(
- getCurrentDuration() - 1,
- getCurrentFrame() + getCurrentFps(),
- ),
- });
- } else {
- frameForward(1);
- ensureFrameIsInViewport({
- direction: 'fit-right',
- durationInFrames: getCurrentDuration(),
- frame: Math.min(getCurrentDuration() - 1, getCurrentFrame() + 1),
- });
- }
-
- e.preventDefault();
- },
- [frameForward, seek, getCurrentFrame],
- );
-
const oneFrameBack = useCallback(() => {
frameBack(1);
ensureFrameIsInViewport({
@@ -190,24 +127,6 @@ export const PlayPause: React.FC<{
const keybindings = useKeybinding();
useEffect(() => {
- const arrowLeft = keybindings.registerKeybinding({
- event: 'keydown',
- key: 'ArrowLeft',
- callback: onArrowLeft,
- commandCtrlKey: false,
- preventDefault: true,
- triggerIfInputFieldFocused: false,
- keepRegisteredWhenNotHighestContext: false,
- });
- const arrowRight = keybindings.registerKeybinding({
- event: 'keydown',
- key: 'ArrowRight',
- callback: onArrowRight,
- commandCtrlKey: false,
- preventDefault: true,
- triggerIfInputFieldFocused: false,
- keepRegisteredWhenNotHighestContext: false,
- });
const commandArrowLeft = keybindings.registerKeybinding({
event: 'keydown',
key: 'ArrowLeft',
@@ -264,8 +183,6 @@ export const PlayPause: React.FC<{
});
return () => {
- arrowLeft.unregister();
- arrowRight.unregister();
commandArrowLeft.unregister();
commandArrowRight.unregister();
space.unregister();
@@ -277,8 +194,6 @@ export const PlayPause: React.FC<{
jumpToEnd,
jumpToStart,
keybindings,
- onArrowLeft,
- onArrowRight,
onEnter,
onSpace,
oneFrameBack,
diff --git a/packages/studio/src/components/SelectedOutlineOverlay.tsx b/packages/studio/src/components/SelectedOutlineOverlay.tsx
index 621a614287..a3499132a5 100644
--- a/packages/studio/src/components/SelectedOutlineOverlay.tsx
+++ b/packages/studio/src/components/SelectedOutlineOverlay.tsx
@@ -1,4 +1,12 @@
-import React, {useContext, useEffect, useMemo, useRef, useState} from 'react';
+import {PlayerInternals} from '@remotion/player';
+import React, {
+ useCallback,
+ useContext,
+ useEffect,
+ useMemo,
+ useRef,
+ useState,
+} from 'react';
import type {
CanUpdateSequencePropStatusKeyframed,
CanUpdateSequencePropStatusStatic,
@@ -19,7 +27,7 @@ import {formatFileLocation} from '../helpers/format-file-location';
import {getBoxQuadsPonyfill} from '../helpers/get-box-quads-ponyfill';
import type {SequenceNodePathInfo} from '../helpers/get-timeline-sequence-sort-key';
import {openOriginalPositionInEditor} from '../helpers/open-in-editor';
-import {areKeyboardShortcutsDisabled} from '../helpers/use-keybinding';
+import {useKeybinding} from '../helpers/use-keybinding';
import {EditorShowOutlinesContext} from '../state/editor-outlines';
import {ScaleLockContext} from '../state/scale-lock';
import {ContextMenuForTarget} from './ContextMenu';
@@ -57,6 +65,7 @@ import {
type AddSequenceKeyframeChange,
} from './Timeline/call-add-keyframe';
import {disableSequenceInteractivity} from './Timeline/disable-sequence-interactivity';
+import {getCurrentDuration, getCurrentFps} from './Timeline/imperative-state';
import {parseKeyframeFieldFromNodePath} from './Timeline/parse-keyframe-field-from-node-path';
import {
saveSequenceProps,
@@ -66,6 +75,7 @@ import {
parseCssRotationToDegrees,
serializeCssRotation,
} from './Timeline/timeline-rotation-utils';
+import {ensureFrameIsInViewport} from './Timeline/timeline-scroll-logic';
import {
parseTranslate,
serializeTranslate,
@@ -834,6 +844,14 @@ export type SelectedOutlineDragChange =
| SelectedOutlineStaticDragChange
| SelectedOutlineKeyframedDragChange;
+type SelectedOutlineKeyboardNudgeSession = {
+ readonly dragStates: readonly SelectedOutlineDragState[];
+ readonly clientId: string;
+ deltaX: number;
+ deltaY: number;
+ lastValues: ReadonlyMap<string, string>;
+};
+
export const getSelectedOutlineDragChanges = ({
dragStates,
lastValues,
@@ -894,15 +912,44 @@ export const getSelectedOutlineDragChanges = ({
return changes;
};
+export type SelectedOutlineKeyboardNudgeDirection =
+ | 'left'
+ | 'right'
+ | 'up'
+ | 'down';
+
export const getSelectedOutlineKeyboardNudgeDelta = ({
direction,
shiftKey,
}: {
- readonly direction: 'left' | 'right';
+ readonly direction: SelectedOutlineKeyboardNudgeDirection;
readonly shiftKey: boolean;
}) => {
const increment = shiftKey ? 10 : 1;
- return direction === 'left' ? -increment : increment;
+ return direction === 'left' || direction === 'up' ? -increment : increment;
+};
+
+export const getSelectedOutlineKeyboardNudgeDeltas = ({
+ deltaX,
+ deltaY,
+ direction,
+ shiftKey,
+}: {
+ readonly deltaX: number;
+ readonly deltaY: number;
+ readonly direction: SelectedOutlineKeyboardNudgeDirection;
+ readonly shiftKey: boolean;
+}) => {
+ const delta = getSelectedOutlineKeyboardNudgeDelta({
+ direction,
+ shiftKey,
+ });
+
+ if (direction === 'left' || direction === 'right') {
+ return {deltaX: deltaX + delta, deltaY};
+ }
+
+ return {deltaX, deltaY: deltaY + delta};
};
export type SelectedOutlineScaleEdge = 'top' | 'right' | 'bottom' | 'left';
@@ -1212,6 +1259,28 @@ const clearSelectedOutlineDragOverrides = ({
}
};
+const getSelectedOutlineKeyboardNudgeDirection = (
+ key: string,
+): SelectedOutlineKeyboardNudgeDirection | null => {
+ if (key === 'ArrowLeft') {
+ return 'left';
+ }
+
+ if (key === 'ArrowRight') {
+ return 'right';
+ }
+
+ if (key === 'ArrowUp') {
+ return 'up';
+ }
+
+ if (key === 'ArrowDown') {
+ return 'down';
+ }
+
+ return null;
+};
+
const clearSelectedOutlineScaleDragOverrides = ({
clearDragOverrides,
dragStates,
@@ -2700,9 +2769,14 @@ export const SelectedOutlineOverlay: React.FC<{
const {getDragOverrides, getEffectDragOverrides} = useContext(
Internals.VisualModeDragOverridesContext,
);
- const {setPropStatuses} = useContext(Internals.VisualModeSettersContext);
+ const {setPropStatuses, setDragOverrides, clearDragOverrides} = useContext(
+ Internals.VisualModeSettersContext,
+ );
const {getScaleLockState} = useContext(ScaleLockContext);
const {editorShowOutlines} = useContext(EditorShowOutlinesContext);
+ const {frameBack, frameForward, getCurrentFrame, seek} =
+ PlayerInternals.usePlayer();
+ const keybindings = useKeybinding();
const timelinePosition = Internals.Timeline.useTimelinePosition();
const [outlines, setOutlines] = useState<readonly SelectedOutline[]>([]);
const [hoveredOutlineKey, setHoveredOutlineKey] = useState<string | null>(
@@ -2710,6 +2784,9 @@ export const SelectedOutlineOverlay: React.FC<{
);
const [draggingOutline, setDraggingOutline] = useState(false);
const overlayRef = useRef<SVGSVGElement>(null);
+ const keyboardNudgeSessionRef =
+ useRef<SelectedOutlineKeyboardNudgeSession | null>(null);
+ const saveKeyboardNudgeSessionRef = useRef<() => void>(() => undefined);
const onDraggingChange = React.useCallback((dragging: boolean) => {
setDraggingOutline(dragging);
@@ -3027,123 +3104,296 @@ export const SelectedOutlineOverlay: React.FC<{
);
}, [outlineTargets]);
- useEffect(() => {
- if (areKeyboardShortcutsDisabled()) {
+ const saveKeyboardNudgeSession = useCallback(() => {
+ const session = keyboardNudgeSessionRef.current;
+ if (session === null) {
return;
}
- const onKeyDown = (event: KeyboardEvent) => {
- if (event.key !== 'ArrowLeft' && event.key !== 'ArrowRight') {
+ keyboardNudgeSessionRef.current = null;
+ const changes = getSelectedOutlineDragChanges({
+ dragStates: session.dragStates,
+ lastValues: session.lastValues,
+ });
+
+ if (changes.length === 0) {
+ clearSelectedOutlineDragOverrides({
+ clearDragOverrides,
+ dragStates: session.dragStates,
+ });
+ return;
+ }
+
+ const staticChanges = changes.filter(
+ (change): change is SelectedOutlineStaticDragChange =>
+ change.type === 'static',
+ );
+ const keyframedChanges = changes.filter(
+ (change): change is SelectedOutlineKeyframedDragChange =>
+ change.type === 'keyframed',
+ );
+
+ Promise.all([
+ staticChanges.length > 0
+ ? saveSequenceProps({
+ changes: staticChanges,
+ setPropStatuses,
+ clientId: session.clientId,
+ undoLabel:
+ changes.length > 1 ? 'Move selected sequences' : 'Move sequence',
+ redoLabel:
+ changes.length > 1
+ ? 'Move selected sequences back'
+ : 'Move sequence back',
+ })
+ : Promise.resolve(),
+ ...keyframedChanges.map((change) =>
+ callAddSequenceKeyframe({
+ fileName: change.fileName,
+ nodePath: change.nodePath,
+ fieldKey: change.fieldKey,
+ sourceFrame: change.sourceFrame,
+ value: change.value,
+ schema: change.schema,
+ setPropStatuses,
+ clientId: change.clientId,
+ }),
+ ),
+ ])
+ .catch((err) => {
+ showNotification(
+ `Could not save sequence props: ${
+ err instanceof Error ? err.message : String(err)
+ }`,
+ 4000,
+ );
+ })
+ .finally(() => {
+ clearSelectedOutlineDragOverrides({
+ clearDragOverrides,
+ dragStates: session.dragStates,
+ });
+ });
+ }, [clearDragOverrides, setPropStatuses]);
+
+ useEffect(() => {
+ saveKeyboardNudgeSessionRef.current = saveKeyboardNudgeSession;
+ }, [saveKeyboardNudgeSession]);
+
+ useEffect(() => {
+ return () => {
+ saveKeyboardNudgeSessionRef.current();
+ };
+ }, []);
+
+ const seekWithArrowKey = useCallback(
+ (
+ event: KeyboardEvent,
+ direction: SelectedOutlineKeyboardNudgeDirection,
+ ) => {
+ if (direction === 'up' || direction === 'down') {
return;
}
- if (event.metaKey || event.ctrlKey || event.altKey) {
+ event.preventDefault();
+
+ if (direction === 'left') {
+ if (event.altKey) {
+ seek(0);
+ ensureFrameIsInViewport({
+ direction: 'fit-left',
+ durationInFrames: getCurrentDuration(),
+ frame: 0,
+ });
+ } else if (event.shiftKey) {
+ frameBack(getCurrentFps());
+ ensureFrameIsInViewport({
+ direction: 'fit-left',
+ durationInFrames: getCurrentDuration(),
+ frame: Math.max(0, getCurrentFrame() - getCurrentFps()),
+ });
+ } else {
+ frameBack(1);
+ ensureFrameIsInViewport({
+ direction: 'fit-left',
+ durationInFrames: getCurrentDuration(),
+ frame: Math.max(0, getCurrentFrame() - 1),
+ });
+ }
+
return;
}
- const {activeElement} = document;
- if (
- activeElement instanceof HTMLInputElement ||
- activeElement instanceof HTMLTextAreaElement
- ) {
- return;
+ if (event.altKey) {
+ seek(getCurrentDuration() - 1);
+ ensureFrameIsInViewport({
+ direction: 'fit-right',
+ durationInFrames: getCurrentDuration() - 1,
+ frame: getCurrentDuration() - 1,
+ });
+ } else if (event.shiftKey) {
+ frameForward(getCurrentFps());
+ ensureFrameIsInViewport({
+ direction: 'fit-right',
+ durationInFrames: getCurrentDuration(),
+ frame: Math.min(
+ getCurrentDuration() - 1,
+ getCurrentFrame() + getCurrentFps(),
+ ),
+ });
+ } else {
+ frameForward(1);
+ ensureFrameIsInViewport({
+ direction: 'fit-right',
+ durationInFrames: getCurrentDuration(),
+ frame: Math.min(getCurrentDuration() - 1, getCurrentFrame() + 1),
+ });
}
+ },
+ [frameBack, frameForward, getCurrentFrame, seek],
+ );
- if (selectedItems.length === 0) {
+ const onArrowKeyDown = useCallback(
+ (event: KeyboardEvent) => {
+ const direction = getSelectedOutlineKeyboardNudgeDirection(event.key);
+
+ if (direction === null) {
return;
}
- event.preventDefault();
- event.stopImmediatePropagation();
+ if (selectedItems.length === 0 || allDragTargets.length === 0) {
+ seekWithArrowKey(event, direction);
+ return;
+ }
- if (allDragTargets.length === 0) {
+ if (event.altKey) {
+ seekWithArrowKey(event, direction);
return;
}
- const dragStates = getSelectedOutlineDragStates({
- dragTargets: allDragTargets,
- getDragOverrides,
- timelinePosition,
+ event.preventDefault();
+
+ const activeSession =
+ keyboardNudgeSessionRef.current ??
+ ((): SelectedOutlineKeyboardNudgeSession => {
+ const [firstDragTarget] = allDragTargets;
+ if (firstDragTarget === undefined) {
+ throw new Error('Expected a drag target');
+ }
+
+ return {
+ clientId: firstDragTarget.clientId,
+ deltaX: 0,
+ deltaY: 0,
+ dragStates: getSelectedOutlineDragStates({
+ dragTargets: allDragTargets,
+ getDragOverrides,
+ timelinePosition,
+ }),
+ lastValues: new Map(),
+ };
+ })();
+
+ keyboardNudgeSessionRef.current = activeSession;
+ const nextDeltas = getSelectedOutlineKeyboardNudgeDeltas({
+ deltaX: activeSession.deltaX,
+ deltaY: activeSession.deltaY,
+ direction,
+ shiftKey: event.shiftKey,
});
+ activeSession.deltaX = nextDeltas.deltaX;
+ activeSession.deltaY = nextDeltas.deltaY;
+
const lastValues = getSelectedOutlineDragValues({
- dragStates,
- deltaX: getSelectedOutlineKeyboardNudgeDelta({
- direction: event.key === 'ArrowLeft' ? 'left' : 'right',
- shiftKey: event.shiftKey,
- }),
- deltaY: 0,
- });
- const changes = getSelectedOutlineDragChanges({
- dragStates,
- lastValues,
+ dragStates: activeSession.dragStates,
+ deltaX: activeSession.deltaX,
+ deltaY: activeSession.deltaY,
});
+ activeSession.lastValues = lastValues;
- if (changes.length === 0) {
- return;
+ for (const dragState of activeSession.dragStates) {
+ const value = lastValues.get(dragState.key);
+ if (value === undefined) {
+ throw new Error('Expected drag value to be available');
+ }
+
+ if (dragState.target.propStatus.status === 'keyframed') {
+ setDragOverrides(
+ dragState.target.nodePath,
+ translateFieldKey,
+ Internals.makeKeyframedDragOverride({
+ status: dragState.target.propStatus,
+ frame: dragState.sourceFrame,
+ value,
+ }),
+ );
+ } else {
+ setDragOverrides(
+ dragState.target.nodePath,
+ translateFieldKey,
+ Internals.makeStaticDragOverride(value),
+ );
+ }
}
+ },
+ [
+ allDragTargets,
+ getDragOverrides,
+ seekWithArrowKey,
+ selectedItems.length,
+ setDragOverrides,
+ timelinePosition,
+ ],
+ );
- const staticChanges = changes.filter(
- (change): change is SelectedOutlineStaticDragChange =>
- change.type === 'static',
- );
- const keyframedChanges = changes.filter(
- (change): change is SelectedOutlineKeyframedDragChange =>
- change.type === 'keyframed',
- );
- const [firstDragTarget] = allDragTargets;
- if (firstDragTarget === undefined) {
- throw new Error('Expected a drag target');
+ const onArrowKeyUp = useCallback(
+ (event: KeyboardEvent) => {
+ const direction = getSelectedOutlineKeyboardNudgeDirection(event.key);
+
+ if (direction === null || keyboardNudgeSessionRef.current === null) {
+ return;
}
- Promise.all([
- staticChanges.length > 0
- ? saveSequenceProps({
- changes: staticChanges,
- setPropStatuses,
- clientId: firstDragTarget.clientId,
- undoLabel:
- changes.length > 1
- ? 'Move selected sequences'
- : 'Move sequence',
- redoLabel:
- changes.length > 1
- ? 'Move selected sequences back'
- : 'Move sequence back',
- })
- : Promise.resolve(),
- ...keyframedChanges.map((change) =>
- callAddSequenceKeyframe({
- fileName: change.fileName,
- nodePath: change.nodePath,
- fieldKey: change.fieldKey,
- sourceFrame: change.sourceFrame,
- value: change.value,
- schema: change.schema,
- setPropStatuses,
- clientId: change.clientId,
- }),
- ),
- ]).catch((err) => {
- showNotification(
- `Could not save sequence props: ${
- err instanceof Error ? err.message : String(err)
- }`,
- 4000,
- );
- });
- };
+ event.preventDefault();
+ saveKeyboardNudgeSession();
+ },
+ [saveKeyboardNudgeSession],
+ );
+
+ useEffect(() => {
+ const keyDownBindings = (
+ ['ArrowLeft', 'ArrowRight', 'ArrowUp', 'ArrowDown'] as const
+ ).map((key) =>
+ keybindings.registerKeybinding({
+ event: 'keydown',
+ key,
+ callback: onArrowKeyDown,
+ commandCtrlKey: false,
+ preventDefault: false,
+ triggerIfInputFieldFocused: false,
+ keepRegisteredWhenNotHighestContext: false,
+ }),
+ );
+ const keyUpBindings = (
+ ['ArrowLeft', 'ArrowRight', 'ArrowUp', 'ArrowDown'] as const
+ ).map((key) =>
+ keybindings.registerKeybinding({
+ event: 'keyup',
+ key,
+ callback: onArrowKeyUp,
+ commandCtrlKey: false,
+ preventDefault: false,
+ triggerIfInputFieldFocused: false,
+ keepRegisteredWhenNotHighestContext: false,
+ }),
+ );
- window.addEventListener('keydown', onKeyDown, {capture: true});
return () => {
- window.removeEventListener('keydown', onKeyDown, {capture: true});
+ for (const binding of [...keyDownBindings, ...keyUpBindings]) {
+ binding.unregister();
+ }
};
- }, [
- allDragTargets,
- getDragOverrides,
- selectedItems.length,
- setPropStatuses,
- timelinePosition,
- ]);
+ }, [keybindings, onArrowKeyDown, onArrowKeyUp, saveKeyboardNudgeSession]);
useEffect(() => {
if (outlineTargets.length === 0) {
diff --git a/packages/studio/src/test/timeline-selection.test.ts b/packages/studio/src/test/timeline-selection.test.ts
index 2524ac220f..cb87c391be 100644
--- a/packages/studio/src/test/timeline-selection.test.ts
+++ b/packages/studio/src/test/timeline-selection.test.ts
@@ -24,6 +24,7 @@ import {
getSelectedOutlineDragChanges,
getSelectedOutlineDragValues,
getSelectedOutlineKeyboardNudgeDelta,
+ getSelectedOutlineKeyboardNudgeDeltas,
getSelectedOutlineRotationCornerInfo,
getSelectedOutlineRotationDeltaDegrees,
getSelectedOutlineRotationDragChanges,
@@ -1980,7 +1981,7 @@ test('Selected outline dragging can lock movement to the dominant axis', () => {
).toEqual({deltaX: 12, deltaY: 13});
});
-test('Selected outline keyboard nudging moves horizontally by one or ten pixels', () => {
+test('Selected outline keyboard nudging moves by one or ten pixels', () => {
const schema = {
'style.translate': {type: 'translate', default: '0px 0px'},
} satisfies SequenceSchema;
@@ -2015,8 +2016,39 @@ test('Selected outline keyboard nudging moves horizontally by one or ten pixels'
shiftKey: true,
}),
).toBe(10);
+ expect(
+ getSelectedOutlineKeyboardNudgeDelta({
+ direction: 'up',
+ shiftKey: false,
+ }),
+ ).toBe(-1);
+ expect(
+ getSelectedOutlineKeyboardNudgeDelta({
+ direction: 'down',
+ shiftKey: true,
+ }),
+ ).toBe(10);
+ const accumulatedDeltas = [
+ {direction: 'right', shiftKey: false},
+ {direction: 'right', shiftKey: false},
+ {direction: 'down', shiftKey: true},
+ ] satisfies readonly {
+ readonly direction: 'left' | 'right' | 'up' | 'down';
+ readonly shiftKey: boolean;
+ }[];
+ const finalDeltas = accumulatedDeltas.reduce(
+ (deltas, keyPress) =>
+ getSelectedOutlineKeyboardNudgeDeltas({
+ ...deltas,
+ direction: keyPress.direction,
+ shiftKey: keyPress.shiftKey,
+ }),
+ {deltaX: 0, deltaY: 0},
+ );
- const lastValues = getSelectedOutlineDragValues({
+ expect(finalDeltas).toEqual({deltaX: 2, deltaY: 10});
+
+ const horizontalLastValues = getSelectedOutlineDragValues({
dragStates,
deltaX: getSelectedOutlineKeyboardNudgeDelta({
direction: 'right',
@@ -2025,11 +2057,11 @@ test('Selected outline keyboard nudging moves horizontally by one or ten pixels'
deltaY: 0,
});
- expect(lastValues.get(dragStates[0].key)).toBe('20px 20px');
+ expect(horizontalLastValues.get(dragStates[0].key)).toBe('20px 20px');
expect(
getSelectedOutlineDragChanges({
dragStates,
- lastValues,
+ lastValues: horizontalLastValues,
}),
).toEqual([
{
@@ -2042,6 +2074,33 @@ test('Selected outline keyboard nudging moves horizontally by one or ten pixels'
schema,
},
]);
+
+ const verticalLastValues = getSelectedOutlineDragValues({
+ dragStates,
+ deltaX: 0,
+ deltaY: getSelectedOutlineKeyboardNudgeDelta({
+ direction: 'down',
+ shiftKey: true,
+ }),
+ });
+
+ expect(verticalLastValues.get(dragStates[0].key)).toBe('10px 30px');
+ expect(
+ getSelectedOutlineDragChanges({
+ dragStates,
+ lastValues: verticalLastValues,
+ }),
+ ).toEqual([
+ {
+ type: 'static',
+ fileName: '/project/src/Comp.tsx',
+ nodePath,
+ fieldKey: 'style.translate',
+ value: '10px 30px',
+ defaultValue: JSON.stringify('0px 0px'),
+ schema,
+ },
+ ]);
});
test('Selected outline dragging starts after a screen pixel threshold', () => {