From 3ca164fe1914c845dc43bf161f5ef01346458e98 Mon Sep 17 00:00:00 2001 From: zilongshanren Date: Wed, 17 Feb 2016 11:33:15 +0800 Subject: [PATCH] fix reset scrollbar null exception --- cocos2d/core/components/CCScrollView.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/cocos2d/core/components/CCScrollView.js b/cocos2d/core/components/CCScrollView.js index 1b515e9755..6f79d8b812 100644 --- a/cocos2d/core/components/CCScrollView.js +++ b/cocos2d/core/components/CCScrollView.js @@ -159,8 +159,10 @@ var ScrollView = cc.Class({ type: cc.Scrollbar, tooltip: 'i18n:COMPONENT.scrollview.horizontal_bar', notify: function() { - this.horizontalScrollBar.setTargetScrollView(this); - this._updateScrollBar(0); + if (this.horizontalScrollBar) { + this.horizontalScrollBar.setTargetScrollView(this); + this._updateScrollBar(0); + } }, animatable: false }, @@ -174,8 +176,10 @@ var ScrollView = cc.Class({ type: cc.Scrollbar, tooltip: 'i18n:COMPONENT.scrollview.vertical_bar', notify: function() { - this.verticalScrollBar.setTargetScrollView(this); - this._updateScrollBar(0); + if (this.verticalScrollBar) { + this.verticalScrollBar.setTargetScrollView(this); + this._updateScrollBar(0); + } }, animatable: false }