@hyperframes/studio 0.6.57 → 0.6.59

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.
@@ -215,6 +215,9 @@ export function useDomEditSession({
215
215
  addGsapAnimation,
216
216
  addGsapProperty,
217
217
  removeGsapProperty,
218
+ updateGsapFromProperty,
219
+ addGsapFromProperty,
220
+ removeGsapFromProperty,
218
221
  } = useGsapScriptCommits({
219
222
  projectIdRef,
220
223
  activeCompPath,
@@ -288,7 +291,7 @@ export function useDomEditSession({
288
291
  );
289
292
 
290
293
  const handleGsapAddAnimation = useCallback(
291
- (method: "to" | "from" | "set") => {
294
+ (method: "to" | "from" | "set" | "fromTo") => {
292
295
  if (!domEditSelection) return;
293
296
  addGsapAnimation(domEditSelection, method, currentTime);
294
297
  },
@@ -311,6 +314,30 @@ export function useDomEditSession({
311
314
  [domEditSelection, removeGsapProperty],
312
315
  );
313
316
 
317
+ const handleGsapUpdateFromProperty = useCallback(
318
+ (animId: string, prop: string, value: number | string) => {
319
+ if (!domEditSelection) return;
320
+ updateGsapFromProperty(domEditSelection, animId, prop, value);
321
+ },
322
+ [domEditSelection, updateGsapFromProperty],
323
+ );
324
+
325
+ const handleGsapAddFromProperty = useCallback(
326
+ (animId: string, prop: string) => {
327
+ if (!domEditSelection) return;
328
+ addGsapFromProperty(domEditSelection, animId, prop);
329
+ },
330
+ [domEditSelection, addGsapFromProperty],
331
+ );
332
+
333
+ const handleGsapRemoveFromProperty = useCallback(
334
+ (animId: string, prop: string) => {
335
+ if (!domEditSelection) return;
336
+ removeGsapFromProperty(domEditSelection, animId, prop);
337
+ },
338
+ [domEditSelection, removeGsapFromProperty],
339
+ );
340
+
314
341
  // Sync selection from preview document on load / refresh
315
342
  // eslint-disable-next-line no-restricted-syntax
316
343
  useEffect(() => {
@@ -443,5 +470,8 @@ export function useDomEditSession({
443
470
  handleGsapAddAnimation,
444
471
  handleGsapAddProperty,
445
472
  handleGsapRemoveProperty,
473
+ handleGsapUpdateFromProperty,
474
+ handleGsapAddFromProperty,
475
+ handleGsapRemoveFromProperty,
446
476
  };
447
477
  }
@@ -210,7 +210,11 @@ export function useGsapScriptCommits({
210
210
  );
211
211
 
212
212
  const addGsapAnimation = useCallback(
213
- async (selection: DomEditSelection, method: "to" | "from" | "set", currentTime?: number) => {
213
+ async (
214
+ selection: DomEditSelection,
215
+ method: "to" | "from" | "set" | "fromTo",
216
+ currentTime?: number,
217
+ ) => {
214
218
  const { selector, autoId } = ensureElementAddressable(selection);
215
219
 
216
220
  if (autoId) {
@@ -238,10 +242,11 @@ export function useGsapScriptCommits({
238
242
  }
239
243
 
240
244
  const start = currentTime ?? (Number.parseFloat(selection.dataAttributes.start ?? "0") || 0);
241
- const defaults: Record<string, Record<string, number>> = {
245
+ const toDefaults: Record<string, Record<string, number>> = {
242
246
  from: { opacity: 0 },
243
247
  to: { opacity: 1 },
244
248
  set: { opacity: 1 },
249
+ fromTo: { opacity: 1 },
245
250
  };
246
251
 
247
252
  await commitMutation(
@@ -253,7 +258,8 @@ export function useGsapScriptCommits({
253
258
  position: start,
254
259
  duration: method === "set" ? undefined : 0.5,
255
260
  ease: method === "set" ? undefined : "power2.out",
256
- properties: defaults[method] ?? { opacity: 1 },
261
+ properties: toDefaults[method] ?? { opacity: 1 },
262
+ fromProperties: method === "fromTo" ? { opacity: 0 } : undefined,
257
263
  },
258
264
  { label: `Add GSAP ${method} animation` },
259
265
  );
@@ -292,6 +298,48 @@ export function useGsapScriptCommits({
292
298
  [commitMutation],
293
299
  );
294
300
 
301
+ const updateGsapFromProperty = useCallback(
302
+ (
303
+ selection: DomEditSelection,
304
+ animationId: string,
305
+ property: string,
306
+ value: number | string,
307
+ ) => {
308
+ void commitMutation(
309
+ selection,
310
+ { type: "update-from-property", animationId, property, value },
311
+ {
312
+ label: `Edit GSAP from-${property}`,
313
+ coalesceKey: `gsap:${animationId}:from:${property}`,
314
+ },
315
+ );
316
+ },
317
+ [commitMutation],
318
+ );
319
+
320
+ const addGsapFromProperty = useCallback(
321
+ (selection: DomEditSelection, animationId: string, property: string) => {
322
+ const defaultValue = PROPERTY_DEFAULTS[property] ?? 0;
323
+ void commitMutation(
324
+ selection,
325
+ { type: "add-from-property", animationId, property, defaultValue },
326
+ { label: `Add GSAP from-${property}` },
327
+ );
328
+ },
329
+ [commitMutation],
330
+ );
331
+
332
+ const removeGsapFromProperty = useCallback(
333
+ (selection: DomEditSelection, animationId: string, property: string) => {
334
+ void commitMutation(
335
+ selection,
336
+ { type: "remove-from-property", animationId, property },
337
+ { label: `Remove GSAP from-${property}` },
338
+ );
339
+ },
340
+ [commitMutation],
341
+ );
342
+
295
343
  return {
296
344
  updateGsapProperty,
297
345
  updateGsapMeta,
@@ -299,5 +347,8 @@ export function useGsapScriptCommits({
299
347
  addGsapAnimation,
300
348
  addGsapProperty,
301
349
  removeGsapProperty,
350
+ updateGsapFromProperty,
351
+ addGsapFromProperty,
352
+ removeGsapFromProperty,
302
353
  };
303
354
  }