Manage Slide Transitions in Presentations in .NET

Overview

Slide transitions control how slides appear during a slide show. With Aspose.Slides for .NET, you can choose a transition effect for each slide, configure advancement by mouse click or timer, and adjust options specific to an effect. This article uses C# examples to apply transitions, set exact transition durations, manage slide timing, and create a Morph transition between two slides. The examples also show how to save the settings to a PPTX file.

Add Slide Transition

To apply a transition, load a presentation with the Presentation class and access the slide’s SlideShowTransition property. Set its Type to a value from the TransitionType enumeration, then save the presentation.

The following example applies a Circle transition to the first slide and a Comb transition to the second. Use an input.pptx file with at least two slides.

using System;
using Aspose.Slides;
using Aspose.Slides.Export;
using Aspose.Slides.SlideShow;

using var presentation = new Presentation("input.pptx");

if (presentation.Slides.Count >= 2)
{
    presentation.Slides[0].SlideShowTransition.Type = TransitionType.Circle;
    presentation.Slides[1].SlideShowTransition.Type = TransitionType.Comb;

    presentation.Save("slide-transitions.pptx", SaveFormat.Pptx);
}
else
{
    Console.WriteLine("The input presentation must contain at least two slides.");
}

Wheel Transition

The Spokes property of IWheelTransition controls the number of radial sectors that reveal the destination slide. Set the slide’s transition Type to Wheel from TransitionType before accessing Value as IWheelTransition.

This example creates two identical pairs of slides: a black slide followed by a slide with a gold rectangle. The destination slides use spoke counts of 1 and 8, with the same Speed and an explicit Duration of 8,000 milliseconds to make the difference easy to observe.

using System.Drawing;
using Aspose.Slides;
using Aspose.Slides.Export;
using Aspose.Slides.SlideShow;

using var presentation = new Presentation();
var slideWidth = presentation.SlideSize.Size.Width;
var slideHeight = presentation.SlideSize.Size.Height;

var blackSlide = presentation.Slides[0];
blackSlide.Shapes.Clear();
blackSlide.Background.Type = BackgroundType.OwnBackground;
blackSlide.Background.FillFormat.FillType = FillType.Solid;
blackSlide.Background.FillFormat.SolidFillColor.Color = Color.Black;

var destinationSlide = presentation.Slides.AddClone(blackSlide);
var rectangle = destinationSlide.Shapes.AddAutoShape(ShapeType.Rectangle, 0, 0, slideWidth, slideHeight);
rectangle.FillFormat.FillType = FillType.Solid;
rectangle.FillFormat.SolidFillColor.Color = Color.Gold;
rectangle.TextFrame.Text = "Wheel transition";

presentation.Slides.AddClone(blackSlide);
presentation.Slides.AddClone(destinationSlide);

var spokeCounts = new uint[] { 1, 8 };
for (var i = 0; i < spokeCounts.Length; i++)
{
    var transition = presentation.Slides[i * 2 + 1].SlideShowTransition;
    transition.Type = TransitionType.Wheel;
    var wheelTransition = (IWheelTransition)transition.Value;
    wheelTransition.Spokes = spokeCounts[i];
    transition.Speed = TransitionSpeed.Slow;
    transition.Duration = 8000;
}

presentation.Save("wheel-transitions.pptx", SaveFormat.Pptx);

Open the output presentation in PowerPoint and run the slide show. Advance from slide 1 to slide 2, then from slide 3 to slide 4. In PowerPoint playback, the verified spoke count of 1 reveals the slide with one clockwise sweep; the verified count of 8 reveals it through eight radial sectors simultaneously. The destination content and transition timing are identical, so the difference is the number of reveal sectors.

Set Flythrough Direction and Bounce

On the destination slide, set the transition Type to TransitionType.Flythrough before accessing Value as IFlyThroughTransition. The selected type determines which settings are available. Set Direction to In or Out from TransitionInOutDirectionType to choose the direction of travel. Enable HasBounce to add a bounce to the movement.

The example creates a slide with a rectangle and a slide with a circle, then clones the pair. Both transitions use the inward direction and last two seconds. Only the second has a bounce.

using Aspose.Slides;
using Aspose.Slides.Export;
using Aspose.Slides.SlideShow;

using var presentation = new Presentation();

var source = presentation.Slides[0];
var destination = presentation.Slides.AddEmptySlide(source.LayoutSlide);
source.Shapes.AddAutoShape(ShapeType.Rectangle, 50, 100, 240, 150);
destination.Shapes.AddAutoShape(ShapeType.Ellipse, 380, 200, 200, 200);

presentation.Slides.AddClone(source);
var destinationWithBounce = presentation.Slides.AddClone(destination);

