Events
Events happen in the iframed flipbook and are emitted to the parent window. Our API catches these emitted events and invoke magic callbacks, which can be used to execute business-specific logic in the parent window, in response to specific events that have occurred in the iframed flipbook.
Overview
Events are dispatched from the iframed flipbook to the Javascript API via window.postMessage()
. Once the API receives this event, it then invokes a callback present in the parent window.
Publication-related events
onPageElementClick
onPageElementClick
Fired when an enrichment/link with a shop item action is clicked.
Note:
Current only shop items will fire this event. Click events on any other enrichments are not emitted.
Property | Type | Description |
---|---|---|
|
| The page element type that was clicked on |
|
| Data associated with the page element |
|
| Shop item title |
|
| Shop item description |
|
| Shop item product ID |
|
| Shop item price |
|
| If users are allowed to manually specify an amount before adding to basket |
|
| Number of items per package |
|
| Event data associated with the click event |
|
| Page number on which the page element is located on |
|
| Page numbers on which the spread where the page element is located on |
|
| Absolute x coordinate of the click event |
|
| Absolute y coordinate of the click event |
|
| Ratio of the x coordinate relative to book width |
|
| Ratio of the y coordinate relative to book height |
onSpreadChange
onSpreadChange
Fired when a paging event is registered in the flipbook.
Property | Type | Description |
---|---|---|
|
| Page numbers that are in the current spread |
|
| Page number(s) that are currently in view. This array may contain one or two numbers, depending if the current view is page- (mobile/tablet in portrait) or spread-based (desktop, or mobile/tablet in landscape). |
Shop-related events
onBasketClick
onBasketClick
Fired when the basket icon is clicked to reveal the basket in the sidebar. There is no data returned by this event.
onItemAdd
onItemAdd
Fired when a shop item has been added to the basket.
Property | Type | Description |
---|---|---|
|
| Shop item title |
|
| Shop item description |
|
| Shop item product ID |
|
| Shop item price |
|
| Page index where the shop item is located* (see note) |
|
| Page number where the shop item is located |
|
| Number of items added |
|
| Number of items per package |
Note:
Please note that pageIndex
starts at 0
. So the 1st page of your flipbook will have a pageIndex
of 0
, page 2 a pageIndex
of 1
and so on. To get the actual pagenumber you should use originPage
instead.
Advanced use
If you are accustomed to listening to events instead, that is possible with this API: simply bind the event listener to the iframe element:
The two options presented below are functionally identical.
Refer to Event listeners and command triggers on the advanced usage page for a wholesome example.
Last updated