API overview
See also Diaporama by Examples.
Create a Diaporama
var diaporama = Diaporama(container, data, props)
container(DOM Element) (required) : you must provide an (empty) DOM element container in which the Diaporama will be created.data(Object) : data of the diaporama (e.g; extracted from adiaporama.json), The format is described in JSON Data Format.props(Object) : initial properties of the Diaporama. (datacan also be passed in this object – in that case you can givepropsas second parameter).
Properties:
N.B.: Every properties initially defined in props can also be accessed or set on a
diaporamainstance and the diaporama will always keep things synchronized based on your changes. (Diaporama uses JavaScript'sdefineProperties)
loop(boolean)autoplay(boolean)data(object)width(number in pixels)height(number in pixels)resolution(number)currentTime(number in milliseconds)slide(number)playbackRate(number)paused(boolean)duration(number in milliseconds, read-only)renderingMode(read-only)networkTimeout(number in milliseconds)currentRenderState(read-only)timeBuffered(read-only)
For more details on each property, See Diaporama Properties section.
Methods:
Diaporama has a few helper methods usually on top of Properties:
play(): setpausedto false.pause(): setpausedto true.next([duration]): setcurrentTimeto the time of the next slide. If duration is provided, there is a transition to go to the next slide time.prev([duration]): setcurrentTimeto the time of the previous slide. If duration is provided, there is a transition to go to the previous slide time.jump(slideIndex, [duration]): setcurrentTimeto jump to a specific slide by its index. If duration is provided, there is a transition to go to the requested slide time.feed(observable, opts): give an observable (stream) to feed the diaporama timeline over time. The observed values can be a slide OR an array of slides. Note: an observable has asubscribe(onNext,onError,onCompleted)method that returns a disposable (with adispose()function). You can use RxJS withfeed().
Events:
Diaporama have events that let you watch and react on changes:
canplay,canplaythrough,load,progressdestroyerrorresizeplay,pauserenderendedtransition,transitionEndslide,slideEnd
The
diaporamaobject is anEventEmitterso it haves the same API:on,once,removeListener,... Refer to Event Emitter documentation.
For more details on Events, See Diaporama Events section.