Skip to content

Commit 808fbb5

Browse files
committed
fix(pptx): allow animating grouped elements again
The rule rested on an unreproduced claim about PowerPoint.
1 parent 69f4d3b commit 808fbb5

3 files changed

Lines changed: 44 additions & 57 deletions

File tree

‎packages/pptx/src/deck.ts‎

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -618,7 +618,6 @@ function freeSlideIssues(slide: Slide, index: number): DeckIssue[] {
618618
if (slide.layout !== "free") return [];
619619
const issues: DeckIssue[] = [];
620620
const ids = new Set<string>();
621-
const grouped = new Set<string>();
622621
const slidePath = ["slides", index, "elements"];
623622
for (const [element, path] of freeElements(slide.elements, slidePath)) {
624623
if (element.id !== undefined && ids.has(element.id))
@@ -629,8 +628,6 @@ function freeSlideIssues(slide: Slide, index: number): DeckIssue[] {
629628
),
630629
);
631630
if (element.id !== undefined) ids.add(element.id);
632-
if (element.id !== undefined && path.length > slidePath.length + 1)
633-
grouped.add(element.id);
634631
if (element.type === "group") continue;
635632
if (element.type === "image" && element.crop) {
636633
const { top, right, bottom, left } = element.crop;
@@ -664,13 +661,6 @@ function freeSlideIssues(slide: Slide, index: number): DeckIssue[] {
664661
`names "${animation.target}", which no element on this slide has as its id`,
665662
),
666663
);
667-
if (grouped.has(animation.target))
668-
issues.push(
669-
issueAt(
670-
[...path, "target"],
671-
`names "${animation.target}", which is inside a group; only elements directly on the slide animate`,
672-
),
673-
);
674664
if (animation.trigger === "afterPrevious" && endless)
675665
issues.push(
676666
issueAt(

‎packages/pptx/test/fixture.ts‎

Lines changed: 44 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,7 @@ export const deck: DeckInput = {
282282
opacity: 0.8,
283283
children: [
284284
{
285+
id: "divider",
285286
type: "shape",
286287
geometry: "line",
287288
x: 120,
@@ -292,51 +293,51 @@ export const deck: DeckInput = {
292293
},
293294
],
294295
},
295-
],
296-
},
297-
{
298-
id: "headline",
299-
type: "text",
300-
x: 120,
301-
y: 240,
302-
w: 480,
303-
h: 160,
304-
anchor: "middle",
305-
insets: { top: 4, right: 8, bottom: 4, left: 8 },
306-
link: 0,
307-
paragraphs: [
308296
{
309-
lineHeight: 64,
310-
runs: [
297+
id: "headline",
298+
type: "text",
299+
x: 120,
300+
y: 240,
301+
w: 480,
302+
h: 160,
303+
anchor: "middle",
304+
insets: { top: 4, right: 8, bottom: 4, left: 8 },
305+
link: 0,
306+
paragraphs: [
311307
{
312-
text: "Designed\nslides",
313-
font: "Georgia",
314-
size: 56,
315-
weight: 800,
316-
letterSpacing: -1,
317-
color: {
318-
type: "linear",
319-
angle: 90,
320-
stops: [
321-
{ color: "primary", at: 0 },
322-
{ color: "secondary", at: 100 },
323-
],
324-
},
308+
lineHeight: 64,
309+
runs: [
310+
{
311+
text: "Designed\nslides",
312+
font: "Georgia",
313+
size: 56,
314+
weight: 800,
315+
letterSpacing: -1,
316+
color: {
317+
type: "linear",
318+
angle: 90,
319+
stops: [
320+
{ color: "primary", at: 0 },
321+
{ color: "secondary", at: 100 },
322+
],
323+
},
324+
},
325+
],
325326
},
326-
],
327-
},
328-
{
329-
align: "center",
330-
spaceBefore: 12,
331-
runs: [
332-
"Text, ",
333-
{ text: "italic", italic: true, weight: 300 },
334-
" and a ",
335327
{
336-
text: "link",
337-
link: "https://corbits.dev",
338-
color: "#0EA5E9",
339-
underline: true,
328+
align: "center",
329+
spaceBefore: 12,
330+
runs: [
331+
"Text, ",
332+
{ text: "italic", italic: true, weight: 300 },
333+
" and a ",
334+
{
335+
text: "link",
336+
link: "https://corbits.dev",
337+
color: "#0EA5E9",
338+
underline: true,
339+
},
340+
],
340341
},
341342
],
342343
},
@@ -407,7 +408,7 @@ export const deck: DeckInput = {
407408
},
408409
{ target: "cover", effect: "zoom", kind: "entrance", duration: 700 },
409410
{
410-
target: "tag",
411+
target: "divider",
411412
effect: "wipe",
412413
kind: "entrance",
413414
side: "left",
@@ -420,7 +421,7 @@ export const deck: DeckInput = {
420421
trigger: "withPrevious",
421422
},
422423
{ target: "tag", effect: "pulse", repeat: 3 },
423-
{ target: "card", effect: "scale", scale: 1.1 },
424+
{ target: "card-back", effect: "scale", scale: 1.1 },
424425
{
425426
target: "glow",
426427
effect: "path",

‎packages/pptx/test/pptx.test.ts‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -217,10 +217,6 @@ test("a free slide names the element of every problem, and groups past ten level
217217
"slides[1].animations[0].easing",
218218
"has accel and decel adding up past 1",
219219
),
220-
at(
221-
"slides[1].animations[1].target",
222-
'names "c", which is inside a group; only elements directly on the slide animate',
223-
),
224220
at(
225221
"slides[1].animations[3].trigger",
226222
"waits for an animation that repeats indefinitely and never ends",

0 commit comments

Comments
 (0)