Skip to content

Commit

Permalink
👷 build v2.0.11
Browse files Browse the repository at this point in the history
+ ARIA improvements for cells & page dots
  • Loading branch information
desandro committed Feb 27, 2018
1 parent 26e1889 commit 595d8ea
Show file tree
Hide file tree
Showing 7 changed files with 75 additions and 54 deletions.
2 changes: 1 addition & 1 deletion css/flickity.css
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*! Flickity v2.0.10
/*! Flickity v2.0.11
http://flickity.metafizzy.co
---------------------------------------------- */

Expand Down
2 changes: 1 addition & 1 deletion dist/flickity.css
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*! Flickity v2.0.10
/*! Flickity v2.0.11
http://flickity.metafizzy.co
---------------------------------------------- */

Expand Down
2 changes: 1 addition & 1 deletion dist/flickity.min.css

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

113 changes: 67 additions & 46 deletions dist/flickity.pkgd.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* Flickity PACKAGED v2.0.10
* Flickity PACKAGED v2.0.11
* Touch, responsive, flickable carousels
*
* Licensed GPLv3 for open source use
Expand Down Expand Up @@ -531,7 +531,7 @@ return getSize;
}));

/**
* Fizzy UI utils v2.0.5
* Fizzy UI utils v2.0.7
* MIT license
*/

Expand Down Expand Up @@ -586,23 +586,27 @@ utils.modulo = function( num, div ) {

// ----- makeArray ----- //

var arraySlice = Array.prototype.slice;

// turn element or nodeList into an array
utils.makeArray = function( obj ) {
var ary = [];
if ( Array.isArray( obj ) ) {
// use object if already an array
ary = obj;
} else if ( obj && typeof obj == 'object' &&
typeof obj.length == 'number' ) {
return obj;
}
// return empty array if undefined or null. #6
if ( obj === null || obj === undefined ) {
return [];
}

var isArrayLike = typeof obj == 'object' && typeof obj.length == 'number';
if ( isArrayLike ) {
// convert nodeList to array
for ( var i=0; i < obj.length; i++ ) {
ary.push( obj[i] );
}
} else {
// array of single index
ary.push( obj );
return arraySlice.call( obj );
}
return ary;

// array of single index
return [ obj ];
};

// ----- removeFrom ----- //
Expand Down Expand Up @@ -681,22 +685,21 @@ utils.filterFindElements = function( elems, selector ) {
// ----- debounceMethod ----- //

utils.debounceMethod = function( _class, methodName, threshold ) {
threshold = threshold || 100;
// original method
var method = _class.prototype[ methodName ];
var timeoutName = methodName + 'Timeout';

_class.prototype[ methodName ] = function() {
var timeout = this[ timeoutName ];
if ( timeout ) {
clearTimeout( timeout );
}
var args = arguments;
clearTimeout( timeout );

var args = arguments;
var _this = this;
this[ timeoutName ] = setTimeout( function() {
method.apply( _this, args );
delete _this[ timeoutName ];
}, threshold || 100 );
}, threshold );
};
};

Expand Down Expand Up @@ -810,6 +813,7 @@ var proto = Cell.prototype;

proto.create = function() {
this.element.style.position = 'absolute';
this.element.setAttribute( 'aria-selected', 'false' );
this.x = 0;
this.shift = 0;
};
Expand All @@ -818,6 +822,7 @@ proto.destroy = function() {
// reset style
this.element.style.position = '';
var side = this.parent.originSide;
this.element.removeAttribute('aria-selected');
this.element.style[ side ] = '';
};

Expand Down Expand Up @@ -914,16 +919,18 @@ proto.getLastCell = function() {
};

proto.select = function() {
this.changeSelectedClass('add');
this.changeSelected( true );
};

proto.unselect = function() {
this.changeSelectedClass('remove');
this.changeSelected( false );
};

proto.changeSelectedClass = function( method ) {
proto.changeSelected = function( isSelected ) {
var classMethod = isSelected ? 'add' : 'remove';
this.cells.forEach( function( cell ) {
cell.element.classList[ method ]('is-selected');
cell.element.classList[ classMethod ]('is-selected');
cell.element.setAttribute( 'aria-selected', isSelected.toString() );
});
};

Expand Down Expand Up @@ -2014,7 +2021,7 @@ return Flickity;
}));

