From 1abfe0c006ad6b562ec4d25eab1dd40b27c73079 Mon Sep 17 00:00:00 2001 From: Jare Guo Date: Tue, 31 Jul 2018 10:37:45 +0800 Subject: [PATCH] Button allow enableAutoGrayEffect when COLOR transition being choosed (#3026) --- cocos2d/core/CCNode.js | 2 +- cocos2d/core/components/CCButton.js | 13 +++++++------ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/cocos2d/core/CCNode.js b/cocos2d/core/CCNode.js index fee8abf7e0..c9e249779d 100644 --- a/cocos2d/core/CCNode.js +++ b/cocos2d/core/CCNode.js @@ -502,7 +502,7 @@ function _doDispatchEvent (owner, event) { } } _cachedArray.length = 0; -}; +} /** * !#en diff --git a/cocos2d/core/components/CCButton.js b/cocos2d/core/components/CCButton.js index 4071a015fe..060e248283 100644 --- a/cocos2d/core/components/CCButton.js +++ b/cocos2d/core/components/CCButton.js @@ -661,14 +661,15 @@ let Button = cc.Class({ _updateDisabledState () { if (this._sprite) { - this._sprite.setState(cc.Sprite.State.NORMAL); - } - if (this.enableAutoGrayEffect && this.transition !== Transition.COLOR) { - if (!(this.transition === Transition.SPRITE && this.disabledSprite)) { - if (this._sprite && !this.interactable) { - this._sprite.setState(cc.Sprite.State.GRAY); + if (this.enableAutoGrayEffect) { + if (!(this.transition === Transition.SPRITE && this.disabledSprite)) { + if (!this.interactable) { + this._sprite.setState(cc.Sprite.State.GRAY); + return; + } } } + this._sprite.setState(cc.Sprite.State.NORMAL); } } });