From 912a2e2938f3153a1ee4c91e52d9c560009f2cc2 Mon Sep 17 00:00:00 2001 From: La Marciana Date: Thu, 19 Jan 2012 18:58:59 +0100 Subject: [PATCH] Fix sort problem when scroll in (fix #21) --- README.md | 1 + css/jquery.bsmselect.css | 5 +++++ history.md | 7 ++++++- js/jquery.bsmselect.sortable.js | 7 +++++-- 4 files changed, 17 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 3922ccb..bd14c6a 100644 --- a/README.md +++ b/README.md @@ -179,6 +179,7 @@ The newly created select default option is the original select title attribute: * [Victor Berchet](http://github.com/vicb) is the author of bsmSelect * [Andy Fowler](http://github.com/andyfowler) has contributed many enhancements * [Cracky](https://github.com/Cracky) + * [Marc Busqué](https://github.com/laMarciana) has contributed to fix [issue #21](https://github.com/vicb/bsmSelect/issues/21) and with minimal CSS ## History ## diff --git a/css/jquery.bsmselect.css b/css/jquery.bsmselect.css index 16213ae..10e452e 100644 --- a/css/jquery.bsmselect.css +++ b/css/jquery.bsmselect.css @@ -62,3 +62,8 @@ top: 0; padding: 5px; } + +.bsmScrollWorkaround { + padding-bottom: 1px; + overflow: auto; +} diff --git a/history.md b/history.md index 1ef7f19..ed2b0a8 100644 --- a/history.md +++ b/history.md @@ -1,5 +1,10 @@ # bsmSelect # +v1.4.4 - 2012-01-19 + + * Fix issue #21, that's the scroll problem, adding the css class '.bsmScrollWorkaround' and applying it with js when needed + * Minimal CSS modification: set width to auto in list items + v1.4.3 - 2011-05-05 * Fix the position when appending to the list (GH-9) @@ -89,4 +94,4 @@ v1.0.1 - 2011-11-14 v1.0.0 - 2010-09-05 - * intial release \ No newline at end of file + * intial release diff --git a/js/jquery.bsmselect.sortable.js b/js/jquery.bsmselect.sortable.js index dd6dcd1..b8240b9 100644 --- a/js/jquery.bsmselect.sortable.js +++ b/js/jquery.bsmselect.sortable.js @@ -5,7 +5,7 @@ * * Dual licensed under the MIT (MIT-LICENSE.txt) and GPL (GPL-LICENSE.txt) licenses. * - * version: v1.1.2 - 2011-11-14 + * version: v1.4.4 - 2012-01-19 */ (function($) { $.bsmSelect.plugins.sortable = function(sortConfig, options) @@ -27,6 +27,10 @@ config = $.extend({}, this.sortConfig, { items: '.' + o.listItemClass }), self = this; bsm.$list.addClass(o.listSortableClass).sortable(config); + //If statement to fix bug when html element has an overflow set to scroll or auto. Issues #21 (https://github.com/vicb/bsmSelect/issues/21) and #22 (https://github.com/vicb/bsmSelect/pull/22) + if ($.inArray($('html').css('overflow-x'), ['auto', 'scroll']) > -1 || $.inArray($('html').css('overflow-y'), ['auto', 'scroll']) > -1) { + $('.' + o.listSortableClass).addClass('bsmScrollWorkaround'); + } bsm.$original.bind('change', function(e, info) { self.onChange.call(self, bsm, e, info); } ); bsm.$list.bind('sortupdate', function(e, ui) { self.onSort.call(self, bsm, e, ui); } ); }, @@ -46,4 +50,3 @@ } }); })(jQuery); -