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

Update demo editor "Run" button to be deactivated until Pyodide finishes loading #197

Closed
berinhard opened this issue Nov 2, 2021 · 2 comments · Fixed by #201
Closed
Labels
Demo Editor Issues related to the demo editor Good First Issue

Comments

@berinhard
Copy link
Owner

Currently, if the users click on the "Run" button before the demo sketch appears, they get the following error:

Uncaught TypeError: window.runSketchCode is not a function
    runCode https://berinhard.github.io/pyp5js/pyodide/:104
    <anonymous> https://berinhard.github.io/pyp5js/pyodide/:124
    jQuery 2

But when the sketch starts to run, the run button gets back to work properly. It's probable that issue #189 will make it easier to implement this feature.

@berinhard berinhard added Demo Editor Issues related to the demo editor Good First Issue labels Nov 2, 2021
@jvfe
Copy link
Contributor

jvfe commented Nov 5, 2021

A simple, but not ideal, fix would be to change these lines to be:

$("#executeBtn").on("click", () => { if (window.instance) { runCode() }; });
$("#clearBtn").on("click", () => { if (window.instance) { window.instance.remove() }; });

Then the click event would only be fired once p5's window.instance object is created.

@berinhard
Copy link
Owner Author

@jvfe I think what you're suggesting is very reasonable. Maybe we can add an else condition to the executeBtn logic to display an alert box with a message like: "Pyodide is still loading. Please, wait a few seconds and try to run it again."

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Demo Editor Issues related to the demo editor Good First Issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants