joshdholtz/DeckUI

Custom transitions per `Slide`

yonomitt opened this issue · 1 comments

A feature that might be useful would be to customize a transition on a per slide basis. The Presenter could still be the source for the default transition for the entire Deck, but each Slide could contain their own preferred SlideDirection (or in the future SlideTransition #5), which would override the default.

This could be accomplished by including a:

public struct Slide: Identifiable {
    ...
    let slideDirection: SlideDirection?
    ...
}

And then changing Presenter.nextSlide() to look something like:

private func nextSlide() {
    let slides = self.deck.slides()
    if self.index >= (slides.count - 1) {
        if self.loop {
            self.index = 0
        }
    } else {
        self.index += 1
    }

    let newSlide = slides[self.index]
    self.activeTransition = (newSlide.slideDirection self.slideDirection).next
}

Something similar could be done for Presenter.prevSlide()

I will see if I can get a PR for this soon