Skip to content

Commit

Permalink
version updated to 1.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
dbalaji committed Oct 26, 2017
1 parent 494737c commit 05fd0c0
Show file tree
Hide file tree
Showing 3 changed files with 153 additions and 128 deletions.
277 changes: 151 additions & 126 deletions dist/ui-carousel.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,120 @@
})(angular);
'use strict';

angular.module('ui.carousel.directives').directive('uiCarousel', ['$compile', '$templateCache', '$sce', function ($compile, $templateCache, $sce) {

return { restrict: 'AE',
bindToController: true,
scope: {
name: '=?',
slides: '=',
show: '=?slidesToShow',
scroll: '=?slidesToScroll',
classes: '@',
fade: '=?',
onChange: '=?',
disableArrow: '=?',
autoplay: '=?',
autoplaySpeed: '=?',
cssEase: '=?',
speed: '=?',
infinite: '=?',
arrows: '=?',
dots: '=?',
initialSlide: '=?',
visibleNext: '=?',
visiblePrev: '=?',

// Method
onBeforeChange: '&',
onAfterChange: '&',
onInit: '&',
onItemClick: '&'
},
link: function link($scope, el) {
var template = angular.element($templateCache.get('ui-carousel/carousel.template.html'));

// dynamic injections to override the inner layers' components
var injectComponentMap = {
'carousel-item': '.carousel-item',
'carousel-prev': '.carousel-prev',
'carousel-next': '.carousel-next'
};

var templateInstance = template.clone();
angular.forEach(injectComponentMap, function (innerSelector, outerSelector) {
var outerElement = el[0].querySelector(outerSelector);
if (outerElement) {
angular.element(templateInstance[0].querySelector(innerSelector)).html(outerElement.innerHTML);
}
});

var compiledElement = $compile(templateInstance)($scope);
el.addClass('ui-carousel').html('').append(compiledElement);

$scope.$watch(function () {
return [el[0].offsetWidth, el[0].offsetHeight].join('x');
}, function (value) {
$scope.doRefresh();
});
},


controller: 'CarouselController',
controllerAs: 'ctrl'
};
}]);
'use strict';

angular.module('ui.carousel.providers').provider('Carousel', function () {
var _this = this;

this.options = {
// Init like Slick carousel
// XXX Should be revised
arrows: true,
autoplay: false,
autoplaySpeed: 3000,
cssEase: 'ease',
dots: false,

easing: 'linear',
fade: false,
infinite: true,
initialSlide: 0,

slidesToShow: 1,
slidesToScroll: 1,
speed: 500,

visiblePrev: false,
visibleNext: false,

// Not available right now
draggable: true,

lazyLoad: 'ondemand',

swipe: true,
swipeToSlide: false,
touchMove: true,

vertical: false,
verticalSwiping: false
};
this.$get = [function () {
return {
setOptions: function setOptions(options) {
_this.options = angular.extend(_this.options, options);
},
getOptions: function getOptions() {
return _this.options;
}
};
}];
});
'use strict';

/**
* angular-ui-carousel
* for example:
Expand Down Expand Up @@ -383,33 +497,35 @@ angular.module('ui.carousel.controllers').controller('CarouselController', ['$sc
return deferred.promise;
};

this.handleItemClick = function (item) {
this.onItemClick({ item: item });
};

/**
* correctTrack
* @description correct track after move to animSlide we have to move track
* to exactly its position
*/
this.correctTrack = function () {
if (_this.options.infinite) {
(function () {
var left = 0;
if (_this.slides.length > _this.options.slidesToShow) {
left = -1 * (_this.currentSlide + _this.options.slidesToShow) * _this.itemWidth;
}
var left = 0;
if (_this.slides.length > _this.options.slidesToShow) {
left = -1 * (_this.currentSlide + _this.options.slidesToShow) * _this.itemWidth;
}

// Move without anim
_this.trackStyle[_this.transitionType] = _this.transformType + ' ' + 0 + 'ms ' + _this.options.cssEase;
// Move without anim
_this.trackStyle[_this.transitionType] = _this.transformType + ' ' + 0 + 'ms ' + _this.options.cssEase;

_this.isTrackMoving = true;
$timeout(function () {
_this.trackStyle[_this.animType] = 'translate3d(' + left + 'px, 0, 0px)';
_this.isTrackMoving = true;
$timeout(function () {
_this.trackStyle[_this.animType] = 'translate3d(' + left + 'px, 0, 0px)';

// Revert animation
$timeout(function () {
_this.refreshTrackStyle();
_this.isTrackMoving = false;
}, 200);
});
})();
// Revert animation
$timeout(function () {
_this.refreshTrackStyle();
_this.isTrackMoving = false;
}, 200);
});
}
};

