Skip to content

Commit

Permalink
pausing here, not making any progress
Browse files Browse the repository at this point in the history
  • Loading branch information
Dan Bucholtz authored and Dan Bucholtz committed Mar 31, 2016
1 parent bdb47b9 commit ca178c6
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 9 deletions.
49 changes: 43 additions & 6 deletions js/views/slidesView.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@

if (!(this instanceof Swiper)) return new Swiper(container, params);

var watchesCreated = true;

var defaults = {
direction: 'horizontal',
touchEventsTarget: 'container',
Expand Down Expand Up @@ -2071,26 +2073,55 @@
slide.attr('data-swiper-slide-index', index);
});
for (i = 0; i < appendSlides.length; i++) {


scope = angular.element(appendSlides[i]).scope();

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);
scope.$apply(function(){
newNode = $compile(newNode)(scope);
angular.element(s.wrapper).append(newNode);
});
//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));

scope = angular.element(prependSlides[i]).scope();

newNode = angular.element(prependSlides[i]).clone().addClass(s.params.slideDuplicateClass);
newNode.removeAttr('ng-transclude');
newNode.removeAttr('ng-repeat');
scope.$apply(function(){
newNode = $compile(newNode)(scope);
angular.element(s.wrapper).prepend(newNode);
});
//console.log("Scope: ", scope);
}

if ( ! watchesCreated ){
watchesCreated = true;
var elements = document.getElementsByClassName(s.params.slideDuplicateClass);
console.log("Elements that are duplicates: ", elements);
for ( var i = 0; i < elements.length; i++ ){
var element = elements[i];
var angularElement = angular.element(element);
var myScope = angularElement.scope();
myScope.$watch("someProperty", function(){
console.log("someProperty changed: ", myScope.someProperty);
});
}

scope = angular.element(prependSlides[i]).scope();
newNode = $compile(newNode)(scope);
angular.element(s.wrapper).prepend(newNode);
}
else{
watchesCreated = false;
console.log("watches are already created");
}

};

s.destroyLoop = function () {
s.wrapper.children('.' + s.params.slideClass + '.' + s.params.slideDuplicateClass).remove();
s.slides.removeAttr('data-swiper-slide-index');
Expand Down Expand Up @@ -2119,10 +2150,12 @@
}
if (typeof slides === 'object' && slides.length) {
for (var i = 0; i < slides.length; i++) {
console.log("appendSlide: Directly Appending");
if (slides[i]) s.wrapper.append(slides[i]);
}
}
else {
console.log("appendSlide: Directly Appending");
s.wrapper.append(slides);
}
if (s.params.loop) {
Expand All @@ -2139,11 +2172,13 @@
var newActiveIndex = s.activeIndex + 1;
if (typeof slides === 'object' && slides.length) {
for (var i = 0; i < slides.length; i++) {
console.log("prependSlide: directly preprending");
if (slides[i]) s.wrapper.prepend(slides[i]);
}
newActiveIndex = s.activeIndex + slides.length;
}
else {
console.log("prependSlide: directly preprending");
s.wrapper.prepend(slides);
}
if (s.params.loop) {
Expand All @@ -2155,6 +2190,7 @@
s.slideTo(newActiveIndex, 0, false);
};
s.removeSlide = function (slidesIndexes) {
console.log("removeSlide");
if (s.params.loop) {
s.destroyLoop();
s.slides = s.wrapper.children('.' + s.params.slideClass);
Expand Down Expand Up @@ -2253,6 +2289,7 @@
cubeShadow = s.wrapper.find('.swiper-cube-shadow');
if (cubeShadow.length === 0) {
cubeShadow = $('<div class="swiper-cube-shadow"></div>');
console.log("appendSlide: Directly Appending");
s.wrapper.append(cubeShadow);
}
cubeShadow.css({height: s.width + 'px'});
Expand Down
9 changes: 6 additions & 3 deletions test/html/slides.html
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ <h2>Life on HD 219134 b</h2>
we regret to inform you that the experiment is ended and we hope to one day retrieve your valuable data. From all of us
at Ion Space Pursuits, we thank you for your participation in this important research study.
</p>
<div>some property: {{someProperty}}</div>
</ion-slide-page>
</ion-slides>
</ion-content>
Expand All @@ -109,15 +110,17 @@ <h2>Life on HD 219134 b</h2>
loop: true
}

$scope.someProperty = "Waiting...";

$scope.data = {};

$scope.$watch('data.slider', function(nv, ov) {
$scope.slider = $scope.data.slider;
})

$timeout(function() {
//$scope.slider.slideNext();
}, 1000)
$interval(function() {
$scope.someProperty = Math.random();
}, 500)

$scope.doClick = function() {
console.log('CLICK');
Expand Down

0 comments on commit ca178c6

Please sign in to comment.