Skip to content

Commit

Permalink
Fix version.
Browse files Browse the repository at this point in the history
  • Loading branch information
cnjsstong committed Mar 18, 2014
1 parent 755d6cc commit 6955e75
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 51 deletions.
39 changes: 15 additions & 24 deletions angular-panorama.js
Original file line number Diff line number Diff line change
@@ -1,38 +1,30 @@
/**
* Angular Panorama - Mimic Windows Phone's Panorama UI control.
* @version v0.1.5 - 2014-03-18
* @version v0.2.0 - 2014-03-18
* @link http://cnjsstong2.github.com/angular-panorama
* @author Tong Shen <[email protected]>
* @license MIT License, http://www.opensource.org/licenses/MIT
*/
/*global angular */

/*
Angular touch panorama with CSS GPU accel and slide buffering/cycling
http://github.com/cnjsstong2/angular-panorama
*/

angular.module('angular-panorama', ['ngTouch']);

angular.module('angular-panorama')

.directive('ngPanorama', ['$swipe', '$document', '$window', function ($swipe, $document, $window) {
.directive('ngPanorama', ['$swipe', function ($swipe) {
return {
restrict: 'A',
scope: {
pages: "=ngPanorama",
curIndex: "=ngPanoramaIndex",
backgroundImage: "=ngPanoramaBackgroundImage",
i: "=ngPanoramaIndex",
bg: "=ngPanoramaBackgroundImage",
reset: "=ngPanoramaReset"
},
link: function (scope, el, attr) {
scope.$watch('backgroundImage', function (newValue) {
scope.$watch('bg', function (newValue) {
if (newValue) {
el.css('background-image', 'url(' + newValue + ')');
}
});
scope.$watch('curIndex', function (newValue) {
scope.$watch('i', function (newValue) {
setOffset(getOffsetByIndex(newValue));
});
scope.$watch('reset', function (newValue) {
Expand All @@ -44,8 +36,8 @@ angular.module('angular-panorama')
el.addClass('ng-panorama-container');
var ul = el.find('ul');
ul.addClass('ng-panorama-slides');
if (!scope.curIndex) {
scope.curIndex = 0;
if (!scope.i) {
scope.i = 0;
}
function getOffsetByIndex(index) {
var offset = 0;
Expand Down Expand Up @@ -84,15 +76,14 @@ angular.module('angular-panorama')
$swipe.bind(el, {
start: function (coords) {
startCoords = coords;
startOffset = getOffsetByIndex(scope.curIndex);
startOffset = getOffsetByIndex(scope.i);
ul.css(cruiseOff);
// ul.css('transition','none');
},
move: function (coords) {
setOffset(startOffset + coords.x - startCoords.x);
},
end: function (coords) {
var targetIndex = scope.curIndex;
var targetIndex = scope.i;
var threshold = el.prop('offsetWidth') * 0.1;
var delta = coords.x - startCoords.x;
if (delta > threshold && targetIndex > 0) {
Expand All @@ -101,16 +92,16 @@ angular.module('angular-panorama')
targetIndex++;
}
scope.$apply(function () {
scope.curIndex = targetIndex;
scope.i = targetIndex;
});
ul.css(cruiseOn);
setOffset(getOffsetByIndex(scope.curIndex));
setOffset(getOffsetByIndex(scope.i));
},
cancel: function (coords) {
ul.css(cruiseOn);
setOffset(getOffsetByIndex(scope.curIndex));
setOffset(getOffsetByIndex(scope.i));
}
})
});
}
}
};
}]);
4 changes: 2 additions & 2 deletions angular-panorama.min.js

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

2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"author": "cnjsstong",
"name": "angular-panorama",
"description": "Mimic Windows Phone's panorama UI control.",
"version": "0.2.1",
"version": "0.2.0",
"homepage": "https://github.com/cnjsstong2/angular-panorama",
"ignore": [
"src",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "angular-panorama",
"description": "Angular Panorama - Mimic Windows Phone's Panorama UI control.",
"version": "0.1.5",
"version": "0.2.0",
"homepage": "http://cnjsstong2.github.com/angular-panorama",
"author": "Tong Shen <[email protected]>",
"repository": {
Expand Down
8 changes: 0 additions & 8 deletions src/angular-panorama.js
Original file line number Diff line number Diff line change
@@ -1,9 +1 @@
/*global angular */

/*
Angular touch panorama with CSS GPU accel and slide buffering/cycling
http://github.com/cnjsstong2/angular-panorama
*/

angular.module('angular-panorama', ['ngTouch']);
29 changes: 14 additions & 15 deletions src/directives/ng-panorama.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
angular.module('angular-panorama')

.directive('ngPanorama', ['$swipe', '$document', '$window', function ($swipe, $document, $window) {
.directive('ngPanorama', ['$swipe', function ($swipe) {
return {
restrict: 'A',
scope: {
pages: "=ngPanorama",
curIndex: "=ngPanoramaIndex",
backgroundImage: "=ngPanoramaBackgroundImage",
i: "=ngPanoramaIndex",
bg: "=ngPanoramaBackgroundImage",
reset: "=ngPanoramaReset"
},
link: function (scope, el, attr) {
scope.$watch('backgroundImage', function (newValue) {
scope.$watch('bg', function (newValue) {
if (newValue) {
el.css('background-image', 'url(' + newValue + ')');
}
});
scope.$watch('curIndex', function (newValue) {
scope.$watch('i', function (newValue) {
setOffset(getOffsetByIndex(newValue));
});
scope.$watch('reset', function (newValue) {
Expand All @@ -27,8 +27,8 @@ angular.module('angular-panorama')
el.addClass('ng-panorama-container');
var ul = el.find('ul');
ul.addClass('ng-panorama-slides');
if (!scope.curIndex) {
scope.curIndex = 0;
if (!scope.i) {
scope.i = 0;
}
function getOffsetByIndex(index) {
var offset = 0;
Expand Down Expand Up @@ -67,15 +67,14 @@ angular.module('angular-panorama')
$swipe.bind(el, {
start: function (coords) {
startCoords = coords;
startOffset = getOffsetByIndex(scope.curIndex);
startOffset = getOffsetByIndex(scope.i);
ul.css(cruiseOff);
// ul.css('transition','none');
},
move: function (coords) {
setOffset(startOffset + coords.x - startCoords.x);
},
end: function (coords) {
var targetIndex = scope.curIndex;
var targetIndex = scope.i;
var threshold = el.prop('offsetWidth') * 0.1;
var delta = coords.x - startCoords.x;
if (delta > threshold && targetIndex > 0) {
Expand All @@ -84,16 +83,16 @@ angular.module('angular-panorama')
targetIndex++;
}
scope.$apply(function () {
scope.curIndex = targetIndex;
scope.i = targetIndex;
});
ul.css(cruiseOn);
setOffset(getOffsetByIndex(scope.curIndex));
setOffset(getOffsetByIndex(scope.i));
},
cancel: function (coords) {
ul.css(cruiseOn);
setOffset(getOffsetByIndex(scope.curIndex));
setOffset(getOffsetByIndex(scope.i));
}
})
});
}
}
};
}]);

0 comments on commit 6955e75

Please sign in to comment.