From 8a8d139e1cf86c28338030b5fdf6e5f1bf578b81 Mon Sep 17 00:00:00 2001 From: pandamicro Date: Mon, 11 Jan 2016 10:17:13 +0800 Subject: [PATCH 1/3] Roll back some mistaken changes to Button/ScrollView, my bad --- cocos2d/core/components/CCButton.js | 12 ++++++++++++ cocos2d/core/components/CCScrollView.js | 4 +++- cocos2d/core/event-manager/CCEventManager.js | 6 ------ 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/cocos2d/core/components/CCButton.js b/cocos2d/core/components/CCButton.js index d29b11a6da..3677eb3d9c 100644 --- a/cocos2d/core/components/CCButton.js +++ b/cocos2d/core/components/CCButton.js @@ -333,6 +333,7 @@ var Button = cc.Class({ _registerEvent: function () { this.node.on(cc.Node.EventType.TOUCH_START, this._onTouchBegan, this); + this.node.on(cc.Node.EventType.TOUCH_MOVE, this._onTouchMove, this); this.node.on(cc.Node.EventType.TOUCH_END, this._onTouchEnded, this); this.node.on(cc.Node.EventType.TOUCH_CANCEL, this._onTouchCancel, this); @@ -383,6 +384,17 @@ var Button = cc.Class({ this._applyState(ButtonState.Pressed); }, + _onTouchMove: function (event) { + var touch = event.touch; + var hit = this._hitTest(touch.getLocation()); + if (hit && this._pressed) { + this._applyState(ButtonState.Pressed); + } + else { + this._applyState(ButtonState.Normal); + } + }, + _onTouchEnded: function () { if (this._hovered) { diff --git a/cocos2d/core/components/CCScrollView.js b/cocos2d/core/components/CCScrollView.js index 7ff29bf2aa..49e5d81672 100644 --- a/cocos2d/core/components/CCScrollView.js +++ b/cocos2d/core/components/CCScrollView.js @@ -490,7 +490,9 @@ var ScrollView = cc.Class({ // touch event handler _onTouchBegan: function(event) { var touch = event.touch; - this._handlePressLogic(touch); + if (this.content) { + this._handlePressLogic(touch); + } event.stopPropagation(); }, diff --git a/cocos2d/core/event-manager/CCEventManager.js b/cocos2d/core/event-manager/CCEventManager.js index 4b9b5c5171..5c7d46a448 100644 --- a/cocos2d/core/event-manager/CCEventManager.js +++ b/cocos2d/core/event-manager/CCEventManager.js @@ -284,12 +284,6 @@ cc.eventManager = { var rootEntity = cc.director.getScene(); if(rootEntity) this._sortListenersOfSceneGraphPriority(listenerID, rootEntity); - - // var rootNode = cc.director.getRunningScene(); - // if(rootNode) - // this._sortListenersOfSceneGraphPriority(listenerID, rootNode); - // else - // locFlagMap[listenerID] = this.DIRTY_SCENE_GRAPH_PRIORITY; } } }, From 09fc0d7b0b1e41ce196c5aea87eb5584c43711a6 Mon Sep 17 00:00:00 2001 From: pandamicro Date: Mon, 11 Jan 2016 10:17:32 +0800 Subject: [PATCH 2/3] Fix adaptation issue on Android caused by user-scalable --- cocos2d/core/platform/CCEGLView.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/cocos2d/core/platform/CCEGLView.js b/cocos2d/core/platform/CCEGLView.js index ae1fc7d443..aa7352d783 100644 --- a/cocos2d/core/platform/CCEGLView.js +++ b/cocos2d/core/platform/CCEGLView.js @@ -52,8 +52,7 @@ cc.__BrowserGetter = { return frame.clientHeight; }, meta: { - "width": "device-width", - "user-scalable": "no" + "width": "device-width" }, adaptationType: cc.sys.browserType }; @@ -744,7 +743,7 @@ cc.EGLView = cc._Class.extend(/** @lends cc.view# */{ */ setRealPixelResolution: function (width, height, resolutionPolicy) { // Set viewport's width - this._setViewportMeta({"width": width, "user-scalable": "no"}, true); + this._setViewportMeta({"width": width}, true); // Set body width to the exact pixel resolution document.body.style.width = width + "px"; From 93fc5681e9bb8d1c53aec9fc6815ee77faaf04da Mon Sep 17 00:00:00 2001 From: pandamicro Date: Mon, 11 Jan 2016 10:40:29 +0800 Subject: [PATCH 3/3] Fix CCButton _hitTest usage --- cocos2d/core/components/CCButton.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos2d/core/components/CCButton.js b/cocos2d/core/components/CCButton.js index 3677eb3d9c..e29339ab07 100644 --- a/cocos2d/core/components/CCButton.js +++ b/cocos2d/core/components/CCButton.js @@ -386,7 +386,7 @@ var Button = cc.Class({ _onTouchMove: function (event) { var touch = event.touch; - var hit = this._hitTest(touch.getLocation()); + var hit = this.node._hitTest(touch.getLocation()); if (hit && this._pressed) { this._applyState(ButtonState.Pressed); }