Skip to content

Commit

Permalink
Fix: move previous and next check on Css, Html to JS for further feat…
Browse files Browse the repository at this point in the history
…ures
  • Loading branch information
mihnsen committed Mar 16, 2017
1 parent 8c85e65 commit 100ab0b
Show file tree
Hide file tree
Showing 10 changed files with 34 additions and 18 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "angular-ui-carousel",
"version": "0.1.5",
"version": "0.1.6",
"authors": [
{
"name": "mihnsen",
Expand Down
3 changes: 1 addition & 2 deletions dist/ui-carousel.css
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,7 @@
.ui-carousel .carousel-next .carousel-btn {
right: -25px; }
.ui-carousel .carousel-disable {
opacity: 0.5;
pointer-events: none; }
opacity: 0.5; }
.ui-carousel .carousel-disable .carousel-btn:hover {
opacity: .75; }

Expand Down
8 changes: 8 additions & 0 deletions dist/ui-carousel.js
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,10 @@ angular.module('ui.carousel.controllers').controller('CarouselController', ['$sc
* - 8 total, 4 show, 3 scroll, current 1 => next index = 4
*/
this.next = function () {
if (!_this.isClickableNext) {
return false;
}

var indexOffset = _this.getIndexOffset();
var slideOffset = indexOffset === 0 ? _this.options.slidesToScroll : indexOffset;

Expand All @@ -203,6 +207,10 @@ angular.module('ui.carousel.controllers').controller('CarouselController', ['$sc
* @see next function
*/
this.prev = function () {
if (!_this.isClickablePrev) {
return false;
}

var indexOffset = _this.getIndexOffset();
var slideOffset = indexOffset === 0 ? _this.options.slidesToScroll : _this.options.slidesToShow - indexOffset;

Expand Down
4 changes: 2 additions & 2 deletions dist/ui-carousel.min.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/ui-carousel.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "angular-ui-carousel",
"version": "0.1.5",
"version": "0.1.6",
"author": {
"name": "mihnsen",
"email": "[email protected]"
Expand Down
20 changes: 10 additions & 10 deletions src/demo/index.pug
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ html(ng-app="App")
ga('create', 'UA-85040392-2', 'auto');
ga('send', 'pageview');

body(ng-controller="CarouselDemoCtrl as ctrl")
body(ng-controller="CarouselDemoCtrl as DemoCtrl")
header.header
.container
h1 UI-Carousel
Expand All @@ -53,18 +53,18 @@ html(ng-app="App")
.divider
.content-box
h2.title Single Item
ui-carousel(slides="ctrl.single.slides", dots="true", on-init="ctrl.singleInit()", infinite="false")
ui-carousel(slides="DemoCtrl.single.slides", dots="true", on-init="DemoCtrl.singleInit()", infinite="false")
carousel-item
h3 {{ item + 1 }}
pre
code.language-html(prism="")
| {{ ctrl.single.source }}
| {{ DemoCtrl.single.source }}

.divider
.content-box
h2.title Multiple Item
ui-carousel(
slides="ctrl.multiple.slides",
slides="DemoCtrl.multiple.slides",
slides-to-show="3",
slides-to-scroll="3",
dots="true"
Expand All @@ -73,12 +73,12 @@ html(ng-app="App")
h3 {{ item + 1 }}
pre
code.language-html(prism="")
| {{ ctrl.multiple.source }}
| {{ DemoCtrl.multiple.source }}
.divider
.content-box
h2.title Autoplay
ui-carousel(
slides="ctrl.autoplay.slides",
slides="DemoCtrl.autoplay.slides",
slides-to-show="3",
slides-to-scroll="1",
initial-slide="1",
Expand All @@ -90,12 +90,12 @@ html(ng-app="App")
h3 {{ item + 1 }}
pre
code.language-html(prism="")
| {{ ctrl.autoplay.source }}
| {{ DemoCtrl.autoplay.source }}
.divider
.content-box
h2.title Fade
ui-carousel(
slides="ctrl.fade.slides",
slides="DemoCtrl.fade.slides",
slides-to-show="3",
slides-to-scroll="2",
fade="true",
Expand All @@ -106,13 +106,13 @@ html(ng-app="App")
img(src="{{ item }}")
pre
code.language-html(prism="")
| {{ ctrl.fade.source }}
| {{ DemoCtrl.fade.source }}
.divider
.content-box
h2.title Customzie
pre
code.language-html(prism="")
| {{ ctrl.customize }}
| {{ DemoCtrl.customize }}

section.screen.extra
.divider
Expand Down
8 changes: 8 additions & 0 deletions src/ui-carousel/controllers/carousel.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,10 @@ angular.module('ui.carousel.controllers')
* - 8 total, 4 show, 3 scroll, current 1 => next index = 4
*/
this.next = () => {
if (!this.isClickableNext) {
return false;
}

const indexOffset = this.getIndexOffset();
const slideOffset = indexOffset === 0
? this.options.slidesToScroll
Expand All @@ -192,6 +196,10 @@ angular.module('ui.carousel.controllers')
* @see next function
*/
this.prev = () => {
if (!this.isClickablePrev) {
return false;
}

const indexOffset = this.getIndexOffset();
const slideOffset = indexOffset === 0
? this.options.slidesToScroll
Expand Down
1 change: 0 additions & 1 deletion src/ui-carousel/scss/carousel.scss
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@
}
.carousel-disable {
opacity: 0.5;
pointer-events: none;

.carousel-btn {
&:hover {
Expand Down
2 changes: 2 additions & 0 deletions test/unit/ui-carousel/controllers/carousel.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ describe('ui.carousel.controller.CarouselController', function() {
return $q.resolve(true);
});
CarouselCtrl.$onInit();
CarouselCtrl.isClickableNext = true;
});

it('should works well with normal case', () => {
Expand Down Expand Up @@ -228,6 +229,7 @@ describe('ui.carousel.controller.CarouselController', function() {
return $q.resolve(true);
});
CarouselCtrl.$onInit();
CarouselCtrl.isClickablePrev = true;
});

it('should works well with infinite case and sync to page index first', () => {
Expand Down

0 comments on commit 100ab0b

Please sign in to comment.