foreach (var slide in new[] { destination, destinationWithBounce })
{
    var transition = slide.SlideShowTransition;
    transition.Type = TransitionType.Flythrough;
    transition.Duration = 2000;
    
    var flythrough = (IFlyThroughTransition)transition.Value;
    flythrough.Direction = TransitionInOutDirectionType.In;
    flythrough.HasBounce = slide == destinationWithBounce;
}

presentation.Save("flythrough.pptx", SaveFormat.Pptx);

Open flythrough.pptx in PowerPoint and press F5 to start the slide show. Advance from slide 1 to slide 2 to see the movement without a bounce, then from slide 3 to slide 4 to see it with a bounce. Static slide images show only the shapes at rest.

Side-by-side PowerPoint playback of the inward Flythrough transition without a bounce on the left and with a bounce on the right.

Fade Through Black with the Reveal Transition

Set the destination slide’s transition type to Reveal, then use IRevealTransition to set ThroughBlack. The example creates a teal source slide and a coral destination slide, then clones both so you can compare the same two-second transition with the fade disabled and enabled.

using System.Drawing;
using Aspose.Slides;
using Aspose.Slides.Export;
using Aspose.Slides.SlideShow;

using var presentation = new Presentation();

var source = presentation.Slides[0];
var destination = presentation.Slides.AddClone(source);
StyleSlide(source, Color.Teal, "Source");
StyleSlide(destination, Color.Coral, "Destination");
presentation.Slides.AddClone(source);
presentation.Slides.AddClone(destination);

foreach (var index in new[] { 1, 3 })
{
    var transition = presentation.Slides[index].SlideShowTransition;
    transition.Type = TransitionType.Reveal;
    transition.Speed = TransitionSpeed.Slow;
    transition.Duration = 2000;

    var reveal = (IRevealTransition)transition.Value;
    reveal.Direction = TransitionLeftRightDirectionType.Left;
    reveal.ThroughBlack = index == 3;
}

presentation.Save("reveal-transitions.pptx", SaveFormat.Pptx);

void StyleSlide(ISlide slide, Color background, string label)
{
    slide.Background.Type = BackgroundType.OwnBackground;
    slide.Background.FillFormat.FillType = FillType.Solid;
    slide.Background.FillFormat.SolidFillColor.Color = background;

    var shape = slide.Shapes.AddAutoShape(ShapeType.Rectangle, 160, 180, 400, 130);
    shape.TextFrame.Text = label;
    shape.TextFrame.Paragraphs[0].Portions[0].PortionFormat.FontHeight = 44;
}

In a PowerPoint slide show, advance from slide 1 to slide 2. Teal fades directly into coral. Then advance from slide 3 to slide 4. The screen briefly darkens to near black before the coral slide appears. Both slides keep their original background colors.

The rows below show frames from PowerPoint at half-second intervals. Compare the middle frame in each row to see the effect of the setting.

PowerPoint playback with ThroughBlack disabled (top) and enabled (bottom). Only the bottom row passes through near black.

Add Advanced Slide Transition

You can configure how long a slide remains on screen and whether a mouse click advances the slide show. The following properties control this behavior:

Enable both click and timed advancement to let the viewer move on with a click or wait for the timer. To use only the timer, set AdvanceOnClick to false. The delay controls when the slide show advances; it does not set the duration of the visual transition effect.

This example assigns different effects to the first three slides and enables automatic advancement after 3, 5, and 7 seconds, respectively. Mouse clicks can also advance these slides. Use an input.pptx file with at least three slides.

using System;
using Aspose.Slides;
using Aspose.Slides.Export;
using Aspose.Slides.SlideShow;

using var presentation = new Presentation("input.pptx");

if (presentation.Slides.Count >= 3)
{
    var firstTransition = presentation.Slides[0].SlideShowTransition;
    firstTransition.Type = TransitionType.Circle;
    firstTransition.AdvanceOnClick = true;
    firstTransition.AdvanceAfter = true;
    firstTransition.AdvanceAfterTime = 3000;

    var secondTransition = presentation.Slides[1].SlideShowTransition;
    secondTransition.Type = TransitionType.Comb;
    secondTransition.AdvanceOnClick = true;
    secondTransition.AdvanceAfter = true;
    secondTransition.AdvanceAfterTime = 5000;

    var thirdTransition = presentation.Slides[2].SlideShowTransition;
    thirdTransition.Type = TransitionType.Zoom;
    thirdTransition.AdvanceOnClick = true;
    thirdTransition.AdvanceAfter = true;
    thirdTransition.AdvanceAfterTime = 7000;

    presentation.Save("advanced-transitions.pptx", SaveFormat.Pptx);
}
else
{
    Console.WriteLine("The input presentation must contain at least three slides.");
}

