From 415aa0959b865b0ff2cc5c0151182f90f43308ea Mon Sep 17 00:00:00 2001 From: mountainmoon Date: Mon, 29 Dec 2014 00:30:13 +0800 Subject: [PATCH 1/3] fix errors(#254, #270) with require.js in shifty.js --- bower.json | 3 ++- src/directives/shifty.js | 5 +++-- test/karma.conf.js | 1 + test/unit/angular-carousel.shifty.js | 20 ++++++++++++++++++++ 4 files changed, 26 insertions(+), 3 deletions(-) create mode 100644 test/unit/angular-carousel.shifty.js diff --git a/bower.json b/bower.json index 3cd6d32..57b62fe 100644 --- a/bower.json +++ b/bower.json @@ -20,6 +20,7 @@ "angular-touch": ">=1.2.10" }, "devDependencies": { - "angular-mocks": ">=1.2.10" + "angular-mocks": ">=1.2.10", + "requirejs": ">=2.1.0" } } diff --git a/src/directives/shifty.js b/src/directives/shifty.js index ccb73ac..80b34ab 100644 --- a/src/directives/shifty.js +++ b/src/directives/shifty.js @@ -482,8 +482,9 @@ angular.module('angular-carousel.shifty', []) // CommonJS module.exports = Tweenable; } else if (typeof define === 'function' && define.amd) { - // AMD - define(function () {return Tweenable;}); + // AMD: define it as a named module to avoid the mismatched error(http://requirejs.org/docs/errors.html#mismatch) + define('shifty', [], function () {return Tweenable;}); + root.Tweenable = Tweenable; } else if (typeof root.Tweenable === 'undefined') { // Browser: Make `Tweenable` globally accessible. root.Tweenable = Tweenable; diff --git a/test/karma.conf.js b/test/karma.conf.js index 5e9ebe4..00f32b6 100644 --- a/test/karma.conf.js +++ b/test/karma.conf.js @@ -13,6 +13,7 @@ module.exports = function ( karma ) { 'bower_components/angular/angular.js', 'bower_components/angular-touch/angular-touch.js', 'bower_components/angular-mocks/angular-mocks.js', + 'bower_components/requirejs/require.js', 'dist/angular-carousel.js', 'test/unit/*.js' ], diff --git a/test/unit/angular-carousel.shifty.js b/test/unit/angular-carousel.shifty.js new file mode 100644 index 0000000..994169c --- /dev/null +++ b/test/unit/angular-carousel.shifty.js @@ -0,0 +1,20 @@ +/*global waits, runs, iit, browserTrigger, beforeEach, afterEach, describe, it, inject, expect, module, angular, $*/ + +describe('angular-carousel.shifty', function () { + 'use strict'; + + describe("compatibility with requirejs", function(){ + var loadShifty = function() { + module('angular-carousel.shifty'); + }; + it("should not throw an exception when load the shifty within requirejs environment", function(){ + expect(loadShifty).not.toThrow(); + }); + + it("should not throw an exception when inject `Tweenable` within requirejs environment", function(){ + loadShifty(); + expect(function() {inject(function(Tweenable){});}).not.toThrow(); + }); + }); + +}); From be0c336ce0b9f2accb774926c506d8ea5ab0f1e5 Mon Sep 17 00:00:00 2001 From: mountainmoon Date: Mon, 29 Dec 2014 00:53:52 +0800 Subject: [PATCH 2/3] add support for 'pause on hover' and fix #268 Make the `rn-carousel-pause-on-hover` attribute work(the old didn't work). --- README.md | 3 +- index.html | 6 +-- src/directives/rn-carousel-auto-slide.js | 48 +++++++----------------- src/directives/rn-carousel.js | 15 +++++--- 4 files changed, 27 insertions(+), 45 deletions(-) diff --git a/README.md b/README.md index 484cc91..c97107b 100644 --- a/README.md +++ b/README.md @@ -67,13 +67,12 @@ You can add position indicators by adding this directive where you want : - angular-carousel use the great [shifty.js](https://github.com/jeremyckahn/shifty) for the animations ## Todo : - - disable autoslide on hover - delay autoslide on indicators click/move - customisable transitions - more transition types - infinite loop support -## Contributing +## Contributing - Please follow [AngularJS GIT conventions](https://docs.google.com/document/d/1QrDFcIiPjSLDn3EL15IJygNPiHORgU1_OOAqWjiDU5Y/edit#) - Please add tests - Please update the README and demo (index.html) diff --git a/index.html b/index.html index 3776ae5..b201000 100644 --- a/index.html +++ b/index.html @@ -38,12 +38,12 @@

Buffered ngRepeat demo

-

buffered ngRepeat with auto-slide and builtin indicators

+

buffered ngRepeat with auto-slide(pause on hover) and builtin indicators