Skip to content

Commit

Permalink
Fix hit-area bug
Browse files Browse the repository at this point in the history
  • Loading branch information
rexrainbow committed Dec 11, 2024
1 parent dbbd392 commit 06cc318
Show file tree
Hide file tree
Showing 35 changed files with 761 additions and 241 deletions.
56 changes: 43 additions & 13 deletions dist/rexbbcodetext.js
Original file line number Diff line number Diff line change
Expand Up @@ -2284,13 +2284,17 @@
clear() {
// Reuse hitArea(rectangle) later
for (var i = 0, cnt = this.hitAreas.length; i < cnt; i++) {
Clear(this.hitAreas[i].data);
this.hitAreas[i].data = null;
}
RectanglePool.pushMultiple(this.hitAreas);
return this;
}

add(x, y, width, height, data) {
if (data === undefined) {
data = {};
}

var rectangle = RectanglePool.pop();
if (rectangle === null) {
rectangle = new Rectangle(x, y, width, height);
Expand Down Expand Up @@ -2375,6 +2379,11 @@
var key = area.data.key;
FireEvent.call(this, 'areadown', key, pointer, localX, localY, event);

// Removed by callback of previous event
if (!area.data) {
return;
}

area.data.isDown = true;
};

Expand All @@ -2384,21 +2393,29 @@
return;
}

var areaData = area.data;

var key = areaData.key;
var key = area.data.key;
FireEvent.call(this, 'areaup', key, pointer, localX, localY, event);

if (areaData.isDown) {
// Removed by callback of previous event
if (!area.data) {
return;
}

if (area.data.isDown) {
FireEvent.call(this, 'areaclick', key, pointer, localX, localY, event);

var url = areaData.url;
// Removed by callback of previous event
if (!area.data) {
return;
}

var url = area.data.url;
if (url) {
window.open(url, '_blank');
}
}

areaData.isDown = false;
area.data.isDown = false;
};

var OnAreaOverOut = function (pointer, localX, localY, event) {
Expand All @@ -2421,17 +2438,22 @@
FireEvent.call(this, 'areaout', this.lastHitAreaKey, pointer, localX, localY, event);

var prevHitArea = this.hitAreaManager.getByKey(this.lastHitAreaKey);
if (this.urlTagCursorStyle && !!prevHitArea.data.url) {
this.scene.input.manager.canvas.style.cursor = '';
}

prevHitArea.isDown = false;
if (prevHitArea) {
if (this.urlTagCursorStyle) {
SetCursorStyle(this.scene, prevHitArea, '');
}

prevHitArea.isDown = false;
}
}
if (key !== null) {
FireEvent.call(this, 'areaover', key, pointer, localX, localY, event);

if (this.urlTagCursorStyle && !!area.data.url) {
this.scene.input.manager.canvas.style.cursor = this.urlTagCursorStyle;
if (area.data) {
if (this.urlTagCursorStyle) {
SetCursorStyle(this.scene, area, this.urlTagCursorStyle);
}
}
}

Expand All @@ -2443,6 +2465,14 @@
this.parent.emit(eventName, key, pointer, localX, localY, event);
};

var SetCursorStyle = function (scene, area, cursorStyle) {
if (!area || !area.data || !area.data.url) {
return;
}

scene.input.manager.canvas.style.cursor = cursorStyle;
};