/*!
* Unipointer v2.2.0
* Unipointer v2.2.1
* base class for doing one thing with pointer event
* MIT license
*/
Expand Down Expand Up @@ -2126,8 +2133,9 @@ proto.onpointerdown = function( event ) {
* @param {Event or Touch} pointer
*/
proto._pointerDown = function( event, pointer ) {
// dismiss other pointers
if ( this.isPointerDown ) {
// dismiss right click and other pointers
// button = 0 is okay, 1-4 not
if ( event.button || this.isPointerDown ) {
return;
}

Expand Down Expand Up @@ -3384,13 +3392,17 @@ PageDots.prototype.setDots = function() {
PageDots.prototype.addDots = function( count ) {
var fragment = document.createDocumentFragment();
var newDots = [];
while ( count ) {
var length = this.dots.length;
var max = length + count;

for ( var i = length; i < max; i++ ) {
var dot = document.createElement('li');
dot.className = 'dot';
dot.setAttribute( 'aria-label', 'Page dot ' + ( i + 1 ) );
fragment.appendChild( dot );
newDots.push( dot );
count--;
}

this.holder.appendChild( fragment );
this.dots = this.dots.concat( newDots );
};
Expand All @@ -3408,13 +3420,15 @@ PageDots.prototype.updateSelected = function() {
// remove selected class on previous
if ( this.selectedDot ) {
this.selectedDot.className = 'dot';
this.selectedDot.removeAttribute('aria-current');
}
// don't proceed if no dots
if ( !this.dots.length ) {
return;
}
this.selectedDot = this.dots[ this.parent.selectedIndex ];
this.selectedDot.className = 'dot is-selected';
this.selectedDot.setAttribute( 'aria-current', 'step' );
};

PageDots.prototype.onTap = function( event ) {
Expand Down Expand Up @@ -4000,7 +4014,7 @@ return Flickity;
}));

/*!
* Flickity v2.0.10
* Flickity v2.0.11
* Touch, responsive, flickable carousels
*
* Licensed GPLv3 for open source use
Expand Down Expand Up @@ -4194,7 +4208,7 @@ return Flickity;
}));

/*!
* imagesLoaded v4.1.3
* imagesLoaded v4.1.4
* JavaScript is all like "You images are done yet or what?"
* MIT License
*/
Expand Down Expand Up @@ -4246,22 +4260,23 @@ function extend( a, b ) {
return a;
}

var arraySlice = Array.prototype.slice;

// turn element or nodeList into an array
function makeArray( obj ) {
var ary = [];
if ( Array.isArray( obj ) ) {
// use object if already an array
ary = obj;
} else if ( typeof obj.length == 'number' ) {
return obj;
}

var isArrayLike = typeof obj == 'object' && typeof obj.length == 'number';
if ( isArrayLike ) {
// convert nodeList to array
for ( var i=0; i < obj.length; i++ ) {
ary.push( obj[i] );
}
} else {
// array of single index
ary.push( obj );
return arraySlice.call( obj );
}
return ary;

// array of single index
return [ obj ];
}

// -------------------------- imagesLoaded -------------------------- //
Expand All @@ -4277,13 +4292,19 @@ function ImagesLoaded( elem, options, onAlways ) {
return new ImagesLoaded( elem, options, onAlways );
}
// use elem as selector string
var queryElem = elem;
if ( typeof elem == 'string' ) {
elem = document.querySelectorAll( elem );
queryElem = document.querySelectorAll( elem );
}
// bail if bad element
if ( !queryElem ) {
console.error( 'Bad element for imagesLoaded ' + ( queryElem || elem ) );
return;
}

this.elements = makeArray( elem );
this.elements = makeArray( queryElem );
this.options = extend( {}, this.options );

// shift arguments if no options set
if ( typeof options == 'function' ) {
onAlways = options;
} else {
Expand All @@ -4302,9 +4323,7 @@ function ImagesLoaded( elem, options, onAlways ) {
}

// HACK check async to allow time to bind listeners
setTimeout( function() {
this.check();
}.bind( this ));
setTimeout( this.check.bind( this ) );
}

ImagesLoaded.prototype = Object.create( EvEmitter.prototype );
Expand Down Expand Up @@ -4472,7 +4491,9 @@ LoadingImage.prototype.check = function() {
};

LoadingImage.prototype.getIsImageComplete = function() {
return this.img.complete && this.img.naturalWidth !== undefined;
// check for non-zero, non-undefined naturalWidth
// fixes Safari+InfiniteScroll+Masonry bug infinite-scroll#671
return this.img.complete && this.img.naturalWidth;
};

LoadingImage.prototype.confirm = function( isLoaded, message ) {
Expand Down
6 changes: 3 additions & 3 deletions dist/flickity.pkgd.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* Flickity v2.0.10
* Flickity v2.0.11
* Touch, responsive, flickable carousels
*
* Licensed GPLv3 for open source use
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "flickity",
"version": "2.0.10",
"version": "2.0.11",
"description": "Touch, responsive, flickable carousels",
"main": "js/index.js",
"style": "css/flickity.css",
Expand Down

0 comments on commit 595d8ea

Please sign in to comment.