Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
bower_components
node_modules
15 changes: 15 additions & 0 deletions dist/js/multi-carousel.directive.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
var moving = false;
var inner = angular.element(element[0].querySelector('inner'));
var interval;
var initialized = false;

// API
scope.prev = prev;
Expand All @@ -34,6 +35,20 @@
scope.$watch('items', start);

function start() {
// avoid infinite loop when modifying items
if (initialized) {
return;
}
initialized = true;

// DOM wrapper being shifted to the left requires
// that the last item is moved to the begining.
scope.items.unshift(scope.items.pop());

// Ensures continuity during navigation
// when there's only one invisible item
scope.items = scope.items.concat(angular.copy(scope.items));

$interval.cancel(interval);
interval = $interval(function() {
if (enabled && scope.items.length && scope.$eval(attrs.interval)) {
Expand Down
15 changes: 15 additions & 0 deletions src/js/multi-carousel.directive.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
var moving = false;
var inner = angular.element(element[0].querySelector('inner'));
var interval;
var initialized = false;

// API
scope.prev = prev;
Expand All @@ -34,6 +35,20 @@
scope.$watch('items', start);

function start() {
// avoid infinite loop when modifying items
if (initialized) {
return;
}
initialized = true;

// DOM wrapper being shifted to the left requires
// that the last item is moved to the begining.
scope.items.unshift(scope.items.pop());

// Ensures continuity during navigation
// when there's only one invisible item
scope.items = scope.items.concat(angular.copy(scope.items));

$interval.cancel(interval);
interval = $interval(function() {
if (enabled && scope.items.length && scope.$eval(attrs.interval)) {
Expand Down