var RE_ASCII = /^[\x00-\x7F]+$/;
var IsASCIIString = function (s) {
return RE_ASCII.test(s);
Expand Down
2 changes: 1 addition & 1 deletion dist/rexbbcodetext.min.js

Large diffs are not rendered by default.

56 changes: 43 additions & 13 deletions dist/rexbbcodetextplugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -2284,13 +2284,17 @@
clear() {
// Reuse hitArea(rectangle) later
for (var i = 0, cnt = this.hitAreas.length; i < cnt; i++) {
Clear(this.hitAreas[i].data);
this.hitAreas[i].data = null;
}
RectanglePool.pushMultiple(this.hitAreas);
return this;
}

add(x, y, width, height, data) {
if (data === undefined) {
data = {};
}

var rectangle = RectanglePool.pop();
if (rectangle === null) {
rectangle = new Rectangle(x, y, width, height);
Expand Down Expand Up @@ -2375,6 +2379,11 @@
var key = area.data.key;
FireEvent.call(this, 'areadown', key, pointer, localX, localY, event);

// Removed by callback of previous event
if (!area.data) {
return;
}

area.data.isDown = true;
};

Expand All @@ -2384,21 +2393,29 @@
return;
}

var areaData = area.data;

var key = areaData.key;
var key = area.data.key;
FireEvent.call(this, 'areaup', key, pointer, localX, localY, event);

if (areaData.isDown) {
// Removed by callback of previous event
if (!area.data) {
return;
}

if (area.data.isDown) {
FireEvent.call(this, 'areaclick', key, pointer, localX, localY, event);

var url = areaData.url;
// Removed by callback of previous event
if (!area.data) {
return;
}

var url = area.data.url;
if (url) {
window.open(url, '_blank');
}
}

areaData.isDown = false;
area.data.isDown = false;
};

var OnAreaOverOut = function (pointer, localX, localY, event) {
Expand All @@ -2421,17 +2438,22 @@
FireEvent.call(this, 'areaout', this.lastHitAreaKey, pointer, localX, localY, event);

var prevHitArea = this.hitAreaManager.getByKey(this.lastHitAreaKey);
if (this.urlTagCursorStyle && !!prevHitArea.data.url) {
this.scene.input.manager.canvas.style.cursor = '';
}

prevHitArea.isDown = false;
if (prevHitArea) {
if (this.urlTagCursorStyle) {
SetCursorStyle(this.scene, prevHitArea, '');
}

prevHitArea.isDown = false;
}
}
if (key !== null) {
FireEvent.call(this, 'areaover', key, pointer, localX, localY, event);

if (this.urlTagCursorStyle && !!area.data.url) {
this.scene.input.manager.canvas.style.cursor = this.urlTagCursorStyle;
if (area.data) {
if (this.urlTagCursorStyle) {
SetCursorStyle(this.scene, area, this.urlTagCursorStyle);
}
}
}

Expand All @@ -2443,6 +2465,14 @@
this.parent.emit(eventName, key, pointer, localX, localY, event);
};

var SetCursorStyle = function (scene, area, cursorStyle) {
if (!area || !area.data || !area.data.url) {
return;
}

scene.input.manager.canvas.style.cursor = cursorStyle;
};

var RE_ASCII = /^[\x00-\x7F]+$/;
var IsASCIIString = function (s) {
return RE_ASCII.test(s);
Expand Down
2 changes: 1 addition & 1 deletion dist/rexbbcodetextplugin.min.js

Large diffs are not rendered by default.

56 changes: 43 additions & 13 deletions dist/rexcolorcomponents.js
Original file line number Diff line number Diff line change
Expand Up @@ -26086,13 +26086,17 @@
clear() {
// Reuse hitArea(rectangle) later
for (var i = 0, cnt = this.hitAreas.length; i < cnt; i++) {
Clear(this.hitAreas[i].data);
this.hitAreas[i].data = null;
}
RectanglePool.pushMultiple(this.hitAreas);
return this;
}

add(x, y, width, height, data) {
if (data === undefined) {
data = {};
}

var rectangle = RectanglePool.pop();
if (rectangle === null) {
rectangle = new Rectangle(x, y, width, height);
Expand Down Expand Up @@ -26177,6 +26181,11 @@
var key = area.data.key;
FireEvent.call(this, 'areadown', key, pointer, localX, localY, event);

// Removed by callback of previous event
if (!area.data) {
return;
}

area.data.isDown = true;
};

Expand All @@ -26186,21 +26195,29 @@
return;
}

var areaData = area.data;

var key = areaData.key;
var key = area.data.key;
FireEvent.call(this, 'areaup', key, pointer, localX, localY, event);

if (areaData.isDown) {
// Removed by callback of previous event
if (!area.data) {
return;
}

if (area.data.isDown) {
FireEvent.call(this, 'areaclick', key, pointer, localX, localY, event);

var url = areaData.url;
// Removed by callback of previous event
if (!area.data) {
return;
}

var url = area.data.url;
if (url) {
window.open(url, '_blank');
}
}

areaData.isDown = false;
area.data.isDown = false;
};

var OnAreaOverOut = function (pointer, localX, localY, event) {
Expand All @@ -26223,17 +26240,22 @@
FireEvent.call(this, 'areaout', this.lastHitAreaKey, pointer, localX, localY, event);

var prevHitArea = this.hitAreaManager.getByKey(this.lastHitAreaKey);
if (this.urlTagCursorStyle && !!prevHitArea.data.url) {
this.scene.input.manager.canvas.style.cursor = '';
}

prevHitArea.isDown = false;
if (prevHitArea) {
if (this.urlTagCursorStyle) {
SetCursorStyle(this.scene, prevHitArea, '');
}

prevHitArea.isDown = false;
}
}
if (key !== null) {
FireEvent.call(this, 'areaover', key, pointer, localX, localY, event);

if (this.urlTagCursorStyle && !!area.data.url) {
this.scene.input.manager.canvas.style.cursor = this.urlTagCursorStyle;
if (area.data) {
if (this.urlTagCursorStyle) {
SetCursorStyle(this.scene, area, this.urlTagCursorStyle);
}
}
}

Expand All @@ -26245,6 +26267,14 @@
this.parent.emit(eventName, key, pointer, localX, localY, event);
};

var SetCursorStyle = function (scene, area, cursorStyle) {
if (!area || !area.data || !area.data.url) {
return;
}

scene.input.manager.canvas.style.cursor = cursorStyle;
};

const NO_NEWLINE$1 = CONST.NO_NEWLINE;
const RAW_NEWLINE = CONST.RAW_NEWLINE;
const WRAPPED_NEWLINE$1 = CONST.WRAPPED_NEWLINE;
Expand Down
2 changes: 1 addition & 1 deletion dist/rexcolorcomponents.min.js

Large diffs are not rendered by default.

Loading

0 comments on commit 06cc318

Please sign in to comment.