Skip to content

Commit 1a79515

Browse files
committed
version 1.9.0
1 parent 8e09c92 commit 1a79515

8 files changed

Lines changed: 595 additions & 519 deletions

README.md

Lines changed: 494 additions & 452 deletions
Large diffs are not rendered by default.

css/OverlayScrollbars.css

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
* OverlayScrollbars
33
* https://github.com/KingSora/OverlayScrollbars
44
*
5-
* Version: 1.8.0
5+
* Version: 1.9.0
66
*
77
* Copyright KingSora | Rene Haas.
88
* https://github.com/KingSora
99
*
1010
* Released under the MIT license.
11-
* Date: 08.07.2019
11+
* Date: 27.07.2019
1212
*/
1313

1414
/*

css/OverlayScrollbars.min.css

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

js/OverlayScrollbars.js

Lines changed: 45 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
* OverlayScrollbars
33
* https://github.com/KingSora/OverlayScrollbars
44
*
5-
* Version: 1.8.0
5+
* Version: 1.9.0
66
*
77
* Copyright KingSora | Rene Haas.
88
* https://github.com/KingSora
99
*
1010
* Released under the MIT license.
11-
* Date: 08.07.2019
11+
* Date: 27.07.2019
1212
*/
1313

1414
(function (global, factory) {
@@ -1440,6 +1440,7 @@
14401440
}
14411441
})();
14421442
var PLUGIN = (function() {
1443+
var _plugin;
14431444
var _pluginsGlobals;
14441445
var _pluginsAutoUpdateLoop;
14451446
var _pluginsExtensions = [ ];
@@ -2005,7 +2006,7 @@
20052006
var each = FRAMEWORK.each;
20062007

20072008
//make correct instanceof
2008-
var _base = new window[PLUGINNAME]();
2009+
var _base = new _plugin();
20092010
var _frameworkProto = FRAMEWORK[LEXICON.p];
20102011

20112012
//if passed element is no HTML element: skip and return
@@ -2218,8 +2219,6 @@
22182219
var _ignoreOverlayScrollbarHidingCache;
22192220
var _autoUpdateCache;
22202221
var _sizeAutoCapableCache;
2221-
var _textareaAutoWrappingCache;
2222-
var _textareaInfoCache;
22232222
var _contentElementScrollSizeChangeDetectedCache;
22242223
var _hostElementSizeChangeDetectedCache;
22252224
var _scrollbarsVisibilityCache;
@@ -2230,6 +2229,9 @@
22302229
var _normalizeRTLCache;
22312230
var _classNameCache;
22322231
var _oldClassName;
2232+
var _textareaAutoWrappingCache;
2233+
var _textareaInfoCache;
2234+
var _textareaSizeCache;
22332235
var _textareaDynHeightCache;
22342236
var _textareaDynWidthCache;
22352237
var _bodyMinSizeCache;
@@ -3519,29 +3521,35 @@
35193521

35203522
//update Textarea
35213523
var textareaSize = _isTextarea ? textareaUpdate() : false;
3524+
var textareaSizeChanged = _isTextarea && checkCacheAutoForce(textareaSize, _textareaSizeCache);
35223525
var textareaDynOrigSize = _isTextarea && textareaSize ? {
35233526
w : textareaDynWidth ? textareaSize._dynamicWidth : textareaSize._originalWidth,
35243527
h : textareaDynHeight ? textareaSize._dynamicHeight : textareaSize._originalHeight
35253528
} : { };
3526-
3529+
_textareaSizeCache = textareaSize;
3530+
35273531
//fix height auto / width auto in cooperation with current padding & boxSizing behavior:
35283532
if (heightAuto && (heightAutoChanged || paddingAbsoluteChanged || boxSizingChanged || cssMaxValue.c || padding.c || border.c)) {
3529-
//if (cssMaxValue.ch)
3530-
contentElementCSS[_strMaxMinus + _strHeight] =
3531-
(cssMaxValue.ch ? (cssMaxValue.ih - paddingAbsoluteY + (_isBorderBox ? -_borderY : _paddingY))
3532-
: _strEmpty);
3533+
/*
3534+
if (cssMaxValue.ch)
3535+
contentElementCSS[_strMaxMinus + _strHeight] =
3536+
(cssMaxValue.ch ? (cssMaxValue.ih - paddingAbsoluteY + (_isBorderBox ? -_borderY : _paddingY))
3537+
: _strEmpty);
3538+
*/
35333539
contentElementCSS[_strHeight] = _strAuto;
35343540
}
35353541
else if (heightAutoChanged || paddingAbsoluteChanged) {
35363542
contentElementCSS[_strMaxMinus + _strHeight] = _strEmpty;
35373543
contentElementCSS[_strHeight] = _strHundredPercent;
35383544
}
35393545
if (widthAuto && (widthAutoChanged || paddingAbsoluteChanged || boxSizingChanged || cssMaxValue.c || padding.c || border.c || cssDirectionChanged)) {
3540-
//if (cssMaxValue.cw)
3541-
contentElementCSS[_strMaxMinus + _strWidth] =
3542-
(cssMaxValue.cw ? (cssMaxValue.iw - paddingAbsoluteX + (_isBorderBox ? -_borderX : _paddingX)) +
3543-
(_nativeScrollbarIsOverlaid.y /*&& _hasOverflowCache.y && widthAuto */ ? _overlayScrollbarDummySize.y : 0)
3544-
: _strEmpty);
3546+
/*
3547+
if (cssMaxValue.cw)
3548+
contentElementCSS[_strMaxMinus + _strWidth] =
3549+
(cssMaxValue.cw ? (cssMaxValue.iw - paddingAbsoluteX + (_isBorderBox ? -_borderX : _paddingX)) +
3550+
(_nativeScrollbarIsOverlaid.y ? _overlayScrollbarDummySize.y : 0)
3551+
: _strEmpty);
3552+
*/
35453553
contentElementCSS[_strWidth] = _strAuto;
35463554
contentGlueElementCSS[_strMaxMinus + _strWidth] = _strHundredPercent; //IE Fix
35473555
}
@@ -3581,7 +3589,7 @@
35813589
contentGlueElementCSS = {};
35823590

35833591
//if [content(host) client / scroll size, or target element direction, or content(host) max-sizes] changed, or force is true
3584-
if (hostSizeChanged || contentSizeChanged || cssDirectionChanged || boxSizingChanged || paddingAbsoluteChanged || widthAutoChanged || widthAuto || heightAutoChanged || heightAuto || cssMaxValue.c || ignoreOverlayScrollbarHidingChanged || overflowBehaviorChanged || clipAlwaysChanged || resizeChanged || scrollbarsVisibilityChanged || scrollbarsAutoHideChanged || scrollbarsDragScrollingChanged || scrollbarsClickScrollingChanged || textareaDynWidthChanged || textareaDynHeightChanged || textareaAutoWrappingChanged) {
3592+
if (hostSizeChanged || contentSizeChanged || textareaSizeChanged || cssDirectionChanged || boxSizingChanged || paddingAbsoluteChanged || widthAutoChanged || widthAuto || heightAutoChanged || heightAuto || cssMaxValue.c || ignoreOverlayScrollbarHidingChanged || overflowBehaviorChanged || clipAlwaysChanged || resizeChanged || scrollbarsVisibilityChanged || scrollbarsAutoHideChanged || scrollbarsDragScrollingChanged || scrollbarsClickScrollingChanged || textareaDynWidthChanged || textareaDynHeightChanged || textareaAutoWrappingChanged) {
35853593
var strOverflow = 'overflow';
35863594
var strOverflowX = strOverflow + '-x';
35873595
var strOverflowY = strOverflow + '-y';
@@ -3597,8 +3605,8 @@
35973605
//Reset the viewport (very important for natively overlaid scrollbars and zoom change
35983606
//don't change the overflow prop as it is very expensive and affects performance !A LOT!
35993607
var viewportElementResetCSS = { };
3600-
var resetXTmp = _hasOverflowCache.y && _hideOverflowCache.ys && !ignoreOverlayScrollbarHiding ? (_nativeScrollbarIsOverlaid.y ? _viewportElement.css(isRTLLeft) : -_nativeScrollbarSize.y) : 0;
3601-
var resetBottomTmp = _hasOverflowCache.x && _hideOverflowCache.xs && !ignoreOverlayScrollbarHiding ? (_nativeScrollbarIsOverlaid.x ? _viewportElement.css(_strBottom) : -_nativeScrollbarSize.x) : 0;
3608+
var resetXTmp = _hasOverflowCache.y && _hideOverflowCache.ys && !ignoreOverlayScrollbarHiding && !_nativeScrollbarStyling ? (_nativeScrollbarIsOverlaid.y ? _viewportElement.css(isRTLLeft) : -_nativeScrollbarSize.y) : 0;
3609+
var resetBottomTmp = _hasOverflowCache.x && _hideOverflowCache.xs && !ignoreOverlayScrollbarHiding && !_nativeScrollbarStyling ? (_nativeScrollbarIsOverlaid.x ? _viewportElement.css(_strBottom) : -_nativeScrollbarSize.x) : 0;
36023610
setTopRightBottomLeft(viewportElementResetCSS, _strEmpty);
36033611
_viewportElement.css(viewportElementResetCSS);
36043612
if(hideOverflow4CorrectMeasuring)
@@ -3671,7 +3679,7 @@
36713679
contentGlueElementCSS[strWH] = maxSize + (_isBorderBox ? 0 : paddingSize) + 1;
36723680

36733681
//if size is auto and host is smaller than size as min size, make content glue size -1 to make sure size changes will be detected (this is only needed if padding is 0)
3674-
if (autoSize && (contentSize[wh] < _viewportSize[wh]) && (horizontal ? (_isTextarea ? !textareaAutoWrapping : false) : true)) {
3682+
if (autoSize && (contentSize[wh] < _viewportSize[wh]) && (horizontal && _isTextarea ? !textareaAutoWrapping : true)) {
36753683
if (_isTextarea)
36763684
textareaCoverCSS[strWH] = parseToZeroOrNumber(_textareaCoverElement.css(strWH)) - 1;
36773685
contentGlueElementCSS[strWH] -= 1;
@@ -4015,8 +4023,7 @@
40154023
else
40164024
_scrollbarCornerElement[remove ? 'off' : 'on'](_strMouseTouchDownEvent, _resizeOnMouseTouchDown);
40174025
};
4018-
removeClass(_scrollbarCornerElement, [
4019-
_classNameHostResizeDisabled,
4026+
removeClass(_scrollbarCornerElement, [
40204027
_classNameScrollbarCornerResize,
40214028
_classNameScrollbarCornerResizeB,
40224029
_classNameScrollbarCornerResizeH,
@@ -4026,6 +4033,7 @@
40264033
setupCornerEvents(true);
40274034
}
40284035
else {
4036+
removeClass(_hostElement, _classNameHostResizeDisabled);
40294037
addClass(_scrollbarCornerElement, _classNameScrollbarCornerResize);
40304038
if (_resizeBoth)
40314039
addClass(_scrollbarCornerElement, _classNameScrollbarCornerResizeB);
@@ -6130,7 +6138,7 @@
61306138
* @returns {{}} The instance of the added extension or undefined if the extension couldn't be added properly.
61316139
*/
61326140
_base.addExt = function(extName, extensionOptions) {
6133-
var registeredExtensionObj = window[PLUGINNAME].extension(extName);
6141+
var registeredExtensionObj = _plugin.extension(extName);
61346142
var instance;
61356143
var instanceAdded;
61366144
var instanceContract;
@@ -6318,7 +6326,7 @@
63186326
* @param extensions The extension(s) which shall be added right after initialization.
63196327
* @returns {*}
63206328
*/
6321-
window[PLUGINNAME] = function(pluginTargetElements, options, extensions) {
6329+
_plugin = window[PLUGINNAME] = function(pluginTargetElements, options, extensions) {
63226330
if(arguments[LEXICON.l] === 0)
63236331
return this;
63246332

@@ -6352,7 +6360,7 @@
63526360
else {
63536361
FRAMEWORK.each(pluginTargetElements, function(i, v) {
63546362
inst = INSTANCES(v);
6355-
if((options === '!' && inst instanceof window[PLUGINNAME]) || (COMPATIBILITY.type(options) == TYPES.f && options(v, inst)))
6363+
if((options === '!' && _plugin.valid(inst)) || (COMPATIBILITY.type(options) == TYPES.f && options(v, inst)))
63566364
arr.push(inst);
63576365
else if(options === undefined)
63586366
arr.push(inst);
@@ -6367,7 +6375,7 @@
63676375
* Returns a object which contains global information about the plugin and each instance of it.
63686376
* The returned object is just a copy, that means that changes to the returned object won't have any effect to the original object.
63696377
*/
6370-
window[PLUGINNAME].globals = function () {
6378+
_plugin.globals = function () {
63716379
initOverlayScrollbarsStatics();
63726380
var globals = FRAMEWORK.extend(true, { }, _pluginsGlobals);
63736381
delete globals['msie'];
@@ -6378,7 +6386,7 @@
63786386
* Gets or Sets the default options for each new plugin initialization.
63796387
* @param newDefaultOptions The object with which the default options shall be extended.
63806388
*/
6381-
window[PLUGINNAME].defaultOptions = function(newDefaultOptions) {
6389+
_plugin.defaultOptions = function(newDefaultOptions) {
63826390
initOverlayScrollbarsStatics();
63836391
var currDefaultOptions = _pluginsGlobals.defaultOptions;
63846392
if(newDefaultOptions === undefined)
@@ -6388,6 +6396,15 @@
63886396
_pluginsGlobals.defaultOptions = FRAMEWORK.extend(true, { }, currDefaultOptions , _pluginsOptions._validate(newDefaultOptions, _pluginsOptions._template, true, currDefaultOptions)._default);
63896397
};
63906398

6399+
/**
6400+
* Checks whether the passed instance is a non-destroyed OverlayScrollbars instance.
6401+
* @param osInstance The potential OverlayScrollbars instance which shall be checked.
6402+
* @returns {boolean} True if the passed value is a non-destroyed OverlayScrollbars instance, false otherwise.
6403+
*/
6404+
_plugin.valid = function (osInstance) {
6405+
return osInstance instanceof _plugin && !osInstance.getState().destroyed;
6406+
};
6407+
63916408
/**
63926409
* Registers, Unregisters or returns a extension.
63936410
* Register: Pass the name and the extension. (defaultOptions is optional)
@@ -6398,7 +6415,7 @@
63986415
* @param extension A function which generates the instance of the extension or anything other to remove a already registered extension.
63996416
* @param defaultOptions The default options which shall be used for the registered extension.
64006417
*/
6401-
window[PLUGINNAME].extension = function(extensionName, extension, defaultOptions) {
6418+
_plugin.extension = function(extensionName, extension, defaultOptions) {
64026419
var extNameTypeString = COMPATIBILITY.type(extensionName) == TYPES.s;
64036420
var argLen = arguments[LEXICON.l];
64046421
var i = 0;
@@ -6428,7 +6445,7 @@
64286445
}
64296446
};
64306447

6431-
return window[PLUGINNAME];
6448+
return _plugin;
64326449
})();
64336450

64346451
if(JQUERY && JQUERY.fn) {

js/OverlayScrollbars.min.js

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)