From 0c7f128a989cae6975bb9b4a77e6414877f84bb8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Preczy=C5=84ski?= Date: Wed, 12 Sep 2012 16:23:27 +0200 Subject: [PATCH 1/3] Added orientationEvent option. Now 'onorientationchange' could be disabled by passing 'resize'. --- flickable.js | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/flickable.js b/flickable.js index 5b38d52..c52a473 100644 --- a/flickable.js +++ b/flickable.js @@ -17,9 +17,9 @@ var Flickable = function(elementSelector, options) { nextButtonClass: 'nextSlideButton', prevButtonClass: 'prevSlideButton', nextButtonText: 'Next', - prevButtonText: 'Previous' + prevButtonText: 'Previous', + orientationEvent: 'orientationchange' }, - orientationEvent = 'resize', orientationTimeout; if (elementMatches[1] === '.') { @@ -28,10 +28,6 @@ var Flickable = function(elementSelector, options) { elements = [document.getElementsById(elementMatches[2])]; } - if ('onorientationchange' in window) { - orientationEvent = 'orientationchange'; - } - // Extend settings with options from parameter if (options) { for (i in options) { @@ -41,6 +37,16 @@ var Flickable = function(elementSelector, options) { } } + // 'onorientationchange' could be disabled by passing 'resize' option. + // Default option is 'orientationchange' if supported by browser. + var orientationEvent; + if(settings.orientationEvent === 'orientationchange' + && 'onorientationchange' in window) { + orientationEvent = 'orientationchange'; + } else { + orientationEvent = 'resize'; + } + if (settings.itemWidth) { settings.width = settings.itemWidth; } From f829ca67d1a006936323ada17292696d0c5e0cbd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Preczy=C5=84ski?= Date: Wed, 12 Sep 2012 16:23:27 +0200 Subject: [PATCH 2/3] Added orientationEvent option. Now 'onorientationchange' could be disabled by passing 'resize'. Updated readme file. --- flickable.js | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/flickable.js b/flickable.js index 5b38d52..c52a473 100644 --- a/flickable.js +++ b/flickable.js @@ -17,9 +17,9 @@ var Flickable = function(elementSelector, options) { nextButtonClass: 'nextSlideButton', prevButtonClass: 'prevSlideButton', nextButtonText: 'Next', - prevButtonText: 'Previous' + prevButtonText: 'Previous', + orientationEvent: 'orientationchange' }, - orientationEvent = 'resize', orientationTimeout; if (elementMatches[1] === '.') { @@ -28,10 +28,6 @@ var Flickable = function(elementSelector, options) { elements = [document.getElementsById(elementMatches[2])]; } - if ('onorientationchange' in window) { - orientationEvent = 'orientationchange'; - } - // Extend settings with options from parameter if (options) { for (i in options) { @@ -41,6 +37,16 @@ var Flickable = function(elementSelector, options) { } } + // 'onorientationchange' could be disabled by passing 'resize' option. + // Default option is 'orientationchange' if supported by browser. + var orientationEvent; + if(settings.orientationEvent === 'orientationchange' + && 'onorientationchange' in window) { + orientationEvent = 'orientationchange'; + } else { + orientationEvent = 'resize'; + } + if (settings.itemWidth) { settings.width = settings.itemWidth; } From 3bc2adf08801708577c7a65788758371bcba87fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Preczy=C5=84ski?= Date: Wed, 12 Sep 2012 16:35:38 +0200 Subject: [PATCH 3/3] Changed radme file. --- readme.md | 1 + 1 file changed, 1 insertion(+) diff --git a/readme.md b/readme.md index c838a98..12c6aaf 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. +- `orientationEvent`: Window event which should determine when to change images width. **Default:** `'orientationchange'` _Licensed under the MIT license: http://www.opensource.org/licenses/mit-license.php_ \ No newline at end of file