diff --git a/flickable.js b/flickable.js index 5b38d52..35c4031 100644 --- a/flickable.js +++ b/flickable.js @@ -17,7 +17,10 @@ var Flickable = function(elementSelector, options) { nextButtonClass: 'nextSlideButton', prevButtonClass: 'prevSlideButton', nextButtonText: 'Next', - prevButtonText: 'Previous' + prevButtonText: 'Previous', + widthCallback: function() { + return window.innerWidth; + } }, orientationEvent = 'resize', orientationTimeout; @@ -47,11 +50,11 @@ var Flickable = function(elementSelector, options) { if (settings.width == 'screen') { settings.widthScreen = true; - settings.width = window.innerWidth; + settings.width = settings.widthCallback(); window.addEventListener(orientationEvent, function(e) { clearTimeout(orientationTimeout); orientationTimeout = setTimeout(function() { - settings.width = window.innerWidth; + settings.width = settings.widthCallback(); }, 200); }); } diff --git a/readme.md b/readme.md index c838a98..c241c81 100644 --- a/readme.md +++ b/readme.md @@ -48,5 +48,6 @@ Settings reference - `indicatorClass`: The class name for the indicator wrapper element. **Default:** `'flickableIndicator'` - `activeIndicatorClass`: The class name for the active indicator element. **Default:** `'flickableIndicatorActive'` - `callback`: A function to be called each time the slide changes. The function will be passed the slide number (zero-indexed) as a parameter. +- `widthCallback`: A function to be called each time the orientation changes. The function should return new images width. _Licensed under the MIT license: http://www.opensource.org/licenses/mit-license.php_ \ No newline at end of file