Skip to content
This repository has been archived by the owner on May 10, 2018. It is now read-only.

Commit

Permalink
bump 0.3.6
Browse files Browse the repository at this point in the history
  • Loading branch information
revolunet committed Nov 6, 2014
1 parent 6ff425d commit 6d83767
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 9 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "angular-carousel",
"description": "Angular Carousel - Mobile friendly touch carousel for AngularJS",
"version": "0.3.5",
"version": "0.3.6",
"homepage": "http://revolunet.github.com/angular-carousel",
"author": "Julien Bouquillon <julien@revolunet.com>",
"repository": {
Expand Down
39 changes: 33 additions & 6 deletions dist/angular-carousel.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@ angular.module('angular-carousel').run(['$templateCache', function($templateCach

.service('DeviceCapabilities', function() {

// TODO: merge in a single function

// detect supported CSS property
function detectTransformProperty() {
var transformProperty = 'transform',
Expand Down Expand Up @@ -185,15 +187,15 @@ angular.module('angular-carousel').run(['$templateCache', function($templateCach
transformFrom = offset < (slideIndex * -100) ? 100 : 0;
degrees = offset < (slideIndex * -100) ? maxDegrees : -maxDegrees;
style[DeviceCapabilities.transformProperty] = slideTransformValue + ' ' + 'rotateY(' + degrees + 'deg)';
style['transform-origin'] = transformFrom + '% 50%';
style[DeviceCapabilities.transformProperty + '-origin'] = transformFrom + '% 50%';
} else if (transitionType == 'zoom') {
style[DeviceCapabilities.transformProperty] = slideTransformValue;
var scale = 1;
if (Math.abs(absoluteLeft) < 100) {
scale = 1 + ((1 - distance) * 2);
}
style[DeviceCapabilities.transformProperty] += ' scale(' + scale + ')';
style['transform-origin'] = '50% 50%';
style[DeviceCapabilities.transformProperty + '-origin'] = '50% 50%';
opacity = 0;
if (Math.abs(absoluteLeft) < 100) {
opacity = 0.3 + distance * 0.7;
Expand Down Expand Up @@ -226,6 +228,18 @@ angular.module('angular-carousel').run(['$templateCache', function($templateCach

var requestAnimationFrame = $window.requestAnimationFrame || $window.webkitRequestAnimationFrame || $window.mozRequestAnimationFrame;

function getItemIndex(collection, target, defaultIndex) {
var result = defaultIndex;
collection.every(function(item, index) {
if (angular.equals(item, target)) {
result = index;
return false;
}
return true;
});
return result;
};

return {
restrict: 'A',
scope: true,
Expand Down Expand Up @@ -359,6 +373,7 @@ angular.module('angular-carousel').run(['$templateCache', function($templateCach
};

function goToSlide(index, slideOptions) {
//console.log('goToSlide', arguments);
// move a to the given slide index
if (index === undefined) {
index = scope.carouselIndex;
Expand Down Expand Up @@ -513,11 +528,23 @@ angular.module('angular-carousel').run(['$templateCache', function($templateCach
}

if (isRepeatBased) {
scope.$watchCollection(repeatCollection, function(newValue, oldValue) {
//console.log('repeatCollection', arguments);
// use rn-carousel-deep-watch to fight the Angular $watchCollection weakness : https://github.com/angular/angular.js/issues/2621
// optional because it have some performance impacts (deep watch)
var deepWatch = (iAttributes.rnCarouselDeepWatch!==undefined);

scope[deepWatch?'$watch':'$watchCollection'](repeatCollection, function(newValue, oldValue) {
//console.log('repeatCollection', currentSlides);
var oldSlides = (currentSlides || newValue).slice();
currentSlides = newValue;
goToSlide(scope.carouselIndex);
});
// if deepWatch ON ,manually compare objects to guess the new position
if (deepWatch && angular.isArray(newValue)) {
var activeElement = oldValue[scope.carouselIndex];
var newIndex = getItemIndex(newValue, activeElement, scope.carouselIndex);
goToSlide(newIndex, {animate: false});
} else {
goToSlide(scope.carouselIndex, {animate: false});
}
}, true);
}

function swipeEnd(coords, event, forceAnimation) {
Expand Down
Loading

0 comments on commit 6d83767

Please sign in to comment.