Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ability to know when profile has loaded in iframe #17

Open
liamsnowdon opened this issue Jun 2, 2024 · 2 comments
Open

Ability to know when profile has loaded in iframe #17

liamsnowdon opened this issue Jun 2, 2024 · 2 comments
Assignees

Comments

@liamsnowdon
Copy link

Hi, thanks for the awesome tool. Works great :)

One thing that would be useful when using the iframe is to know when the html changes from the initial loading state to the profile state. As far as I can see there is no easy way of doing this. I think this could be achieved by posting a message to the parent like this:

window.parent.postMessage({
  state: 'loaded'
})

Then whenever the iframe is used, the post message can be listened to using:

window.addEventListener('message', (event) => {
  if (event.origin !== 'https://gamer2810.github.io') {
    return
  }

  // Do something with message
})
@gamer2810
Copy link
Owner

Hello, thanks for the nice suggestion.

I have added the message, please try it out and see if it fits your needs.

@gamer2810 gamer2810 self-assigned this Jun 6, 2024
@liamsnowdon
Copy link
Author

Thanks for adding the message :)

I see it coming through now and was planning to use it to dynamically change the height of the iframe when its contents changing. For example, it can go from 210px in height for the initial loading state and then changes to 266px if you're online and playing a game. The problem is I can't get the height of the body because it's cross-origin. Without changing the height of the actual iframe it can leave a big gap underneath the iframe if you're offline and a lot of data isn't there to expand the height.

Have any other ideas for this? 🤔 The height could be added to the post message, I guess, or maybe some property to indicate offline, online, playing etc - I'm not sure if there are set heights based on that. I'd like to use the iframe method instead of injecting the html directly onto the page if possible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants