Build a page-turn book and mount it into an element without wiring the descriptor by hand.
Module graphic.pageflip/create | Type constructible helper (not a module descriptor, not a graphicModules member) | Source packages/front/graphic/anim/src/pageflip/create.js | Deps the shared helper runtime, graphic.pageflip | Worker-safe no
Descriptor
There is no descriptor. createPageflip(el, opts) acquires the shared runtime
(registerDeep of the graphic.pageflip descriptor and its whole deps
closure), resolves graphic.pageflip, constructs a Pageflip from opts and
mounts it into el. It composes the module; it re-implements nothing and
touches no descriptor.
API
| Export | Signature | Description |
|---|---|---|
createPageflip |
(el: Element, opts: PageflipOptions) => PageflipHandle |
Build the book, mount it, return the handle. |
PageflipHandle:
| Member | Meaning |
|---|---|
instance |
The live Pageflip with its full public API (next, previous, goTo, currentId, index, pageCount, el, …). |
dispose() |
Idempotent teardown: disposes the instance (stops in-flight turns, detaches the subtree), then releases this handle's share of the shared runtime. |
opts is forwarded verbatim to the Pageflip constructor: every option keeps
its meaning and default (see pageflip/pageflip),
including scheduler. The helper adds no option.
Examples
const book = createPageflip(document.querySelector('#stage'), {
pages: [{ id: 'p1' }, { id: 'p2' }],
width: 400, height: 560, duration: 500,
});
book.instance.next();
book.dispose();
Notes
- Throws:
createPageflip: el must be an elementwhenelis absent or has noreplaceChildren; plus everyPageflipconstructor error (emptypages, non-positivewidthorheight), propagated unchanged. On a constructor failure the helper releases its runtime share first, so a failed call leaks nothing. - Mounting uses
Pageflip#mountInto(el): the book's<svg>becomes the sole child ofel(replaceChildren). - The runtime is shared across calls and with
createHypertree, so onegraphic.schedulerserves all of them; the default id prefix comes from a counter inside the resolved factory, so books from the same runtime get distinct ids. An explicitopts.prefixwins. - The runtime is reference-counted: the last
dispose()releases it. - Not Worker-safe (element-anchored); the pure kernels it composes stay Worker-safe.
optsis the fullPageflipOptionsof the pageflip page (the typedef is imported fromsrc/pageflip/pageflip.js).
See also
- pageflip/pageflip — the module and its options
- helpers/shared-runtime — the shared runtime
- main — the public entry that exports the helper
- pageflip guide — the long form