carousel-js
Advanced tools
Comparing version 3.0.1 to 3.1.0
'use strict'; | ||
module.exports = { | ||
dist: 'dist', | ||
build: { | ||
@@ -9,3 +8,3 @@ files: { | ||
browserifyOptions: { | ||
standalone: 'Carousel' | ||
standalone: 'Carousel', | ||
}, | ||
@@ -20,5 +19,5 @@ minifyFiles: { | ||
mocha: { | ||
src: ['tests/*.js'] | ||
files: ['tests/*.js'] | ||
} | ||
} | ||
}; |
{ | ||
"name": "carousel-js", | ||
"version": "3.0.1", | ||
"version": "3.1.0", | ||
"description": "Easily implement a dynamic carousel using minimal javascript. Supports Meteor, AngularJS, React, Polymer and any CSS library, e.g. Bootstrap. ", | ||
@@ -27,2 +27,18 @@ "repository": { | ||
], | ||
"main": "./src/carousel.js", | ||
"dependencies": { | ||
"lodash.defer": "^4.1.0", | ||
"module-js": "^5.10.9", | ||
"promise": "^7.1.1", | ||
"resource-manager-js": "^2.3.7" | ||
}, | ||
"devDependencies": { | ||
"babel-plugin-add-module-exports": "^0.2.1", | ||
"babel-plugin-transform-es2015-modules-commonjs": "^6.18.0", | ||
"babel-plugin-transform-object-assign": "^6.8.0", | ||
"babel-preset-es2015": "^6.18.0", | ||
"babelify": "^7.3.0", | ||
"build-tools": "^6.0.4", | ||
"sinon": "^1.17.3" | ||
}, | ||
"browserify": { | ||
@@ -35,2 +51,13 @@ "transform": [ | ||
"es2015" | ||
], | ||
"plugins": [ | ||
[ | ||
"add-module-exports" | ||
], | ||
[ | ||
"transform-object-assign" | ||
], | ||
[ | ||
"transform-es2015-modules-commonjs" | ||
] | ||
] | ||
@@ -41,16 +68,2 @@ } | ||
}, | ||
"main": "src/carousel.js", | ||
"dependencies": { | ||
"lodash": "^4.6.1", | ||
"module-js": "^5.9.2", | ||
"promise": "^7.1.1" | ||
}, | ||
"devDependencies": { | ||
"babel-polyfill": "^6.7.4", | ||
"babel-preset-es2015": "^6.6.0", | ||
"babelify": "^7.3.0", | ||
"browserify": "^13.0.1", | ||
"build-tools": "^3.1.0", | ||
"sinon": "^1.17.3" | ||
}, | ||
"scripts": { | ||
@@ -57,0 +70,0 @@ "test": "bt test", |
@@ -25,4 +25,4 @@ [![Build Status](https://travis-ci.org/mkay581/carousel-js.svg?branch=master)](https://travis-ci.org/mkay581/carousel-js) | ||
In order to use carousel, you can use one of the [pre-built files](/dist) if you want to quickly get started. Or, alternatively | ||
you can use the [source files](/src) directly if you are running your own build processes. | ||
In order to use carousel, you can use one of the [pre-built files](/dist) if you want to quickly get started. | ||
Or, alternatively you can install as an npm package or use the [source files](/src) directly if you are using [Browserify](http://browserify.org/). | ||
@@ -29,0 +29,0 @@ ### Carousel |
'use strict'; | ||
import _ from 'lodash'; | ||
@@ -18,3 +17,3 @@ /** | ||
*/ | ||
class CarouselArrows { | ||
export default class CarouselArrows { | ||
@@ -33,3 +32,3 @@ /** | ||
options = _.extend({ | ||
options = Object.assign({ | ||
leftArrow: null, | ||
@@ -181,3 +180,1 @@ rightArrow: null, | ||
} | ||
module.exports = CarouselArrows; |
'use strict'; | ||
import Promise from 'promise'; | ||
import _ from 'lodash'; | ||
import Module from 'module-js'; | ||
class CarouselPanel extends Module { | ||
export default class CarouselPanel extends Module { | ||
@@ -17,3 +16,3 @@ /** | ||
constructor (el, options) { | ||
options = _.extend({ | ||
options = Object.assign({ | ||
activeClass: 'carousel-panel-active', | ||
@@ -85,3 +84,1 @@ lazyLoadAttr: null, | ||
} | ||
module.exports = CarouselPanel; |
'use strict'; | ||
import _ from 'lodash'; | ||
import Promise from 'promise'; | ||
@@ -18,3 +17,3 @@ import CarouselPanel from './carousel-panel'; | ||
*/ | ||
class CarouselPanels { | ||
export default class CarouselPanels { | ||
@@ -34,3 +33,3 @@ /** | ||
options = _.extend({ | ||
options = Object.assign({ | ||
panels: [], | ||
@@ -197,3 +196,1 @@ assetLoadedClass: 'carousel-asset-loaded', | ||
} | ||
module.exports = CarouselPanels; |
'use strict'; | ||
import _ from 'lodash'; | ||
@@ -16,3 +15,3 @@ /** | ||
*/ | ||
class CarouselThumbs { | ||
export default class CarouselThumbs { | ||
@@ -28,3 +27,3 @@ /** | ||
constructor (options) { | ||
options = _.extend({ | ||
options = Object.assign({ | ||
thumbnails: [], | ||
@@ -148,3 +147,1 @@ thumbnailActiveTriggerEvent: 'click', | ||
} | ||
module.exports = CarouselThumbs; |
@@ -5,3 +5,2 @@ 'use strict'; | ||
import CarouselArrows from './carousel-arrows'; | ||
import _ from 'lodash'; | ||
/** | ||
@@ -31,3 +30,3 @@ * A callback function that fires after a new active panel is set | ||
class Carousel { | ||
export default class Carousel { | ||
@@ -51,3 +50,3 @@ /** | ||
options = _.extend({ | ||
options = Object.assign({ | ||
panels: [], | ||
@@ -109,3 +108,3 @@ assetLoadingClass: 'carousel-asset-loading', | ||
_setupThumbs (options) { | ||
return new CarouselThumbs(_.extend({}, options, { | ||
return new CarouselThumbs(Object.assign({}, options, { | ||
onChange: this.onThumbnailChange.bind(this) | ||
@@ -123,3 +122,3 @@ })); | ||
if (options.panels.length) { | ||
return new CarouselPanels(_.extend({}, options, { | ||
return new CarouselPanels(Object.assign({}, options, { | ||
onChange: this.onPanelChange.bind(this) | ||
@@ -139,3 +138,3 @@ })); | ||
// make clone of original options | ||
internalOptions = _.extend({}, options); | ||
internalOptions = Object.assign({}, options); | ||
@@ -272,3 +271,1 @@ internalOptions.onLeftArrowClick = this.onLeftArrowClick.bind(this); | ||
} | ||
module.exports = Carousel; |
'use strict'; | ||
var sinon = require('sinon'); | ||
var CarouselArrows = require('../src/carousel-arrows'); | ||
import CarouselArrows from '../src/carousel-arrows'; | ||
var assert = require('assert'); | ||
@@ -5,0 +5,0 @@ |
"use strict"; | ||
var sinon = require('sinon'); | ||
var CarouselPanel = require('../src/carousel-panel'); | ||
import CarouselPanel from '../src/carousel-panel'; | ||
var assert = require('assert'); | ||
var _ = require('lodash'); | ||
var defer = require('lodash.defer'); | ||
var Promise = require('promise'); | ||
@@ -38,3 +38,3 @@ // must import module in order to operate off of prototype | ||
// call stack has completed since it is wrapped in a Promise | ||
_.defer(function () { | ||
defer(function () { | ||
assert.ok(image.classList.contains(imageLoadedClass), 'once image is loaded, the loaded class is added'); | ||
@@ -61,6 +61,6 @@ panel.destroy(); | ||
images[0].onload(); | ||
_.defer(function () { | ||
defer(function () { | ||
assert.equal(onLoadSpy.callCount, 0, 'load still hasnt resolved after first image load because there is also a second one'); | ||
images[1].onload(); | ||
_.defer(function () { | ||
defer(function () { | ||
assert.equal(onLoadSpy.callCount, 1, 'load has resolved after final image loads'); | ||
@@ -67,0 +67,0 @@ panel.destroy(); |
"use strict"; | ||
var CarouselPanels = require('./../src/carousel-panels'); | ||
var CarouselPanel = require('./../src/carousel-panel'); | ||
import CarouselPanels from './../src/carousel-panels'; | ||
import CarouselPanel from './../src/carousel-panel'; | ||
var sinon = require('sinon'); | ||
var assert = require('assert'); | ||
var _ = require('lodash'); | ||
var Promise = require('promise'); | ||
@@ -8,0 +7,0 @@ |
'use strict'; | ||
var sinon = require('sinon'); | ||
var CarouselArrows = require('../src/carousel-arrows'); | ||
var CarouselThumbs = require('../src/carousel-thumbs'); | ||
var Carousel = require('../src/carousel'); | ||
import Carousel from '../src/carousel'; | ||
import CarouselArrows from '../src/carousel-arrows'; | ||
import CarouselThumbs from '../src/carousel-thumbs'; | ||
import CarouselPanels from '../src/carousel-panels'; | ||
var assert = require('assert'); | ||
var CarouselPanels = require('../src/carousel'); | ||
@@ -76,3 +76,3 @@ describe('Carousel', function () { | ||
it('should return CarouselPanel\'s getCurrentIndex() when getCurrentIndex() is called', function () { | ||
it('should return CarouselPanel\'s getCurrentIndex() of 0 after initialization', function () { | ||
var carouselEl = document.createElement('div'); | ||
@@ -83,12 +83,21 @@ carouselEl.innerHTML = | ||
'<div class="carousel-panel"></div>'; | ||
var carouselPanelsGetCurrentIndexStub = sinon.stub(CarouselPanels.prototype, 'getCurrentIndex'); | ||
var panels = carouselEl.getElementsByClassName('carousel-panel'); | ||
var carouselView = new Carousel({panels: panels}); | ||
var panelReturnValue = 2500; | ||
carouselPanelsGetCurrentIndexStub.returns(panelReturnValue); | ||
assert.equal(carouselView.getCurrentIndex(), panelReturnValue); | ||
assert.equal(carouselView.getCurrentIndex(), 0); | ||
carouselView.destroy(); | ||
carouselPanelsGetCurrentIndexStub.restore(); | ||
}); | ||
it('should return CarouselPanel\'s getCurrentIndex() of 1 after switching to second panel', function () { | ||
var carouselEl = document.createElement('div'); | ||
carouselEl.innerHTML = | ||
'<div class="carousel-panel"></div>' + | ||
'<div class="carousel-panel"></div>' + | ||
'<div class="carousel-panel"></div>'; | ||
var panels = carouselEl.getElementsByClassName('carousel-panel'); | ||
var carouselView = new Carousel({panels: panels}); | ||
carouselView.goTo(1); | ||
assert.equal(carouselView.getCurrentIndex(), 1); | ||
carouselView.destroy(); | ||
}); | ||
it('should invoke the onPanelChange function with the index passed to goTo()', function () { | ||
@@ -95,0 +104,0 @@ var carouselEl = document.createElement('div'); |
var sinon = require('sinon'); | ||
var CarouselThumbs = require('../src/carousel-thumbs'); | ||
var assert = require('assert'); | ||
import CarouselThumbs from '../src/carousel-thumbs'; | ||
@@ -5,0 +5,0 @@ describe('Carousel Thumbs', function () { |
1254877
4
7
28665
+ Addedlodash.defer@^4.1.0
+ Addedresource-manager-js@^2.3.7
+ Addedlodash.defer@4.1.0(transitive)
- Removedlodash@^4.6.1
Updatedmodule-js@^5.10.9