To check whether timed advancement is enabled, read AdvanceAfter. A stored delay alone does not indicate that the timer is active.

The next example opens the file saved above, reports each enabled timer, and disables automatic advancement for slides with a delay greater than two seconds. It enables mouse clicks for those slides and saves the updated settings.

using System;
using Aspose.Slides;
using Aspose.Slides.Export;

using var presentation = new Presentation("advanced-transitions.pptx");

foreach (var slide in presentation.Slides)
{
    var transition = slide.SlideShowTransition;

    if (transition.AdvanceAfter)
    {
        Console.WriteLine($"Slide {slide.SlideNumber}: advance after {transition.AdvanceAfterTime} ms.");

        if (transition.AdvanceAfterTime > 2000)
        {
            transition.AdvanceAfter = false;
            transition.AdvanceOnClick = true;
        }
    }
}

presentation.Save("adjusted-transitions.pptx", SaveFormat.Pptx);

Control Transition Timing Precisely

Use Duration to specify the exact length of a transition effect in milliseconds. The slide’s SlideShowTransition property exposes these settings through ISlideShowTransition:

Property Purpose
Duration Sets the duration of the transition effect itself, in milliseconds.
AdvanceAfterTime Sets the delay before the slide advances automatically, in milliseconds. Enable AdvanceAfter to activate this timer.
Speed Selects a predefined speed category from TransitionSpeed: Slow, Medium, or Fast. It is used when an exact duration is not specified.

Duration controls only the transition effect; it does not determine how long the slide remains visible. Configure the automatic advancement delay separately. When no explicit duration is set, Aspose.Slides determines the effect duration from the transition type and Speed value.

Apply the Same Duration to Every Slide

For consistent pacing, apply the same effect and exact duration to every slide. This example loads input.pptx, selects Fade from TransitionType, and gives each transition a duration of 750 milliseconds. It separately enables automatic advancement after 5,000 milliseconds and disables advancement by mouse click, then saves the result as PPTX.

using Aspose.Slides;
using Aspose.Slides.Export;
using Aspose.Slides.SlideShow;

using var presentation = new Presentation("input.pptx");

foreach (var slide in presentation.Slides)
{
    var transition = slide.SlideShowTransition;
    transition.Type = TransitionType.Fade;
    transition.Duration = 750;

    // Configure automatic advancement independently of the effect duration.
    transition.AdvanceAfter = true;
    transition.AdvanceAfterTime = 5000;
    transition.AdvanceOnClick = false;
}

presentation.Save("precise-transitions.pptx", SaveFormat.Pptx);

Set Different Durations for Individual Slides

Different slides can use different effect durations. For example, use a brief transition for a title slide and a longer transition for a section introduction. This example sets 500 milliseconds for the first slide and 1,200 milliseconds for the second. Use an input.pptx file with at least two slides.

using System;
using Aspose.Slides;
using Aspose.Slides.Export;
using Aspose.Slides.SlideShow;

using var presentation = new Presentation("input.pptx");

if (presentation.Slides.Count >= 2)
{
    var firstTransition = presentation.Slides[0].SlideShowTransition;
    firstTransition.Type = TransitionType.Fade;
    firstTransition.Duration = 500;

    var secondTransition = presentation.Slides[1].SlideShowTransition;
    secondTransition.Type = TransitionType.Push;
    secondTransition.Duration = 1200;

    presentation.Save("individual-transition-durations.pptx", SaveFormat.Pptx);
}
else
{
    Console.WriteLine("The input presentation must contain at least two slides.");
}

Coordinate Transitions with Animated Output

When preparing an animated GIF, HTML5 presentation, or video, set exact transition durations before export to match the intended pacing. For example, use a 600-millisecond fade between scenes, and adjust each slide’s advancement delay separately to allow time for its narration or content.

For GIF and video, coordinate the output frame rate with the effect duration: 600 milliseconds corresponds to 18 frames at 30 frames per second. In HTML5, enable animated transitions in the export settings. Check the chosen export format’s supported effects and timing options, and preview the output to confirm synchronization.

Read an Existing Transition Duration

Read Duration before modifying the transition to determine whether an explicit value is stored. A value of -1 means no explicit duration is set; a nonnegative value specifies the stored duration in milliseconds. The unset value is not the calculated playback duration: Aspose.Slides uses the transition type and Speed to determine that duration. Setting a transition type can initialize a duration, so inspect the original settings first.

using System;
using Aspose.Slides;

using var presentation = new Presentation("input.pptx");

