Skip to content

Commit 3803358

Browse files
authored
Merge branch 'main' into main
2 parents c5ed762 + b293b9c commit 3803358

File tree

8 files changed

+67
-22
lines changed

8 files changed

+67
-22
lines changed

.all-contributorsrc

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6813,6 +6813,44 @@
68136813
"bug",
68146814
"doc"
68156815
]
6816+
},
6817+
{
6818+
"login": "clairep94",
6819+
"name": "Claire Peng",
6820+
"avatar_url": "https://avatars.githubusercontent.com/u/128436909?v=4",
6821+
"profile": "https://github.com/clairep94",
6822+
"contributions": [
6823+
"code",
6824+
"bug"
6825+
]
6826+
},
6827+
{
6828+
"login": "IIITM-Jay",
6829+
"name": "Jay Dev Jha",
6830+
"avatar_url": "https://avatars.githubusercontent.com/u/65283880?v=4",
6831+
"profile": "https://github.com/IIITM-Jay",
6832+
"contributions": [
6833+
"code"
6834+
]
6835+
},
6836+
{
6837+
"login": "yugalkaushik",
6838+
"name": "Yugal Kaushik",
6839+
"avatar_url": "https://avatars.githubusercontent.com/u/138966980?v=4",
6840+
"profile": "https://yugalkaushik.vercel.app",
6841+
"contributions": [
6842+
"code",
6843+
"doc"
6844+
]
6845+
},
6846+
{
6847+
"login": "LalitNarayanYadav",
6848+
"name": "Lalit Narayan Yadav",
6849+
"avatar_url": "https://avatars.githubusercontent.com/u/162928571?v=4",
6850+
"profile": "https://github.com/LalitNarayanYadav",
6851+
"contributions": [
6852+
"doc"
6853+
]
68166854
}
68176855
],
68186856
"repoType": "github",

.github/workflows/release-workflow.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ jobs:
7373
uses: JS-DevTools/npm-publish@v1
7474
with:
7575
token: ${{ secrets.NPM_TOKEN }}
76+
tag: r1
7677

