Animated Text
Contents
[
Hide
]
Adding Animation Effects to Paragraphs
We added the addEffect() method to the Sequence and Sequence classes. This method allows you to add animation effects to a single paragraph. This sample code shows you how to add an animation effect to a single paragraph:
var presentation = new aspose.slides.Presentation("Presentation.pptx");
try {
// select paragraph to add effect
var autoShape = presentation.getSlides().get_Item(0).getShapes().get_Item(0);
var paragraph = autoShape.getTextFrame().getParagraphs().get_Item(0);
// add Fly animation effect to selected paragraph
var effect = presentation.getSlides().get_Item(0).getTimeline().getMainSequence().addEffect(paragraph, aspose.slides.EffectType.Fly, aspose.slides.EffectSubtype.Left, aspose.slides.EffectTriggerType.OnClick);
presentation.save("AnimationEffectinParagraph.pptx", aspose.slides.SaveFormat.Pptx);
} finally {
if (presentation != null) {
presentation.dispose();
}
}
Getting the Animation Effects in Paragraphs
You may decide to find out the animation effects added to a paragraph—for example, in one scenario, you want to get the animation effects in a paragraph because you plan to apply those effects to another paragraph or shape.
Aspose.Slides for Node.js via Java allows you to get all the animation effects applied to paragraphs contained in a text frame (shape). This sample code shows you how to get the animation effects in a paragraph:
var pres = new aspose.slides.Presentation("pres.pptx");
try {
var sequence = pres.getSlides().get_Item(0).getTimeline().getMainSequence();
var autoShape = pres.getSlides().get_Item(0).getShapes().get_Item(0);
for (let i = 0; i < autoShape.getTextFrame().getParagraphs().getCount(); i++) {
let paragraph = autoShape.getTextFrame().getParagraphs().get_Item(i);
var effects = sequence.getEffectsByParagraph(paragraph);
if (effects.length > 0) {
console.log("Paragraph \"" + paragraph.getText() + "\" has " + effects[0].getType() + " effect.");
}
}
} finally {
pres.dispose();
}