Skip to content

Commit cf40260

Browse files
authored
Adjusted Stage code for when there is no canvas
Added Jeff Peck suggestion from CreateJS Slack to handle Stage when there is no canvas.
1 parent c637dd3 commit cf40260

File tree

1 file changed

+44
-42
lines changed

1 file changed

+44
-42
lines changed

src/easeljs/display/Stage.js

Lines changed: 44 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -786,55 +786,57 @@ this.createjs = this.createjs||{};
786786
nextStage&&nextStage._testMouseOver(clear, owner, eventTarget);
787787
return;
788788
}
789-
var o = this._getPointerData(-1);
790-
// only update if the mouse position has changed. This provides a lot of optimization, but has some trade-offs.
791-
if (!o || (!clear && this.mouseX == this._mouseOverX && this.mouseY == this._mouseOverY && this.mouseInBounds)) { return; }
789+
if (this.canvas) { // Jeff Peck change from CreateJS Slack
790+
var o = this._getPointerData(-1);
791+
// only update if the mouse position has changed. This provides a lot of optimization, but has some trade-offs.
792+
if (!o || (!clear && this.mouseX == this._mouseOverX && this.mouseY == this._mouseOverY && this.mouseInBounds)) { return; }
793+
794+
var e = o.posEvtObj;
795+
var isEventTarget = eventTarget || e&&(e.target == this.canvas);
796+
var target=null, common = -1, cursor="", t, i, l;
792797

793-
var e = o.posEvtObj;
794-
var isEventTarget = eventTarget || e&&(e.target == this.canvas);
795-
var target=null, common = -1, cursor="", t, i, l;
796-
797-
if (!owner && (clear || this.mouseInBounds && isEventTarget)) {
798-
target = this._getObjectsUnderPoint(this.mouseX, this.mouseY, null, true);
799-
this._mouseOverX = this.mouseX;
800-
this._mouseOverY = this.mouseY;
801-
}
798+
if (!owner && (clear || this.mouseInBounds && isEventTarget)) {
799+
target = this._getObjectsUnderPoint(this.mouseX, this.mouseY, null, true);
800+
this._mouseOverX = this.mouseX;
801+
this._mouseOverY = this.mouseY;
802+
}
802803

803-
var oldList = this._mouseOverTarget||[];
804-
var oldTarget = oldList[oldList.length-1];
805-
var list = this._mouseOverTarget = [];
806-
807-
// generate ancestor list and check for cursor:
808-
// Note: Internet Explorer won't update null or undefined cursor properties
809-
t = target;
810-
while (t) {
811-
list.unshift(t);
812-
if (!cursor && t.cursor) { cursor = t.cursor; }
813-
t = t.parent;
814-
}
815-
this.canvas.style.cursor = cursor;
816-
if (!owner && eventTarget) { eventTarget.canvas.style.cursor = cursor; }
804+
var oldList = this._mouseOverTarget||[];
805+
var oldTarget = oldList[oldList.length-1];
806+
var list = this._mouseOverTarget = [];
807+
808+
// generate ancestor list and check for cursor:
809+
// Note: Internet Explorer won't update null or undefined cursor properties
810+
t = target;
811+
while (t) {
812+
list.unshift(t);
813+
if (!cursor && t.cursor) { cursor = t.cursor; }
814+
t = t.parent;
815+
}
816+
this.canvas.style.cursor = cursor;
817+
if (!owner && eventTarget) { eventTarget.canvas.style.cursor = cursor; }
817818

818-
// find common ancestor:
819-
for (i=0,l=list.length; i<l; i++) {
820-
if (list[i] != oldList[i]) { break; }
821-
common = i;
822-
}
819+
// find common ancestor:
820+
for (i=0,l=list.length; i<l; i++) {
821+
if (list[i] != oldList[i]) { break; }
822+
common = i;
823+
}
823824

824-
if (oldTarget != target) {
825-
this._dispatchMouseEvent(oldTarget, "mouseout", true, -1, o, e, target);
826-
}
825+
if (oldTarget != target) {
826+
this._dispatchMouseEvent(oldTarget, "mouseout", true, -1, o, e, target);
827+
}
827828

828-
for (i=oldList.length-1; i>common; i--) {
829-
this._dispatchMouseEvent(oldList[i], "rollout", false, -1, o, e, target);
830-
}
829+
for (i=oldList.length-1; i>common; i--) {
830+
this._dispatchMouseEvent(oldList[i], "rollout", false, -1, o, e, target);
831+
}
831832

832-
for (i=list.length-1; i>common; i--) {
833-
this._dispatchMouseEvent(list[i], "rollover", false, -1, o, e, oldTarget);
834-
}
833+
for (i=list.length-1; i>common; i--) {
834+
this._dispatchMouseEvent(list[i], "rollover", false, -1, o, e, oldTarget);
835+
}
835836

836-
if (oldTarget != target) {
837-
this._dispatchMouseEvent(target, "mouseover", true, -1, o, e, oldTarget);
837+
if (oldTarget != target) {
838+
this._dispatchMouseEvent(target, "mouseover", true, -1, o, e, oldTarget);
839+
}
838840
}
839841

840842
nextStage&&nextStage._testMouseOver(clear, owner || target && this, eventTarget || isEventTarget && this);

0 commit comments

Comments
 (0)