mirror of
https://github.com/cocos/cocos4.git
synced 2026-12-06 11:31:59 +08:00
Merge pull request #1055 from pandamicro/v1.2
Fix currentHovered state and orientation changing during resize
This commit is contained in:
@@ -705,8 +705,8 @@ cc.RepeatForever = cc.ActionInterval.extend({
|
||||
});
|
||||
|
||||
/**
|
||||
* !#en Create a acton which repeat forever
|
||||
* !#zh 永远地重复一个动作,有限次数内重复一个动作请使用 repeat 动作。
|
||||
* !#en Create a acton which repeat forever, as it runs forever, it can't be added into cc.sequence and cc.spawn.
|
||||
* !#zh 永远地重复一个动作,有限次数内重复一个动作请使用 repeat 动作,由于这个动作不会停止,所以不能被添加到 cc.sequence 或 cc.spawn 中。
|
||||
* @method repeatForever
|
||||
* @param {FiniteTimeAction} action
|
||||
* @return {ActionInterval}
|
||||
|
||||
@@ -140,7 +140,7 @@ var _mouseEvents = [
|
||||
EventType.MOUSE_WHEEL,
|
||||
];
|
||||
|
||||
var currentHovered = null;
|
||||
var _currentHovered = null;
|
||||
|
||||
var _touchStartHandler = function (touch, event) {
|
||||
var pos = touch.getLocation();
|
||||
@@ -194,12 +194,12 @@ var _mouseMoveHandler = function (event) {
|
||||
event.stopPropagation();
|
||||
if (!this._previousIn) {
|
||||
// Fix issue when hover node switched, previous hovered node won't get MOUSE_LEAVE notification
|
||||
if (currentHovered) {
|
||||
if (_currentHovered) {
|
||||
event.type = EventType.MOUSE_LEAVE;
|
||||
currentHovered.owner.dispatchEvent(event);
|
||||
currentHovered._previousIn = false;
|
||||
_currentHovered.dispatchEvent(event);
|
||||
_currentHovered._mouseListener._previousIn = false;
|
||||
}
|
||||
currentHovered = this;
|
||||
_currentHovered = this.owner;
|
||||
event.type = EventType.MOUSE_ENTER;
|
||||
node.dispatchEvent(event);
|
||||
this._previousIn = true;
|
||||
@@ -211,7 +211,7 @@ var _mouseMoveHandler = function (event) {
|
||||
event.type = EventType.MOUSE_LEAVE;
|
||||
node.dispatchEvent(event);
|
||||
this._previousIn = false;
|
||||
currentHovered = null;
|
||||
_currentHovered = null;
|
||||
}
|
||||
};
|
||||
var _mouseUpHandler = function (event) {
|
||||
@@ -528,8 +528,8 @@ var Node = cc.Class({
|
||||
this._releaseAllActions();
|
||||
|
||||
// Remove Node.currentHovered
|
||||
if (currentHovered === this) {
|
||||
currentHovered = null;
|
||||
if (_currentHovered === this) {
|
||||
_currentHovered = null;
|
||||
}
|
||||
|
||||
// Remove all listeners
|
||||
|
||||
@@ -127,6 +127,8 @@ var View = cc._Class.extend({
|
||||
// Custom callback for resize event
|
||||
_resizeCallback: null,
|
||||
|
||||
_orientationChanging: false,
|
||||
|
||||
_scaleX: 1,
|
||||
_originalScaleX: 1,
|
||||
_scaleY: 1,
|
||||
@@ -210,6 +212,12 @@ var View = cc._Class.extend({
|
||||
}
|
||||
},
|
||||
|
||||
_orientationChange: function () {
|
||||
this._orientationChanging = true;
|
||||
this._resizeEvent();
|
||||
this._orientationChanging = false;
|
||||
},
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Sets view's target-densitydpi for android mobile browser. it can be set to: <br/>
|
||||
@@ -249,14 +257,14 @@ var View = cc._Class.extend({
|
||||
if (!this.__resizeWithBrowserSize) {
|
||||
this.__resizeWithBrowserSize = true;
|
||||
window.addEventListener('resize', this._resizeEvent);
|
||||
window.addEventListener('orientationchange', this._resizeEvent);
|
||||
window.addEventListener('orientationchange', this._orientationChange);
|
||||
}
|
||||
} else {
|
||||
//disable
|
||||
if (this.__resizeWithBrowserSize) {
|
||||
this.__resizeWithBrowserSize = false;
|
||||
window.removeEventListener('resize', this._resizeEvent);
|
||||
window.removeEventListener('orientationchange', this._resizeEvent);
|
||||
window.removeEventListener('orientationchange', this._orientationChange);
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -297,7 +305,7 @@ var View = cc._Class.extend({
|
||||
var h = __BrowserGetter.availHeight(cc.game.frame);
|
||||
var isLandscape = w >= h;
|
||||
|
||||
if (CC_EDITOR || !cc.sys.isMobile ||
|
||||
if (CC_EDITOR || !this._orientationChanging || !cc.sys.isMobile ||
|
||||
(isLandscape && this._orientation & cc.macro.ORIENTATION_LANDSCAPE) ||
|
||||
(!isLandscape && this._orientation & cc.macro.ORIENTATION_PORTRAIT)) {
|
||||
locFrameSize.width = w;
|
||||
|
||||
Reference in New Issue
Block a user