nir9 / itemslide

JavaScript Touch Carousel Library with Zero Dependencies
https://itemslide.org
MIT License
647 stars 85 forks source link

ItemSlide on a container without any element #48

Closed PurHur closed 8 years ago

PurHur commented 8 years ago

Hey there,

if you try to apply the itemslide on a container without any children you get the error:

Uncaught TypeError: Cannot read property 'offsetWidth' of undefined

Patch (check length):

// Stuff to add for compatibility with Zepto $.fn.outerWidth = function () { if (this.length) { var el = $(this)[0]; var width = el.offsetWidth; var style = getComputedStyle(el); width += parseInt(style.marginLeft) + parseInt(style.marginRight); return width; } else { return 0; } };

P.s: Sorry for not using git correctly :(

PurHur commented 8 years ago

hmm its patched in https://github.com/itemslide/itemslide.github.io/commit/1c6e93e5ccbab1740763347bafb7cd1028aceb7c