Skip to content

Commit db8304d

Browse files
author
Dan Bucholtz
committed
fix(slides): resolves data-update issue on duplicate slides #5739
1 parent 639d6df commit db8304d

File tree

1 file changed

+20
-25
lines changed

1 file changed

+20
-25
lines changed

Diff for: js/angular/directive/slides.js

+20-25
Original file line numberDiff line numberDiff line change
@@ -96,51 +96,51 @@ function($animate, $timeout, $compile) {
9696
_this.update();
9797
}, 50);
9898

99-
this.updateLoop = ionic.debounce(function(){
100-
if ( _this._options.loop ){
99+
this.updateLoop = ionic.debounce(function() {
100+
if ( _this._options.loop ) {
101101
_this.__slider.updateLoop();
102102
}
103103
}, 50);
104104

105-
this.watchForChanges = function(){
106-
if ( ! _watchHandler ){
105+
this.watchForChanges = function() {
106+
if ( !_watchHandler ) {
107107
// if we're not already watching, start watching
108-
_watchHandler = $scope.$watch(function(){
108+
_watchHandler = $scope.$watch(function() {
109109
console.log("Watch triggered");
110110
_this.updateLoop();
111111
});
112112
}
113-
}
113+
};
114114

115-
this.stopWatching = function(){
116-
if ( _watchHandler ){
115+
this.stopWatching = function() {
116+
if ( _watchHandler ) {
117117
console.log("Stopping watching...");
118118
_watchHandler();
119119
_watchHandler = null;
120120
}
121-
}
121+
};
122122

123-
this.cleanUpEventHandlers = function(){
124-
if ( _enterHandler ){
123+
this.cleanUpEventHandlers = function() {
124+
if ( _enterHandler ) {
125125
_enterHandler();
126126
_enterHandler = null;
127127
}
128128

129-
if ( _afterLeaveHandler ){
129+
if ( _afterLeaveHandler ) {
130130
_afterLeaveHandler();
131131
_afterLeaveHandler = null;
132132
}
133133

134-
if ( _modalRemovedHandler ){
134+
if ( _modalRemovedHandler ) {
135135
_modalRemovedHandler();
136136
_modalRemovedHandler = null;
137137
}
138138

139-
if ( _modalPresentedHandler ){
139+
if ( _modalPresentedHandler ) {
140140
_modalPresentedHandler();
141141
_modalPresentedHandler = null;
142142
}
143-
}
143+
};
144144

145145
this.getSlider = function() {
146146
return _this.__slider;
@@ -164,7 +164,6 @@ function($animate, $timeout, $compile) {
164164
$scope.slider = _this.__slider;
165165

166166
$scope.$on('$destroy', function() {
167-
alert("scope destroy event");
168167
slider.destroy();
169168
_this.__slider = null;
170169
_this.stopWatching();
@@ -174,31 +173,27 @@ function($animate, $timeout, $compile) {
174173

175174
_this.watchForChanges();
176175

177-
_enterHandler = $scope.$on("$ionicView.enter", function(){
178-
console.log("enter");
176+
_enterHandler = $scope.$on("$ionicView.enter", function() {
179177
_this.watchForChanges();
180178
});
181179

182-
_afterLeaveHandler = $scope.$on("$ionicView.afterLeave", function(){
183-
console.log("after leave");
180+
_afterLeaveHandler = $scope.$on("$ionicView.afterLeave", function() {
184181
_this.stopWatching();
185182
});
186183

187-
_modalRemovedHandler = $scope.$on("$ionic.modalRemoved", function(){
188-
console.log("Modal removed");
184+
_modalRemovedHandler = $scope.$on("$ionic.modalRemoved", function() {
189185
_this.stopWatching();
190186
});
191187

192-
_modalPresentedHandler = $scope.$on("$ionic.modalPresented", function(){
193-
console.log("Modal presented");
188+
_modalPresentedHandler = $scope.$on("$ionic.modalPresented", function() {
194189
_this.watchForChanges();
195190
});
196191

197192
});
198193

199194
}],
200195

201-
link: function($scope, element, attrs) {
196+
link: function($scope) {
202197
$scope.showPager = true;
203198
// Disable ngAnimate for slidebox and its children
204199
//$animate.enabled(false, $element);

0 commit comments

Comments
 (0)