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

Commit

Permalink
chore: update build
Browse files Browse the repository at this point in the history
  • Loading branch information
revolunet committed Jan 26, 2015
1 parent 1d08d7d commit ecbbb78
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 70 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.7",
"version": "0.3.8",
"homepage": "http://revolunet.github.com/angular-carousel",
"author": "Julien Bouquillon <[email protected]>",
"repository": {
Expand Down
130 changes: 64 additions & 66 deletions dist/angular-carousel.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* Angular Carousel - Mobile friendly touch carousel for AngularJS
* @version v0.3.7 - 2014-11-11
* @version v0.3.8 - 2015-01-26
* @link http://revolunet.github.com/angular-carousel
* @author Julien Bouquillon <[email protected]>
* @license MIT License, http://www.opensource.org/licenses/MIT
Expand All @@ -20,57 +20,36 @@ angular.module('angular-carousel', [

angular.module('angular-carousel')

.directive('rnCarouselAutoSlide', ['$timeout', function($timeout) {
.directive('rnCarouselAutoSlide', ['$interval', function($interval) {
return {
restrict: 'A',
link: function (scope, element, attrs) {
var delay = Math.round(parseFloat(attrs.rnCarouselAutoSlide) * 1000),
timer = increment = false, slidesCount = element.children().length;

if(!scope.carouselExposedIndex){
scope.carouselExposedIndex = 0;
}
stopAutoplay = function () {
if (angular.isDefined(timer)) {
$timeout.cancel(timer);
var stopAutoPlay = function() {
if (scope.autoSlider) {
$interval.cancel(scope.autoSlider);
scope.autoSlider = null;
}
timer = undefined;
};

increment = function () {
if (scope.carouselExposedIndex < slidesCount - 1) {
scope.carouselExposedIndex = scope.carouselExposedIndex + 1;
} else {
scope.carouselExposedIndex = 0;
}
var restartTimer = function() {
scope.autoSlide();
};

restartTimer = function (){
stopAutoplay();
timer = $timeout(increment, delay);
};

scope.$watch('carouselIndex', function(){
restartTimer();
});

restartTimer();
if (attrs.rnCarouselPauseOnHover && attrs.rnCarouselPauseOnHover != 'false'){
element.on('mouseenter', stopAutoplay);
scope.$watch('carouselIndex', restartTimer);

if (attrs.hasOwnProperty('rnCarouselPauseOnHover') && attrs.rnCarouselPauseOnHover !== 'false'){
element.on('mouseenter', stopAutoPlay);
element.on('mouseleave', restartTimer);
}

scope.$on('$destroy', function(){
stopAutoplay();
element.off('mouseenter', stopAutoplay);
stopAutoPlay();
element.off('mouseenter', stopAutoPlay);
element.off('mouseleave', restartTimer);
});


}
};
}]);

angular.module('angular-carousel')

.directive('rnCarouselIndicators', ['$parse', function($parse) {
Expand Down Expand Up @@ -306,23 +285,15 @@ angular.module('angular-carousel').run(['$templateCache', function($templateCach
destination,
swipeMoved = false,
//animOnIndexChange = true,
currentSlides,
currentSlides = [],
elWidth = null,
elX = null,
animateTransitions = true,
intialState = true,
animating = false,
mouseUpBound = false,
locked = false;

if(iAttributes.rnCarouselControls!==undefined) {
// dont use a directive for this
var tpl = '<div class="rn-carousel-controls">\n' +
' <span class="rn-carousel-control rn-carousel-control-prev" ng-click="prevSlide()" ng-if="carouselIndex > 0"></span>\n' +
' <span class="rn-carousel-control rn-carousel-control-next" ng-click="nextSlide()" ng-if="carouselIndex < ' + repeatCollection + '.length - 1"></span>\n' +
'</div>';
iElement.append($compile(angular.element(tpl))(scope));
}

$swipe.bind(iElement, {
start: swipeStart,
move: swipeMove,
Expand Down Expand Up @@ -403,11 +374,13 @@ angular.module('angular-carousel').run(['$templateCache', function($templateCach
updateSlidesPosition(state.x);
},
finish: function() {
locked = false;
scope.$apply(function() {
scope.carouselIndex = index;
offset = index * -100;
updateBufferIndex();
$timeout(function () {
locked = false;
}, 0, false);
});
}
});
Expand All @@ -422,9 +395,25 @@ angular.module('angular-carousel').run(['$templateCache', function($templateCach
elWidth = getContainerWidth();
}

function bindMouseUpEvent() {
if (!mouseUpBound) {
mouseUpBound = true;
$document.bind('mouseup', documentMouseUpEvent);
}
}

function unbindMouseUpEvent() {
if (mouseUpBound) {
mouseUpBound = false;
$document.unbind('mouseup', documentMouseUpEvent);
}
}

function swipeStart(coords, event) {
// console.log('swipeStart', coords, event);
$document.bind('mouseup', documentMouseUpEvent);
if (locked || currentSlides.length <= 1) {
return;
}
updateContainerWidth();
elX = iElement[0].querySelector('li').getBoundingClientRect().left;
pressed = true;
Expand All @@ -434,10 +423,8 @@ angular.module('angular-carousel').run(['$templateCache', function($templateCach

function swipeMove(coords, event) {
//console.log('swipeMove', coords, event);
if (locked) {
return;
}
var x, delta;
bindMouseUpEvent();
if (pressed) {
x = coords.x;
delta = startX - x;
Expand All @@ -461,14 +448,29 @@ angular.module('angular-carousel').run(['$templateCache', function($templateCach
});
}

var autoSlider;
if (iAttributes.rnCarouselControls!==undefined) {
// dont use a directive for this
var nextSlideIndexCompareValue = isRepeatBased ? repeatCollection.replace('::', '') + '.length - 1' : currentSlides.length - 1;
var tpl = '<div class="rn-carousel-controls">\n' +
' <span class="rn-carousel-control rn-carousel-control-prev" ng-click="prevSlide()" ng-if="carouselIndex > 0"></span>\n' +
' <span class="rn-carousel-control rn-carousel-control-next" ng-click="nextSlide()" ng-if="carouselIndex < ' + nextSlideIndexCompareValue + '"></span>\n' +
'</div>';
iElement.append($compile(angular.element(tpl))(scope));
}

if (iAttributes.rnCarouselAutoSlide!==undefined) {
var duration = parseInt(iAttributes.rnCarouselAutoSlide, 10) || options.autoSlideDuration;
autoSlider = $interval(function() {
if (!locked && !pressed) {
scope.nextSlide();
scope.autoSlide = function() {
if (scope.autoSlider) {
$interval.cancel(scope.autoSlider);
scope.autoSlider = null;
}
}, duration * 1000);
scope.autoSlider = $interval(function() {
if (!locked && !pressed) {
scope.nextSlide();
}
}, duration * 1000);
};
}

if (iAttributes.rnCarouselIndex) {
Expand All @@ -479,10 +481,7 @@ angular.module('angular-carousel').run(['$templateCache', function($templateCach
if (angular.isFunction(indexModel.assign)) {
/* check if this property is assignable then watch it */
scope.$watch('carouselIndex', function(newValue) {
if (!locked) {
updateParentIndex(newValue);
}

updateParentIndex(newValue);
});
scope.$parent.$watch(indexModel, function(newValue, oldValue) {

Expand Down Expand Up @@ -534,7 +533,6 @@ angular.module('angular-carousel').run(['$templateCache', function($templateCach

scope[deepWatch?'$watch':'$watchCollection'](repeatCollection, function(newValue, oldValue) {
//console.log('repeatCollection', currentSlides);
var oldSlides = (currentSlides || newValue).slice();
currentSlides = newValue;
// if deepWatch ON ,manually compare objects to guess the new position
if (deepWatch && angular.isArray(newValue)) {
Expand All @@ -553,8 +551,7 @@ angular.module('angular-carousel').run(['$templateCache', function($templateCach
if (event && !swipeMoved) {
return;
}

$document.unbind('mouseup', documentMouseUpEvent);
unbindMouseUpEvent();
pressed = false;
swipeMoved = false;
destination = startX - coords.x;
Expand Down Expand Up @@ -593,7 +590,7 @@ angular.module('angular-carousel').run(['$templateCache', function($templateCach
}

scope.$on('$destroy', function() {
$document.unbind('mouseup', documentMouseUpEvent);
unbindMouseUpEvent();
});

scope.carouselBufferIndex = 0;
Expand Down Expand Up @@ -640,7 +637,7 @@ angular.module('angular-carousel').run(['$templateCache', function($templateCach
winEl.bind('resize', onOrientationChange);

scope.$on('$destroy', function() {
$document.unbind('mouseup', documentMouseUpEvent);
unbindMouseUpEvent();
winEl.unbind('orientationchange', onOrientationChange);
winEl.unbind('resize', onOrientationChange);
});
Expand Down Expand Up @@ -1135,8 +1132,9 @@ angular.module('angular-carousel.shifty', [])
// CommonJS
module.exports = Tweenable;
} else if (typeof define === 'function' && define.amd) {
// AMD
define(function () {return Tweenable;});
// AMD: define it as a named module to avoid the mismatched error(http://requirejs.org/docs/errors.html#mismatch)
define('shifty', [], function () {return Tweenable;});
root.Tweenable = Tweenable;
} else if (typeof root.Tweenable === 'undefined') {
// Browser: Make `Tweenable` globally accessible.
root.Tweenable = Tweenable;
Expand Down
Loading

0 comments on commit ecbbb78

Please sign in to comment.