This feature is experimental. Please share your experiences so we know what to keep or change.
Runs another preview function.
To run another preview function registered with up.preview()
, pass it's
name:
up.preview('foo', function(preview) { // mark-phrase "'foo'"
// ...
})
up.preview('bar', function(preview) {
preview.run('foo') // mark-phrase "'foo'"
})
All undo callbacks from the other preview will be added to this preview.
In the example below, preview2
will call both undo1()
and
undo2()
when the preview ends:
function undo1() { ... }
function undo2() { ... }
up.preview('preview1', function(preview) {
preview.undo(undo1)
})
up.preview('preview2', function(preview) {
preview.run('preview1')
preview.undo(undo2)
})
To call a preview with parameters, pass an options object as a second argument:
up.preview('foo', function(preview, { size, speed }) {
// ...
})
up.preview('bar', function(preview) {
preview.run('foo', { size: 'large', speed: 'fast' })
})
Instead of running a preview by its registered name,
you can pass any function that accepts an up.Preview
argument.
This is a way to share common behavior between multiple preview functions:
function shared(preview) {
// ...
}
up.preview('foo', function(preview) {
preview.run(shared)
})
up.preview('bar', function(preview) {
preview.run(shared)
})
Another preview function or its registered name.
Parameters that will be passed to the other preview function.