Skip to content

Commit

Permalink
Fix bug in slide collection removal (thanks @jmallison)
Browse files Browse the repository at this point in the history
  • Loading branch information
thenikso committed May 4, 2014
1 parent d2d2d38 commit b81380f
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 27 deletions.
4 changes: 2 additions & 2 deletions angular-flexslider.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,9 @@ angular.module('angular-flexslider', [])
collection ?= []
trackCollection = {}
for c in collection
trackCollection[c] = getTrackFromItem c
trackCollection[getTrackFromItem(c)] = c
# Generates arrays of collection items to add and remvoe
toAdd = (c for c in collection when not slidesItems[trackCollection[c]]?)
toAdd = (c for c in collection when not slidesItems[getTrackFromItem(c)]?)
toRemove = (i.collectionItem for t, i of slidesItems when not trackCollection[t]?)
# Workaround to a still unresolved problem in using flexslider.addSlide
if (toAdd.length == 1 and toRemove.length == 0) or toAdd.length == 0
Expand Down
4 changes: 2 additions & 2 deletions angular-flexslider.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 14 additions & 16 deletions bower.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
{
"name": "angular-flexslider",
"version": "1.2.4",
"main": "./angular-flexslider.js",
"dependencies": {
"angular": "~1.2.4",
"jquery": "2.0.2",
"flexslider": "latest"
},
"readme": "angular-flexslider\n======================\n\nbower repo for angular-flexslider.js",
"readmeFilename": "README.md",
"_id": "[email protected]",
"description": "bower-angular-flexslider ======================",
"repository": {
"type": "git",
"url": "git://github.com/EnthusiasticCode/angular-flexslider.git"
}
"name": "angular-flexslider",
"version": "1.2.6",
"main": "./angular-flexslider.js",
"dependencies": {
"angular": "~1.2.16",
"jquery": "2.0.2",
"flexslider": "latest"
},
"readmeFilename": "README.md",
"description": "AngularJS wrapper for Flexslider",
"repository": {
"type": "git",
"url": "git://github.com/EnthusiasticCode/angular-flexslider.git"
}
}
15 changes: 8 additions & 7 deletions examples/add-remove-slides.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
<body ng-controller="BasicSliderCtrl">

<flex-slider
slide="s in slideshow.slides"
slide="s in slideshow.slides track by s.id"
animation="slide">
<li>
<img ng-src="{{s}}">
<img ng-src="{{s.url}}">
</li>
</flex-slider>

Expand All @@ -31,13 +31,14 @@
.controller('BasicSliderCtrl', function($scope) {
$scope.slideshow = {};
$scope.slideshow.slides = [
'http://flexslider.woothemes.com/images/kitchen_adventurer_cheesecake_brownie.jpg',
'http://flexslider.woothemes.com/images/kitchen_adventurer_lemon.jpg',
'http://flexslider.woothemes.com/images/kitchen_adventurer_donut.jpg',
'http://flexslider.woothemes.com/images/kitchen_adventurer_caramel.jpg'
{ id: 1, url: 'http://flexslider.woothemes.com/images/kitchen_adventurer_cheesecake_brownie.jpg' },
{ id: 2, url: 'http://flexslider.woothemes.com/images/kitchen_adventurer_lemon.jpg' },
{ id: 3, url: 'http://flexslider.woothemes.com/images/kitchen_adventurer_donut.jpg' },
{ id: 4, url: 'http://flexslider.woothemes.com/images/kitchen_adventurer_caramel.jpg' }
];
var nextId = 5;
$scope.addRandomSlide = function () {
$scope.slideshow.slides.push('http://lorempixel.com/704/444/cats');
$scope.slideshow.slides.push({ id: nextId++, url: 'http://lorempixel.com/704/444/cats' });
};
$scope.removeRandomSlide = function () {
$scope.slideshow.slides.shift();
Expand Down

0 comments on commit b81380f

Please sign in to comment.