Expand Down Expand Up @@ -508,7 +624,7 @@ angular.module('ui.carousel.controllers').controller('CarouselController', ['$sc
var dots = Math.ceil(_this.slides.length / _this.options.slidesToScroll);

var res = [];
for (var i = 0; i < dots; i++) {
for (var i = 0; i < dots.length; i++) {
res.push(i);
}
return res;
Expand Down Expand Up @@ -589,11 +705,27 @@ angular.module('ui.carousel.controllers').controller('CarouselController', ['$sc
if (_this.currentSlide > slides.length - 1) {
_this.currentSlide = slides.length - 1;
}
//Refer : https://github.com/mihnsen/ui-carousel/issues/10

_this.initOptions();
_this.initRanges();
_this.setProps();
_this.setupInfinite();
_this.refreshCarousel();
});
}, true);

var _self = this;
var _about_to_refresh = false;
$scope.doRefresh = function () {
if (_about_to_refresh) {
return;
}
_about_to_refresh = true;
$timeout(function () {
_self.refreshCarousel();
_about_to_refresh = false;
}, 50);
};
/**
* update when resize
*
Expand All @@ -620,113 +752,6 @@ angular.module('ui.carousel.controllers').controller('CarouselController', ['$sc
}]);
'use strict';

angular.module('ui.carousel.directives').directive('uiCarousel', ['$compile', '$templateCache', '$sce', function ($compile, $templateCache, $sce) {

return { restrict: 'AE',
bindToController: true,
scope: {
name: '=?',
slides: '=',
show: '=?slidesToShow',
scroll: '=?slidesToScroll',
classes: '@',
fade: '=?',
onChange: '=?',
disableArrow: '=?',
autoplay: '=?',
autoplaySpeed: '=?',
cssEase: '=?',
speed: '=?',
infinite: '=?',
arrows: '=?',
dots: '=?',
initialSlide: '=?',
visibleNext: '=?',
visiblePrev: '=?',

// Method
onBeforeChange: '&',
onAfterChange: '&',
onInit: '&'
},
link: function link($scope, el) {
var template = angular.element($templateCache.get('ui-carousel/carousel.template.html'));

// dynamic injections to override the inner layers' components
var injectComponentMap = {
'carousel-item': '.carousel-item',
'carousel-prev': '.carousel-prev',
'carousel-next': '.carousel-next'
};

var templateInstance = template.clone();
angular.forEach(injectComponentMap, function (innerSelector, outerSelector) {
var outerElement = el[0].querySelector(outerSelector);
if (outerElement) {
angular.element(templateInstance[0].querySelector(innerSelector)).html(outerElement.innerHTML);
}
});

var compiledElement = $compile(templateInstance)($scope);
el.addClass('ui-carousel').html('').append(compiledElement);
},


controller: 'CarouselController',
controllerAs: 'ctrl'
};
}]);
'use strict';

angular.module('ui.carousel.providers').provider('Carousel', function () {
var _this = this;

this.options = {
// Init like Slick carousel
// XXX Should be revised
arrows: true,
autoplay: false,
autoplaySpeed: 3000,
cssEase: 'ease',
dots: false,

easing: 'linear',
fade: false,
infinite: true,
initialSlide: 0,

slidesToShow: 1,
slidesToScroll: 1,
speed: 500,

visiblePrev: false,
visibleNext: false,

// Not available right now
draggable: true,

lazyLoad: 'ondemand',

swipe: true,
swipeToSlide: false,
touchMove: true,

vertical: false,
verticalSwiping: false
};
this.$get = [function () {
return {
setOptions: function setOptions(options) {
_this.options = angular.extend(_this.options, options);
},
getOptions: function getOptions() {
return _this.options;
}
};
}];
});
'use strict';

(function (module) {
try {
module = angular.module('ui.carousel');
Expand Down
Loading

0 comments on commit 05fd0c0

Please sign in to comment.