Skip to content

Commit

Permalink
2.7.3
Browse files Browse the repository at this point in the history
  • Loading branch information
quinton-ashley committed Oct 20, 2024
1 parent 85bf3cd commit b12d802
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 22 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "q5",
"version": "2.7.2",
"version": "2.7.3",
"description": "A sequel to p5.js that's optimized for interactive art",
"author": "quinton-ashley",
"contributors": [
Expand Down
18 changes: 8 additions & 10 deletions q5.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ function Q5(scope, parent, renderer) {
$._renderer = renderer || 'q2d';
$._preloadCount = 0;

let autoLoaded = scope == 'auto';
scope ??= 'global';
if (scope == 'auto') {
if (!(window.setup || window.draw)) return;
Expand Down Expand Up @@ -201,7 +202,7 @@ function Q5(scope, parent, renderer) {

let t = globalScope || $;
$._isTouchAware = t.touchStarted || t.touchMoved || t.mouseReleased;
let preloadDefined = t.preload;

if ($._isGlobal) {
$.preload = t.preload;
$.setup = t.setup;
Expand Down Expand Up @@ -239,9 +240,9 @@ function Q5(scope, parent, renderer) {
}
}

async function _start() {
async function _setup() {
$._startDone = true;
if ($._preloadCount > 0) return raf(_start);
if ($._preloadCount > 0) return raf(_setup);
millisStart = performance.now();
await $.setup();
$._setupDone = true;
Expand All @@ -251,21 +252,18 @@ function Q5(scope, parent, renderer) {
raf($._draw);
}

function _preStart() {
function _start() {
try {
$.preload();
if (!$._startDone) _start();
if (!$._startDone) _setup();
} catch (e) {
if ($._askAI) $._askAI(e);
throw e;
}
}

if (preloadDefined || $._isGlobal) {
_preStart();
} else {
setTimeout(_preStart, 32);
}
if (autoLoaded) _start();
else setTimeout(_start, 32);
}

Q5.renderers = {};
Expand Down
2 changes: 1 addition & 1 deletion q5.min.js

Large diffs are not rendered by default.

18 changes: 8 additions & 10 deletions src/q5-core.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ function Q5(scope, parent, renderer) {
$._renderer = renderer || 'q2d';
$._preloadCount = 0;

let autoLoaded = scope == 'auto';
scope ??= 'global';
if (scope == 'auto') {
if (!(window.setup || window.draw)) return;
Expand Down Expand Up @@ -201,7 +202,7 @@ function Q5(scope, parent, renderer) {

let t = globalScope || $;
$._isTouchAware = t.touchStarted || t.touchMoved || t.mouseReleased;
let preloadDefined = t.preload;

if ($._isGlobal) {
$.preload = t.preload;
$.setup = t.setup;
Expand Down Expand Up @@ -239,9 +240,9 @@ function Q5(scope, parent, renderer) {
}
}

async function _start() {
async function _setup() {
$._startDone = true;
if ($._preloadCount > 0) return raf(_start);
if ($._preloadCount > 0) return raf(_setup);
millisStart = performance.now();
await $.setup();
$._setupDone = true;
Expand All @@ -251,21 +252,18 @@ function Q5(scope, parent, renderer) {
raf($._draw);
}

function _preStart() {
function _start() {
try {
$.preload();
if (!$._startDone) _start();
if (!$._startDone) _setup();
} catch (e) {
if ($._askAI) $._askAI(e);
throw e;
}
}

if (preloadDefined || $._isGlobal) {
_preStart();
} else {
setTimeout(_preStart, 32);
}
if (autoLoaded) _start();
else setTimeout(_start, 32);
}

Q5.renderers = {};
Expand Down

0 comments on commit b12d802

Please sign in to comment.