Skip to content

louv api

Pawel Przezwanski edited this page Jan 27, 2020 · 4 revisions

1. Presentational methods with the same optional arguments:

There three methods that present picture: 'presentPicture', 'loop', 'next'. They all accept the same optional arguments that are interpreted in the same way. See explanation

Method Description
presentPicture Present specified picture with scenario given by picture data-scenario or if not set will take next scenario from scenarios array. Returns a promise that resolves when picture is fully presented (phase 'present' from scenario is completed
next Hide current picture and shows next one (or if { upstream: true } shows previous picture. Returns a promise that resolves when next picture is fully presented (phase 'present' from scenario is completed
loop Loop pictures by applying intelligently presentPicture and next methods. Returns a promise that resolves when first picture in a loop is fully presented (phase 'present' from scenario is completed

2. other methods:

Method Description
hidePicture Hides currently active picture with current scenario's phase 'hide'. Returns a promise that resolves when picture is fully hidden (phase 'hide' from scenario is completed). Optional argument: type: boolean, default: false - if true picture will ignore scenario and hide and resolve its promise immediately
pause finish current morph and pause current scenario. Chainable (returns this)
continue continue with next morph from current scenario on current picture. Chainable (returns this). Optional argument: type: number, default: undefined - if specified it will continue with picture of specified id from the beginning of its scenario.
unloop terminate loop. Chainable (returns this)
hide hide gallery by setting style.opacity = '0'. Chainable (returns this). Optional argument: type: number, default: 0 - set number of millisecond that will take to fully fade out
show show gallery by setting style.opacity = '1'. Chainable (returns this). Optional argument: type: number, default: 0 - set number of millisecond that will take to fully fade in
deactivate apply class with { display: none } on gallery element. Chainable (returns this).
activate remove class with { display: none } from gallery element. Chainable (returns this)
flatten make gallery occupy only one browsers layer and shrink as kind of soft deactivation that does not produce big recalculate style durations (too understand how please look into louv.scss file). Chainable (returns this). Argument: type: boolean, default: true - if false picture will not shrink.
unflatten make gallery fully activated and its every morph occupy one browsers layer. Chainable (returns this)

3. Promises:

Promise Description
this.promiseTo.beReady resolves when init method has done its work and gallery is ready to present first picture
this.promiseTo.finishAnimation if during animation Louv sets a promise that resolves when animation is finished. So if we don't want to interupt the morph animation we can await it with this promise. But remember that promise is set only when animation starts
this.promiseTo.finishLoading if louv is loading it sets a promise that will resolve when loading is finished
** this.promiseTo.loadAllPictures resolves when all pictures are loaded
** this.picturesPromises an array of all pictures promises. Available after as soon as promiseTo.beReady is resolved