Skip to content

Commit

Permalink
- Added portalRequestAppletData
Browse files Browse the repository at this point in the history
- Updated version to v3.0.7
  • Loading branch information
ct-gilford committed Oct 7, 2022
1 parent 219bdff commit ecbb6ba
Show file tree
Hide file tree
Showing 3 changed files with 5,006 additions and 3 deletions.
22 changes: 22 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -321,3 +321,25 @@ export class Copyright {
}
}

// 1. used by non-Phaser games
// 2.. tell parent window ready for appletData
// 3. wait for parent window to postMessage with appletData
// 4. call callback with the supplied appletData
export function portalRequestAppletData(callback) {
// do only if embeded
if (window.parent !== window) {
// listen for events from parents: pause, unpause and appletData
window.addEventListener('message', ev => {
const { type, params } = ev;
// console.log('message:', { type, params });
if (type === 'appletData') {
callback(params);
}
});

// tell parent i am ready
window.parent.postMessage('requestAppletData', '*');
} else {
callback(null);
}
}
Loading

0 comments on commit ecbb6ba

Please sign in to comment.