-
Notifications
You must be signed in to change notification settings - Fork 13.5k
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -61,6 +61,11 @@ function($animate, $timeout, $compile) { | |
'</div>', | ||
controller: ['$scope', '$element', function($scope, $element) { | ||
var _this = this; | ||
var _watchHandler = null; | ||
This comment has been minimized.
Sorry, something went wrong. |
||
var _enterHandler = null; | ||
var _afterLeaveHandler = null; | ||
var _modalRemovedHandler = null; | ||
var _modalPresentedHandler = null; | ||
|
||
this.update = function() { | ||
$timeout(function() { | ||
|
@@ -91,6 +96,52 @@ function($animate, $timeout, $compile) { | |
_this.update(); | ||
}, 50); | ||
|
||
This comment has been minimized.
Sorry, something went wrong.
danbucholtz
Contributor
|
||
this.updateLoop = ionic.debounce(function(){ | ||
if ( _this._options.loop ){ | ||
_this.__slider.updateLoop(); | ||
} | ||
}, 50); | ||
|
||
This comment has been minimized.
Sorry, something went wrong.
danbucholtz
Contributor
|
||
this.watchForChanges = function(){ | ||
if ( ! _watchHandler ){ | ||
// if we're not already watching, start watching | ||
_watchHandler = $scope.$watch(function(){ | ||
console.log("Watch triggered"); | ||
_this.updateLoop(); | ||
}); | ||
} | ||
} | ||
|
||
this.stopWatching = function(){ | ||
This comment has been minimized.
Sorry, something went wrong.
danbucholtz
Contributor
|
||
if ( _watchHandler ){ | ||
console.log("Stopping watching..."); | ||
_watchHandler(); | ||
_watchHandler = null; | ||
} | ||
} | ||
|
||
this.cleanUpEventHandlers = function(){ | ||
This comment has been minimized.
Sorry, something went wrong. |
||
if ( _enterHandler ){ | ||
_enterHandler(); | ||
_enterHandler = null; | ||
} | ||
|
||
if ( _afterLeaveHandler ){ | ||
_afterLeaveHandler(); | ||
_afterLeaveHandler = null; | ||
} | ||
|
||
if ( _modalRemovedHandler ){ | ||
_modalRemovedHandler(); | ||
_modalRemovedHandler = null; | ||
} | ||
|
||
if ( _modalPresentedHandler ){ | ||
_modalPresentedHandler(); | ||
_modalPresentedHandler = null; | ||
} | ||
} | ||
|
||
this.getSlider = function() { | ||
return _this.__slider; | ||
}; | ||
|
@@ -113,15 +164,41 @@ function($animate, $timeout, $compile) { | |
$scope.slider = _this.__slider; | ||
|
||
$scope.$on('$destroy', function() { | ||
alert("scope destroy event"); | ||
slider.destroy(); | ||
_this.__slider = null; | ||
_this.stopWatching(); | ||
_this.cleanUpEventHandlers(); | ||
|
||
}); | ||
|
||
This comment has been minimized.
Sorry, something went wrong.
danbucholtz
Contributor
|
||
_this.watchForChanges(); | ||
|
||
_enterHandler = $scope.$on("$ionicView.enter", function(){ | ||
console.log("enter"); | ||
_this.watchForChanges(); | ||
}); | ||
|
||
_afterLeaveHandler = $scope.$on("$ionicView.afterLeave", function(){ | ||
console.log("after leave"); | ||
_this.stopWatching(); | ||
}); | ||
|
||
_modalRemovedHandler = $scope.$on("$ionic.modalRemoved", function(){ | ||
console.log("Modal removed"); | ||
_this.stopWatching(); | ||
}); | ||
|
||
_modalPresentedHandler = $scope.$on("$ionic.modalPresented", function(){ | ||
console.log("Modal presented"); | ||
_this.watchForChanges(); | ||
}); | ||
|
||
}); | ||
|
||
}], | ||
|
||
|
||
link: function($scope) { | ||
link: function($scope, element, attrs) { | ||
$scope.showPager = true; | ||
// Disable ngAnimate for slidebox and its children | ||
//$animate.enabled(false, $element); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2044,14 +2044,35 @@ | |
} | ||
s.observers = []; | ||
}; | ||
|
||
This comment has been minimized.
Sorry, something went wrong.
danbucholtz
Contributor
|
||
s.updateLoop = function(){ | ||
// this is an Ionic custom function | ||
var duplicates = s.wrapper.children('.' + s.params.slideClass + '.' + s.params.slideDuplicateClass); | ||
var slides = s.wrapper.children('.' + s.params.slideClass); | ||
for ( var i = 0; i < duplicates.length; i++ ){ | ||
var duplicate = duplicates[i]; | ||
var swiperSlideIndex = angular.element(duplicate).attr("data-swiper-slide-index"); | ||
// loop through each slide | ||
for ( var j = 0; i < slides.length; j++ ){ | ||
// if it's not a duplicate, and the data swiper slide index matches the duplicate value | ||
var slide = slides[j] | ||
if ( !angular.element(slide).hasClass(s.params.slideDuplicateClass) && angular.element(slide).attr("data-swiper-slide-index") === swiperSlideIndex ){ | ||
// sweet, it's a match | ||
duplicate.innerHTML = slide.innerHTML; | ||
break; | ||
} | ||
} | ||
} | ||
} | ||
/*========================= | ||
Loop | ||
===========================*/ | ||
// Create looped slides | ||
s.createLoop = function () { | ||
This comment has been minimized.
Sorry, something went wrong.
danbucholtz
Contributor
|
||
|
||
var toRemove = s.wrapper.children('.' + s.params.slideClass + '.' + s.params.slideDuplicateClass); | ||
angular.element(toRemove).remove(); | ||
//console.log("Slider create loop method"); | ||
//var toRemove = s.wrapper.children('.' + s.params.slideClass + '.' + s.params.slideDuplicateClass); | ||
//angular.element(toRemove).remove(); | ||
s.wrapper.children('.' + s.params.slideClass + '.' + s.params.slideDuplicateClass).remove(); | ||
|
||
var slides = s.wrapper.children('.' + s.params.slideClass); | ||
|
||
|
@@ -2071,24 +2092,26 @@ | |
slide.attr('data-swiper-slide-index', index); | ||
}); | ||
for (i = 0; i < appendSlides.length; i++) { | ||
newNode = angular.element(appendSlides[i]).clone().addClass(s.params.slideDuplicateClass); | ||
/*newNode = angular.element(appendSlides[i]).clone().addClass(s.params.slideDuplicateClass); | ||
newNode.removeAttr('ng-transclude'); | ||
newNode.removeAttr('ng-repeat'); | ||
scope = angular.element(appendSlides[i]).scope(); | ||
newNode = $compile(newNode)(scope); | ||
angular.element(s.wrapper).append(newNode); | ||
//s.wrapper.append($(appendSlides[i].cloneNode(true)).addClass(s.params.slideDuplicateClass)); | ||
*/ | ||
s.wrapper.append($(appendSlides[i].cloneNode(true)).addClass(s.params.slideDuplicateClass)); | ||
} | ||
for (i = prependSlides.length - 1; i >= 0; i--) { | ||
//s.wrapper.prepend($(prependSlides[i].cloneNode(true)).addClass(s.params.slideDuplicateClass)); | ||
s.wrapper.prepend($(prependSlides[i].cloneNode(true)).addClass(s.params.slideDuplicateClass)); | ||
|
||
newNode = angular.element(prependSlides[i]).clone().addClass(s.params.slideDuplicateClass); | ||
/*newNode = angular.element(prependSlides[i]).clone().addClass(s.params.slideDuplicateClass); | ||
newNode.removeAttr('ng-transclude'); | ||
newNode.removeAttr('ng-repeat'); | ||
scope = angular.element(prependSlides[i]).scope(); | ||
newNode = $compile(newNode)(scope); | ||
angular.element(s.wrapper).prepend(newNode); | ||
*/ | ||
} | ||
}; | ||
s.destroyLoop = function () { | ||
|
Initialize handlers so we can clean-up when the directive is destroyed