Advanced Usage
Multiple Flipbooks
<iframe src="https://demo.ipaper.io" data-ipaper></iframe>var anotherIPaper = document.getElementById('another-flipbook')
var anotherIPaperAPI = new _iPaperAPI(anotherIPaper);Example
<!doctype html>
<html>
<head>
<title>Multiple iframed flipbooks</title>
<!-- Start of async iPaper Flipbook API script -->
<!-- NOTE: The entire code snippet below can be obtained directly from the Admin. Refer to our help article for further information. -->
<script>
(function(i,P,a,p,e,r){if(i.getElementById(a=a+'-'+e))return;
r=i.querySelector(P).parentNode.appendChild(i.createElement(P));
r.id=a;r.async=1;r.src=p+'/'+e+'.js'})
(document,'script','ipaper-api','<ApiBaseUrl>','<ApiSecret>');
</script>
<!-- End of async iPaper Flipbook API script -->
<script>
function iPaperInit() {
// Listen to event from the default iframe flipbook
// This is the default API instance
iPaperAPI.onSpreadChange = function(data) {
console.log('onSpreadChange event detected in default flipbook', data);
};
// Listen to event from a second iframe flipbook
// Create new API instance first
var anotherIPaper = document.getElementById('yet-another-flipbook')
var anotherIPaperAPI = new _iPaperAPI(anotherIPaper);
anotherIPaperAPI.onSpreadChange = function(data) {
console.log('onSpreadChange event detected in second flipbook', data);
};
}
</script>
</head>
<body>
<!-- Remember to add the HMTL5 `data-ipaper` attribute to the default iframe -->
<iframe src="https://demo.ipaper.io" style="width: 100%; height: 400px;" data-ipaper></iframe>
<!-- Subsequent iframes can be identified by any means, but we use ID for convenience -->
<iframe src="https://demo.ipaper.io" style="width: 100%; height: 400px;" id="yet-another-flipbook"></iframe>
</body>
</html>Event listeners and command triggers
Last updated