foreach (var slide in presentation.Slides)
{
    var transition = slide.SlideShowTransition;
    var duration = transition.Duration;

    if (duration >= 0)
    {
        Console.WriteLine($"Slide {slide.SlideNumber}: stored transition duration is {duration} ms.");
    }
    else
    {
        Console.WriteLine($"Slide {slide.SlideNumber}: no explicit duration; timing depends on {transition.Type} and {transition.Speed}.");
    }
}

Morph Transition

The Morph transition animates changes between objects on consecutive slides. To create a simple Morph effect, clone a slide, move or resize an object on the clone, and apply the Morph transition to the second slide. This gives the transition corresponding objects to animate between their original and modified states.

The following example creates a slide with a text rectangle, clones the slide, and changes the rectangle’s position and size on the clone. It then selects Morph from the TransitionType enumeration for the second slide. Open the saved file in a presentation viewer that supports Morph to see the effect during a slide show.

using Aspose.Slides;
using Aspose.Slides.Export;
using Aspose.Slides.SlideShow;

using var presentation = new Presentation();

var firstSlide = presentation.Slides[0];
var rectangle = firstSlide.Shapes.AddAutoShape(ShapeType.Rectangle, 100, 100, 400, 100);
rectangle.TextFrame.Text = "Morph transition";

var secondSlide = presentation.Slides.AddClone(firstSlide);
var movedRectangle = secondSlide.Shapes[0];
movedRectangle.X += 100;
movedRectangle.Y += 50;
movedRectangle.Width -= 200;
movedRectangle.Height -= 10;

secondSlide.SlideShowTransition.Type = TransitionType.Morph;

presentation.Save("morph-transition.pptx", SaveFormat.Pptx);

Morph Transition Types

The TransitionMorphType enumeration controls how Morph matches and animates content:

  • ByObject treats each shape as a whole object.
  • ByWord animates text by matching words where possible.
  • ByChar animates text by matching characters where possible.

Set the transition Type to Morph before accessing its Value. The value then provides the IMorphTransition interface, whose MorphType property selects the matching mode.

This example opens the presentation created in the previous section and configures the second slide to use word-based Morph animation.

using System;
using Aspose.Slides;
using Aspose.Slides.Export;
using Aspose.Slides.SlideShow;

using var presentation = new Presentation("morph-transition.pptx");

if (presentation.Slides.Count >= 2)
{
    var transition = presentation.Slides[1].SlideShowTransition;
    transition.Type = TransitionType.Morph;

    if (transition.Value is IMorphTransition morphTransition)
    {
        morphTransition.MorphType = TransitionMorphType.ByWord;
        presentation.Save("morph-by-word.pptx", SaveFormat.Pptx);
    }
    else
    {
        Console.WriteLine("Morph transition options are unavailable.");
    }
}
else
{
    Console.WriteLine("The input presentation must contain at least two slides.");
}

Morph matching units shown as a whole shape, individual words, and individual characters.

Morph can match whole shapes, words or characters where possible. These boxes identify matching units rather than observed motion. The example selects ByWord on the second slide.

Set Transition Effects

Some transitions expose additional options, such as direction or whether the effect starts from a black screen. The available options depend on the selected transition Type. Set the type first, then use the appropriate interface from its Value.

The following example applies a Cut transition to the first slide of input.pptx. It sets FromBlack through IOptionalBlackTransition so that the transition starts from a black screen.

using System;
using Aspose.Slides;
using Aspose.Slides.Export;
using Aspose.Slides.SlideShow;

using var presentation = new Presentation("input.pptx");
var transition = presentation.Slides[0].SlideShowTransition;
transition.Type = TransitionType.Cut;

if (transition.Value is IOptionalBlackTransition cutTransition)
{
    cutTransition.FromBlack = true;
    presentation.Save("cut-from-black.pptx", SaveFormat.Pptx);
}
else
{
    Console.WriteLine("Cut transition options are unavailable.");
}

FAQ

Can I control the playback speed of a slide transition?

Yes. Prefer Duration when you need an exact effect duration in milliseconds. Use Speed when a predefined TransitionSpeed category—Slow, Medium, or Fast—is sufficient and no explicit duration is set. These settings control the transition effect independently of the automatic advancement delay.

Can I attach audio to a transition and make it loop?

Yes. Assign embedded audio to Sound, set SoundMode to StartSound from the TransitionSoundMode enumeration, and enable SoundLoop. The audio loops until the next sound event in the slide show.

What’s the fastest way to apply the same transition to every slide?

Loop through the presentation’s Slides collection and set each slide’s transition Type to the same value. Set any timing and effect options in the same loop to keep the behavior consistent across slides.

How can I check which transition is currently set on a slide?

Read the Type property from the slide’s SlideShowTransition. It returns a value from the TransitionType enumeration; None means that no transition effect is applied.