From 1118938e3063d05a6eb84683681ceddc022e1b63 Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Thu, 28 Jun 2012 12:18:33 +0200 Subject: [PATCH] Detect scrollbar width for browser that do not support scrollbar styling. Fixes #800 --- source/Ox.UI/Ox.UI.js | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/source/Ox.UI/Ox.UI.js b/source/Ox.UI/Ox.UI.js index 9dfa0875..aef05fc8 100644 --- a/source/Ox.UI/Ox.UI.js +++ b/source/Ox.UI/Ox.UI.js @@ -400,7 +400,25 @@ Ox.load.UI = function(options, callback) { //@ Ox.UI.PATH Path of Ox.UI Ox.UI.PATH = Ox.PATH + 'Ox.UI/'; //@ Ox.UI.SCOLLBAR_SIZE size of scrollbar - Ox.UI.SCROLLBAR_SIZE = $.browser.mozilla ? 16 : 12; + Ox.UI.SCROLLBAR_SIZE = $.browser.webkit ? 12 : (function() { + var inner = $('

').css({ + height: '200px', + width: '100%' + }), + outer = $('

').css({ + height: '150px', + left: 0, + overflow: 'hidden', + position: 'absolute', + top: 0, + visibility: 'hidden', + width: '200px' + }).append(inner).appendTo($('body')), + width; + width = inner[0].offsetWidth; + outer.css({overflow: 'scroll'}); + return 1 + width - (inner[0].offsetWidth == width ? outer[0].clientWidth : inner[0].offsetWidth); + })(); //@ Ox.UI.getBarSize get bar size by name // fixme: the follwing should be deprecated Ox.UI.getBarSize = function(size) {