Skip to content

Fix _isgloabl flag in ini method #7785

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 8 additions & 14 deletions src/core/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class p5 {
//////////////////////////////////////////////
// PUBLIC p5 PROPERTIES AND METHODS
//////////////////////////////////////////////

this._isGlobal = !sketch;
/**
* A function that's called once to load assets before the sketch runs.
*
Expand Down Expand Up @@ -286,7 +286,6 @@ class p5 {
this._glAttributes = null;
this._requestAnimId = 0;
this._preloadCount = 0;
this._isGlobal = false;
this._loop = true;
this._startListener = null;
this._initializeInstanceVariables();
Expand Down Expand Up @@ -661,21 +660,11 @@ class p5 {
// ensure correct reporting of window dimensions
this._updateWindowSize();

// call any registered init functions
this._registeredMethods.init.forEach(function(f) {
if (typeof f !== 'undefined') {
f.call(this);
}
}, this);
// Set up promise preloads
this._setupPromisePreloads();

const friendlyBindGlobal = this._createFriendlyGlobalFunctionBinder();

// If the user has created a global setup or draw function,
// assume "global" mode and make everything global (i.e. on the window)
if (!sketch) {
this._isGlobal = true;
if (this._isGlobal) {
p5.instance = this;
// Loop through methods on the prototype and attach them to the window
for (const p in p5.prototype) {
Expand Down Expand Up @@ -709,8 +698,13 @@ class p5 {
// detects capitalization mistakes only ( Setup, SETUP, MouseClicked, etc)
p5._checkForUserDefinedFunctions(this);
}

// Bind events to window (not using container div bc key events don't work)
this._updateWindowSize();

// call any registered init functions
this.callRegisteredHooksFor('init');
// Set up promise preloads
this._setupPromisePreloads();

for (const e in this._events) {
const f = this[`_on${e}`];
Expand Down