7778
# 4. Update p5.js website
7879
- name: Clone p5.js website

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1135,6 +1135,11 @@ We recognize all types of contributions. This project follows the [all-contribut
11351135
</tr>
11361136
<tr>
11371137
<td align="center" valign="top" width="16.66%"><a href="http://jackeddielove.github.io"><img src="https://avatars.githubusercontent.com/u/130420780?v=4?s=64" width="64px;" alt="Jack L"/><br /><sub><b>Jack L</b></sub></a><br /><a href="https://github.com/processing/p5.js/issues?q=author%3Ajackeddielove" title="Bug reports">🐛</a> <a href="https://github.com/processing/p5.js/commits?author=jackeddielove" title="Documentation">📖</a></td>
1138+
<td align="center" valign="top" width="16.66%"><a href="http://jackeddielove.github.io"><img src="https://avatars.githubusercontent.com/u/130420780?v=4?s=64" width="64px;" alt="Jack L"/><br /><sub><b>Jack L</b></sub></a><br /><a href="https://github.com/processing/p5.js/issues?q=author%3Ajackeddielove" title="Bug reports">🐛</a> <a href="https://github.com/processing/p5.js/commits?author=jackeddielove" title="Documentation">📖</a></td>
1139+
<td align="center" valign="top" width="16.66%"><a href="https://github.com/clairep94"><img src="https://avatars.githubusercontent.com/u/128436909?v=4?s=64" width="64px;" alt="Claire Peng"/><br /><sub><b>Claire Peng</b></sub></a><br /><a href="https://github.com/processing/p5.js/commits?author=clairep94" title="Code">💻</a> <a href="https://github.com/processing/p5.js/issues?q=author%3Aclairep94" title="Bug reports">🐛</a></td>
1140+
<td align="center" valign="top" width="16.66%"><a href="https://github.com/IIITM-Jay"><img src="https://avatars.githubusercontent.com/u/65283880?v=4?s=64" width="64px;" alt="Jay Dev Jha"/><br /><sub><b>Jay Dev Jha</b></sub></a><br /><a href="https://github.com/processing/p5.js/commits?author=IIITM-Jay" title="Code">💻</a></td>
1141+
<td align="center" valign="top" width="16.66%"><a href="https://yugalkaushik.vercel.app"><img src="https://avatars.githubusercontent.com/u/138966980?v=4?s=64" width="64px;" alt="Yugal Kaushik"/><br /><sub><b>Yugal Kaushik</b></sub></a><br /><a href="https://github.com/processing/p5.js/commits?author=yugalkaushik" title="Code">💻</a> <a href="https://github.com/processing/p5.js/commits?author=yugalkaushik" title="Documentation">📖</a></td>
1142+
<td align="center" valign="top" width="16.66%"><a href="https://github.com/LalitNarayanYadav"><img src="https://avatars.githubusercontent.com/u/162928571?v=4?s=64" width="64px;" alt="Lalit Narayan Yadav"/><br /><sub><b>Lalit Narayan Yadav</b></sub></a><br /><a href="https://github.com/processing/p5.js/commits?author=LalitNarayanYadav" title="Documentation">📖</a></td>
11381143
</tr>
11391144
</tbody>
11401145
</table>

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
"node --require @babel/register ./utils/sample-linter.js"
2525
]
2626
},
27-
"version": "1.11.5",
27+
"version": "1.11.7",
2828
"devDependencies": {
2929
"@babel/core": "^7.7.7",
3030
"@babel/preset-env": "^7.10.2",

src/core/main.js

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class p5 {
3737
//////////////////////////////////////////////
3838
// PUBLIC p5 PROPERTIES AND METHODS
3939
//////////////////////////////////////////////
40-
40+
this._isGlobal = !sketch;
4141
/**
4242
* A function that's called once to load assets before the sketch runs.
4343
*
@@ -286,7 +286,6 @@ class p5 {
286286
this._glAttributes = null;
287287
this._requestAnimId = 0;
288288
this._preloadCount = 0;
289-
this._isGlobal = false;
290289
this._loop = true;
291290
this._startListener = null;
292291
this._initializeInstanceVariables();
@@ -661,21 +660,11 @@ class p5 {
661660
// ensure correct reporting of window dimensions
662661
this._updateWindowSize();
663662

664-
// call any registered init functions
665-
this._registeredMethods.init.forEach(function(f) {
666-
if (typeof f !== 'undefined') {
667-
f.call(this);
668-
}
669-
}, this);
670-
// Set up promise preloads
671-
this._setupPromisePreloads();
672-
673663
const friendlyBindGlobal = this._createFriendlyGlobalFunctionBinder();
674664

675665
// If the user has created a global setup or draw function,
676666
// assume "global" mode and make everything global (i.e. on the window)
677-
if (!sketch) {
678-
this._isGlobal = true;
667+
if (this._isGlobal) {
679668
p5.instance = this;
680669
// Loop through methods on the prototype and attach them to the window
681670
for (const p in p5.prototype) {
@@ -710,8 +699,14 @@ class p5 {
710699
p5._checkForUserDefinedFunctions(this);
711700
}
712701

713-
// Bind events to window (not using container div bc key events don't work)
702+
this._updateWindowSize();
703+
704+
// call any registered init functions
705+
this.callRegisteredHooksFor('init');
706+
// Set up promise preloads
707+
this._setupPromisePreloads();
714708

709+
// Bind events to window (not using container div bc key events don't work)
715710
for (const e in this._events) {
716711
const f = this[`_on${e}`];
717712
if (f) {

src/events/keyboard.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -441,11 +441,13 @@ p5.prototype.keyCode = 0;
441441
* </div>
442442
*/
443443
p5.prototype._onkeydown = function(e) {
444+
// Ignore repeated key events when holding down a key
444445
if (e.repeat) {
445-
// Ignore repeated key events when holding down a key
446+
this._setProperty('isKeyRepeated', true);
446447
return;
447448
}
448449

450+
this._setProperty('isKeyRepeated', false);
449451
this._setProperty('isKeyPressed', true);
450452
this._setProperty('keyIsPressed', true);
451453
this._setProperty('keyCode', e.which);
@@ -781,7 +783,7 @@ p5.prototype._onkeyup = function(e) {
781783
* </div>
782784
*/
783785
p5.prototype._onkeypress = function(e) {
784-
if (e.which === this._lastKeyCodeTyped) {
786+
if (e.which === this._lastKeyCodeTyped && this.isKeyRepeated) {
785787
// prevent multiple firings
786788
return;
787789
}

src/events/mouse.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -825,15 +825,19 @@ p5.prototype._updateNextMouseCoords = function(e) {
825825
this.height,
826826
e
827827
);
828-
this._setProperty('movedX', e.movementX);
829-
this._setProperty('movedY', e.movementY);
828+
830829
this._setProperty('mouseX', mousePos.x);
831830
this._setProperty('mouseY', mousePos.y);
832831
this._setProperty('winMouseX', mousePos.winX);
833832
this._setProperty('winMouseY', mousePos.winY);
833+
834+
const deltaX = this.mouseX - this.pmouseX;
835+
const deltaY = this.mouseY - this.pmouseY;
836+
this._setProperty('movedX', deltaX);
837+
this._setProperty('movedY', deltaY);
834838
}
839+
835840
if (!this._hasMouseInteracted) {
836-
// For first draw, make previous and next equal
837841
this._updateMouseCoords();
838842
this._setProperty('_hasMouseInteracted', true);
839843
}

0 commit comments

Comments
 (0)