Skip to content

Commit 7e29681

Browse files
author
Lauren McCarthy
committed
changing event handler functions to use _on so they dont clash when bound to window
1 parent 15fb26d commit 7e29681

File tree

8 files changed

+36
-36
lines changed

8 files changed

+36
-36
lines changed

lib/p5.js

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ amdclean['core'] = function (require, shim, constants) {
309309
sketch(this);
310310
}
311311
for (var e in this._events) {
312-
var f = this['on' + e];
312+
var f = this['_on' + e];
313313
if (f) {
314314
var m = f.bind(this);
315315
window.addEventListener(e, m);
@@ -2223,7 +2223,7 @@ amdclean['environment'] = function (require, core, constants) {
22232223
p5.prototype.displayHeight = screen.height;
22242224
p5.prototype.windowWidth = window.innerWidth;
22252225
p5.prototype.windowHeight = window.innerHeight;
2226-
p5.prototype.onresize = function (e) {
2226+
p5.prototype._onresize = function (e) {
22272227
this._setProperty('windowWidth', window.innerWidth);
22282228
this._setProperty('windowHeight', window.innerHeight);
22292229
var context = this._isGlobal ? window : this;
@@ -3360,7 +3360,7 @@ amdclean['inputkeyboard'] = function (require, core) {
33603360
p5.prototype.keyIsPressed = false;
33613361
p5.prototype.key = '';
33623362
p5.prototype.keyCode = 0;
3363-
p5.prototype.onkeydown = function (e) {
3363+
p5.prototype._onkeydown = function (e) {
33643364
this._setProperty('isKeyPressed', true);
33653365
this._setProperty('keyIsPressed', true);
33663366
this._setProperty('keyCode', e.which);
@@ -3378,7 +3378,7 @@ amdclean['inputkeyboard'] = function (require, core) {
33783378
}
33793379
}
33803380
};
3381-
p5.prototype.onkeyup = function (e) {
3381+
p5.prototype._onkeyup = function (e) {
33823382
var keyReleased = this.keyReleased || window.keyReleased;
33833383
this._setProperty('isKeyPressed', false);
33843384
this._setProperty('keyIsPressed', false);
@@ -3396,7 +3396,7 @@ amdclean['inputkeyboard'] = function (require, core) {
33963396
}
33973397
}
33983398
};
3399-
p5.prototype.onkeypress = function (e) {
3399+
p5.prototype._onkeypress = function (e) {
34003400
this._setProperty('keyCode', e.which);
34013401
this._setProperty('key', String.fromCharCode(e.which));
34023402
var keyTyped = this.keyTyped || window.keyTyped;
@@ -3407,7 +3407,7 @@ amdclean['inputkeyboard'] = function (require, core) {
34073407
}
34083408
}
34093409
};
3410-
p5.prototype.onblur = function (e) {
3410+
p5.prototype._onblur = function (e) {
34113411
downKeys = {};
34123412
};
34133413
p5.prototype.keyIsDown = function (code) {
@@ -3438,19 +3438,19 @@ amdclean['inputacceleration'] = function (require, core) {
34383438
};
34393439
var old_max_axis = '';
34403440
var new_max_axis = '';
3441-
p5.prototype.ondeviceorientation = function (e) {
3441+
p5.prototype._ondeviceorientation = function (e) {
34423442
this._setProperty('accelerationX', e.beta);
34433443
this._setProperty('accelerationY', e.gamma);
34443444
this._setProperty('accelerationZ', e.alpha);
34453445
this._handleMotion();
34463446
};
3447-
p5.prototype.ondevicemotion = function (e) {
3447+
p5.prototype._ondevicemotion = function (e) {
34483448
this._setProperty('accelerationX', e.acceleration.x * 2);
34493449
this._setProperty('accelerationY', e.acceleration.y * 2);
34503450
this._setProperty('accelerationZ', e.acceleration.z * 2);
34513451
this._handleMotion();
34523452
};
3453-
p5.prototype.onMozOrientation = function (e) {
3453+
p5.prototype._onMozOrientation = function (e) {
34543454
this._setProperty('accelerationX', e.x);
34553455
this._setProperty('accelerationY', e.y);
34563456
this._setProperty('accelerationZ', e.z);
@@ -3547,7 +3547,7 @@ amdclean['inputmouse'] = function (require, core, constants) {
35473547
}
35483548
}
35493549
};
3550-
p5.prototype.onmousemove = function (e) {
3550+
p5.prototype._onmousemove = function (e) {
35513551
var context = this._isGlobal ? window : this;
35523552
var executeDefault;
35533553
this._updateMouseCoords(e);
@@ -3573,7 +3573,7 @@ amdclean['inputmouse'] = function (require, core, constants) {
35733573
}
35743574
}
35753575
};
3576-
p5.prototype.onmousedown = function (e) {
3576+
p5.prototype._onmousedown = function (e) {
35773577
var context = this._isGlobal ? window : this;
35783578
var executeDefault;
35793579
this._setProperty('isMousePressed', true);
@@ -3593,7 +3593,7 @@ amdclean['inputmouse'] = function (require, core, constants) {
35933593
this._updateTouchCoords(e);
35943594
}
35953595
};
3596-
p5.prototype.onmouseup = function (e) {
3596+
p5.prototype._onmouseup = function (e) {
35973597
var context = this._isGlobal ? window : this;
35983598
var executeDefault;
35993599
this._setProperty('isMousePressed', false);
@@ -3611,7 +3611,7 @@ amdclean['inputmouse'] = function (require, core, constants) {
36113611
this._updateTouchCoords(e);
36123612
}
36133613
};
3614-
p5.prototype.onclick = function (e) {
3614+
p5.prototype._onclick = function (e) {
36153615
var context = this._isGlobal ? window : this;
36163616
if (typeof context.mouseClicked === 'function') {
36173617
var executeDefault = context.mouseClicked(e);
@@ -3620,7 +3620,7 @@ amdclean['inputmouse'] = function (require, core, constants) {
36203620
}
36213621
}
36223622
};
3623-
p5.prototype.onmousewheel = function (e) {
3623+
p5.prototype._onmousewheel = function (e) {
36243624
var context = this._isGlobal ? window : this;
36253625
if (typeof context.mouseWheel === 'function') {
36263626
var executeDefault = context.mouseWheel(e);
@@ -3697,7 +3697,7 @@ amdclean['inputtouch'] = function (require, core) {
36973697
y: e.changedTouches[i].pageY - rect.top
36983698
};
36993699
}
3700-
p5.prototype.ontouchstart = function (e) {
3700+
p5.prototype._ontouchstart = function (e) {
37013701
var context = this._isGlobal ? window : this;
37023702
var executeDefault;
37033703
this._updateTouchCoords(e);
@@ -3714,7 +3714,7 @@ amdclean['inputtouch'] = function (require, core) {
37143714
}
37153715
}
37163716
};
3717-
p5.prototype.ontouchmove = function (e) {
3717+
p5.prototype._ontouchmove = function (e) {
37183718
var context = this._isGlobal ? window : this;
37193719
var executeDefault;
37203720
this._updateTouchCoords(e);
@@ -3731,7 +3731,7 @@ amdclean['inputtouch'] = function (require, core) {
37313731
this._updateMouseCoords(e);
37323732
}
37333733
};
3734-
p5.prototype.ontouchend = function (e) {
3734+
p5.prototype._ontouchend = function (e) {
37353735
this._updateTouchCoords(e);
37363736
if (this.touches.length === 0) {
37373737
this._setProperty('touchIsDown', false);

lib/p5.min.js

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

src/core/core.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,7 @@ define(function (require) {
429429

430430
// Bind events to window (not using container div bc key events don't work)
431431
for (var e in this._events) {
432-
var f = this['on'+e];
432+
var f = this['_on'+e];
433433
if (f) {
434434
var m = f.bind(this);
435435
window.addEventListener(e, m);

src/environment/environment.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ define(function(require) {
247247
* }
248248
* </code></div>
249249
*/
250-
p5.prototype.onresize = function(e){
250+
p5.prototype._onresize = function(e){
251251
this._setProperty('windowWidth', window.innerWidth);
252252
this._setProperty('windowHeight', window.innerHeight);
253253
var context = this._isGlobal ? window : this;

src/input/acceleration.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -150,19 +150,19 @@ define(function (require){
150150
* </code>
151151
* </div>
152152
*/
153-
p5.prototype.ondeviceorientation = function (e) {
153+
p5.prototype._ondeviceorientation = function (e) {
154154
this._setProperty('accelerationX', e.beta);
155155
this._setProperty('accelerationY', e.gamma);
156156
this._setProperty('accelerationZ', e.alpha);
157157
this._handleMotion();
158158
};
159-
p5.prototype.ondevicemotion = function (e) {
159+
p5.prototype._ondevicemotion = function (e) {
160160
this._setProperty('accelerationX', e.acceleration.x * 2);
161161
this._setProperty('accelerationY', e.acceleration.y * 2);
162162
this._setProperty('accelerationZ', e.acceleration.z * 2);
163163
this._handleMotion();
164164
};
165-
p5.prototype.onMozOrientation = function (e) {
165+
p5.prototype._onMozOrientation = function (e) {
166166
this._setProperty('accelerationX', e.x);
167167
this._setProperty('accelerationY', e.y);
168168
this._setProperty('accelerationZ', e.z);

src/input/keyboard.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ define(function (require) {
132132
* </code>
133133
* </div>
134134
*/
135-
p5.prototype.onkeydown = function (e) {
135+
p5.prototype._onkeydown = function (e) {
136136
this._setProperty('isKeyPressed', true);
137137
this._setProperty('keyIsPressed', true);
138138
this._setProperty('keyCode', e.which);
@@ -177,7 +177,7 @@ define(function (require) {
177177
* </code>
178178
* </div>
179179
*/
180-
p5.prototype.onkeyup = function (e) {
180+
p5.prototype._onkeyup = function (e) {
181181
var keyReleased = this.keyReleased || window.keyReleased;
182182
this._setProperty('isKeyPressed', false);
183183
this._setProperty('keyIsPressed', false);
@@ -229,7 +229,7 @@ define(function (require) {
229229
* </code>
230230
* </div>
231231
*/
232-
p5.prototype.onkeypress = function (e) {
232+
p5.prototype._onkeypress = function (e) {
233233
this._setProperty('keyCode', e.which);
234234
this._setProperty('key', String.fromCharCode(e.which));
235235
var keyTyped = this.keyTyped || window.keyTyped;
@@ -246,7 +246,7 @@ define(function (require) {
246246
* not focused on the element we must assume all keys currently down have
247247
* been released.
248248
*/
249-
p5.prototype.onblur = function (e) {
249+
p5.prototype._onblur = function (e) {
250250
downKeys = {};
251251
};
252252

src/input/mouse.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ define(function (require) {
224224
* </code>
225225
* </div>
226226
*/
227-
p5.prototype.onmousemove = function(e){
227+
p5.prototype._onmousemove = function(e){
228228
var context = this._isGlobal ? window : this;
229229
var executeDefault;
230230
this._updateMouseCoords(e);
@@ -294,7 +294,7 @@ define(function (require) {
294294
* </code>
295295
* </div>
296296
*/
297-
p5.prototype.onmousedown = function(e) {
297+
p5.prototype._onmousedown = function(e) {
298298
var context = this._isGlobal ? window : this;
299299
var executeDefault;
300300
this._setProperty('isMousePressed', true);
@@ -357,7 +357,7 @@ define(function (require) {
357357
* </code>
358358
* </div>
359359
*/
360-
p5.prototype.onmouseup = function(e) {
360+
p5.prototype._onmouseup = function(e) {
361361
var context = this._isGlobal ? window : this;
362362
var executeDefault;
363363
this._setProperty('isMousePressed', false);
@@ -416,7 +416,7 @@ define(function (require) {
416416
* </code>
417417
* </div>
418418
*/
419-
p5.prototype.onclick = function(e) {
419+
p5.prototype._onclick = function(e) {
420420
var context = this._isGlobal ? window : this;
421421
if (typeof context.mouseClicked === 'function') {
422422
var executeDefault = context.mouseClicked(e);
@@ -440,7 +440,7 @@ define(function (require) {
440440
*
441441
* @method mouseWheel
442442
*/
443-
p5.prototype.onmousewheel = function(e) {
443+
p5.prototype._onmousewheel = function(e) {
444444
var context = this._isGlobal ? window : this;
445445
if (typeof context.mouseWheel === 'function') {
446446
var executeDefault = context.mouseWheel(e);

src/input/touch.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ define(function (require) {
142142
* </code>
143143
* </div>
144144
*/
145-
p5.prototype.ontouchstart = function(e) {
145+
p5.prototype._ontouchstart = function(e) {
146146
var context = this._isGlobal ? window : this;
147147
var executeDefault;
148148
this._updateTouchCoords(e);
@@ -199,7 +199,7 @@ define(function (require) {
199199
* </code>
200200
* </div>
201201
*/
202-
p5.prototype.ontouchmove = function(e) {
202+
p5.prototype._ontouchmove = function(e) {
203203
var context = this._isGlobal ? window : this;
204204
var executeDefault;
205205
this._updateTouchCoords(e);
@@ -256,7 +256,7 @@ define(function (require) {
256256
* </code>
257257
* </div>
258258
*/
259-
p5.prototype.ontouchend = function(e) {
259+
p5.prototype._ontouchend = function(e) {
260260
this._updateTouchCoords(e);
261261
if (this.touches.length === 0) {
262262
this._setProperty('touchIsDown', false);

0 commit comments

Comments
 (0)