14
(function (global, factory) {
15
if (typeof define === 'function' && define.amd)
16
define(['jquery'], function (framework) { return factory(global, global.document, undefined, framework); });
17
else if (typeof module === 'object' && typeof module.exports === 'object')
18
module.exports = factory(global, global.document, undefined, require('jquery'));
20
factory(global, global.document, undefined, global.jQuery);
21
}(typeof window !== 'undefined' ? window : this,
22
function (window, document, undefined, framework) {
24
var PLUGINNAME = 'OverlayScrollbars';
52
hOP: 'hasOwnProperty',
53
bCR: 'getBoundingClientRect'
55
var VENDORS = (function () {
59
var cssPrefixes = ['-webkit-', '-moz-', '-o-', '-ms-'];
60
var jsPrefixes = ['WebKit', 'Moz', 'O', 'MS'];
61
function firstLetterToUpper(str) {
62
return str.charAt(0).toUpperCase() + str.slice(1);
66
_cssPrefixes: cssPrefixes,
67
_jsPrefixes: jsPrefixes,
68
_cssProperty: function (name) {
69
var result = cssCache[name];
71
if (cssCache[LEXICON.hOP](name))
74
var uppercasedName = firstLetterToUpper(name);
75
var elmStyle = document.createElement('div')[LEXICON.s];
76
var resultPossibilities;
79
var currVendorWithoutDashes;
81
for (; i < cssPrefixes.length; i++) {
82
currVendorWithoutDashes = cssPrefixes[i].replace(/-/g, '');
83
resultPossibilities = [
85
cssPrefixes[i] + name,
86
currVendorWithoutDashes + uppercasedName,
87
firstLetterToUpper(currVendorWithoutDashes) + uppercasedName
89
for (v = 0; v < resultPossibilities[LEXICON.l]; v++) {
90
if (elmStyle[resultPossibilities[v]] !== undefined) {
91
result = resultPossibilities[v];
97
cssCache[name] = result;
100
_cssPropertyValue: function (property, values, suffix) {
101
var name = property + ' ' + values;
102
var result = cssCache[name];
104
if (cssCache[LEXICON.hOP](name))
107
var dummyStyle = document.createElement('div')[LEXICON.s];
108
var possbleValues = values.split(' ');
109
var preparedSuffix = suffix || '';
114
for (; i < possbleValues[LEXICON.l]; i++) {
115
for (; v < VENDORS._cssPrefixes[LEXICON.l]; v++) {
116
prop = v < 0 ? possbleValues[i] : VENDORS._cssPrefixes[v] + possbleValues[i];
117
dummyStyle.cssText = property + ':' + prop + preparedSuffix;
118
if (dummyStyle[LEXICON.l]) {
125
cssCache[name] = result;
128
_jsAPI: function (name, isInterface, fallback) {
130
var result = jsCache[name];
132
if (!jsCache[LEXICON.hOP](name)) {
133
result = window[name];
134
for (; i < jsPrefixes[LEXICON.l]; i++)
135
result = result || window[(isInterface ? jsPrefixes[i] : jsPrefixes[i].toLowerCase()) + firstLetterToUpper(name)];
136
jsCache[name] = result;
138
return result || fallback;
142
var COMPATIBILITY = (function () {
143
function windowSize(x) {
144
return x ? window.innerWidth || document.documentElement[LEXICON.cW] || document.body[LEXICON.cW] : window.innerHeight || document.documentElement[LEXICON.cH] || document.body[LEXICON.cH];
146
function bind(func, thisObj) {
147
if (typeof func != TYPES.f) {
148
throw "Can't bind function!";
153
var proto = LEXICON.p;
154
var aArgs = Array[proto].slice.call(arguments, 2);
155
var fNOP = function () { };
156
var fBound = function () { return func.apply(this instanceof fNOP ? this : thisObj, aArgs.concat(Array[proto].slice.call(arguments))); };
159
fNOP[proto] = func[proto];
160
fBound[proto] = new fNOP();
170
wW: bind(windowSize, 0, true),
176
wH: bind(windowSize, 0),
182
mO: bind(VENDORS._jsAPI, 0, 'MutationObserver', true),
188
rO: bind(VENDORS._jsAPI, 0, 'ResizeObserver', true),
194
rAF: bind(VENDORS._jsAPI, 0, 'requestAnimationFrame', false, function (func) { return window.setTimeout(func, 1000 / 60); }),
200
cAF: bind(VENDORS._jsAPI, 0, 'cancelAnimationFrame', false, function (id) { return window.clearTimeout(id); }),
207
return Date.now && Date.now() || new Date().getTime();
214
stpP: function (event) {
215
if (event.stopPropagation)
216
event.stopPropagation();
218
event.cancelBubble = true;
225
prvD: function (event) {
226
if (event.preventDefault && event.cancelable)
227
event.preventDefault();
229
event.returnValue = false;
237
page: function (event) {
238
event = event.originalEvent || event;
240
var strPage = 'page';
241
var strClient = 'client';
244
var target = event.target || event.srcElement || document;
245
var eventDoc = target.ownerDocument || document;
246
var doc = eventDoc.documentElement;
247
var body = eventDoc.body;
250
if (event.touches !== undefined) {
251
var touch = event.touches[0];
253
x: touch[strPage + strX],
254
y: touch[strPage + strY]
259
if (!event[strPage + strX] && event[strClient + strX] && event[strClient + strX] != null) {
262
x: event[strClient + strX] +
263
(doc && doc.scrollLeft || body && body.scrollLeft || 0) -
264
(doc && doc.clientLeft || body && body.clientLeft || 0),
265
y: event[strClient + strY] +
266
(doc && doc.scrollTop || body && body.scrollTop || 0) -
267
(doc && doc.clientTop || body && body.clientTop || 0)
271
x: event[strPage + strX],
272
y: event[strPage + strY]
281
mBtn: function (event) {
282
var button = event.button;
283
if (!event.which && button !== undefined)
284
return (button & 1 ? 1 : (button & 2 ? 3 : (button & 4 ? 2 : 0)));
295
inA: function (item, arr) {
296
for (var i = 0; i < arr[LEXICON.l]; i++)
311
isA: function (arr) {
312
var def = Array.isArray;
313
return def ? def(arr) : this.type(arr) == TYPES.a;
321
type: function (obj) {
322
if (obj === undefined)
326
return Object[LEXICON.p].toString.call(obj).replace(/^\[object (.+)\]$/, '$1').toLowerCase();
348
var JQUERY = framework;
349
var EASING = framework.easing;
350
var FRAMEWORK = framework;
351
var INSTANCES = (function () {
353
var _instancePropertyString = '__overlayScrollbars__';
365
return function (target, instance) {
366
var argLen = arguments[LEXICON.l];
374
target[_instancePropertyString] = instance;
375
_targets.push(target);
378
var index = COMPATIBILITY.inA(target, _targets);
382
delete target[_instancePropertyString];
383
_targets.splice(index, 1);
387
return _targets[index][_instancePropertyString];
394
var PLUGIN = (function () {
397
var _pluginsAutoUpdateLoop;
398
var _pluginsExtensions = [];
399
var _pluginsOptions = (function () {
400
var type = COMPATIBILITY.type;
401
var possibleTemplateTypes = [
410
var restrictedStringsSplit = ' ';
411
var restrictedStringsPossibilitiesSplit = ':';
412
var classNameAllowedValues = [TYPES.z, TYPES.s];
413
var numberAllowedValues = TYPES.n;
414
var booleanNullAllowedValues = [TYPES.z, TYPES.b];
415
var booleanTrueTemplate = [true, TYPES.b];
416
var booleanFalseTemplate = [false, TYPES.b];
417
var callbackTemplate = [null, [TYPES.z, TYPES.f]];
418
var updateOnLoadTemplate = [['img'], [TYPES.s, TYPES.a, TYPES.z]];
419
var inheritedAttrsTemplate = [['style', 'class'], [TYPES.s, TYPES.a, TYPES.z]];
420
var resizeAllowedValues = 'n:none b:both h:horizontal v:vertical';
421
var overflowBehaviorAllowedValues = 'v-h:visible-hidden v-s:visible-scroll s:scroll h:hidden';
422
var scrollbarsVisibilityAllowedValues = 'v:visible h:hidden a:auto';
423
var scrollbarsAutoHideAllowedValues = 'n:never s:scroll l:leave m:move';
424
var optionsDefaultsAndTemplate = {
425
className: ['os-theme-dark', classNameAllowedValues],
426
resize: ['none', resizeAllowedValues],
427
sizeAutoCapable: booleanTrueTemplate,
428
clipAlways: booleanTrueTemplate,
429
normalizeRTL: booleanTrueTemplate,
430
paddingAbsolute: booleanFalseTemplate,
431
autoUpdate: [null, booleanNullAllowedValues],
432
autoUpdateInterval: [33, numberAllowedValues],
433
updateOnLoad: updateOnLoadTemplate,
434
nativeScrollbarsOverlaid: {
435
showNativeScrollbars: booleanFalseTemplate,
436
initialize: booleanTrueTemplate
439
x: ['scroll', overflowBehaviorAllowedValues],
440
y: ['scroll', overflowBehaviorAllowedValues]
443
visibility: ['auto', scrollbarsVisibilityAllowedValues],
444
autoHide: ['never', scrollbarsAutoHideAllowedValues],
445
autoHideDelay: [800, numberAllowedValues],
446
dragScrolling: booleanTrueTemplate,
447
clickScrolling: booleanFalseTemplate,
448
touchSupport: booleanTrueTemplate,
449
snapHandle: booleanFalseTemplate
452
dynWidth: booleanFalseTemplate,
453
dynHeight: booleanFalseTemplate,
454
inheritedAttrs: inheritedAttrsTemplate
457
onInitialized: callbackTemplate,
458
onInitializationWithdrawn: callbackTemplate,
459
onDestroyed: callbackTemplate,
460
onScrollStart: callbackTemplate,
461
onScroll: callbackTemplate,
462
onScrollStop: callbackTemplate,
463
onOverflowChanged: callbackTemplate,
464
onOverflowAmountChanged: callbackTemplate,
465
onDirectionChanged: callbackTemplate,
466
onContentSizeChanged: callbackTemplate,
467
onHostSizeChanged: callbackTemplate,
468
onUpdated: callbackTemplate
471
var convert = function (template) {
472
var recursive = function (obj) {
477
if (!obj[LEXICON.hOP](key))
481
if (valType == TYPES.a)
482
obj[key] = val[template ? 1 : 0];
483
else if (valType == TYPES.o)
484
obj[key] = recursive(val);
488
return recursive(FRAMEWORK.extend(true, {}, optionsDefaultsAndTemplate));
492
_defaults: convert(),
494
_template: convert(true),
504
_validate: function (obj, template, writeErrors, diffObj) {
505
var validatedOptions = {};
506
var validatedOptionsPrepared = {};
507
var objectCopy = FRAMEWORK.extend(true, {}, obj);
508
var inArray = FRAMEWORK.inArray;
509
var isEmptyObj = FRAMEWORK.isEmptyObject;
510
var checkObjectProps = function (data, template, diffData, validatedOptions, validatedOptionsPrepared, prevPropName) {
511
for (var prop in template) {
512
if (template[LEXICON.hOP](prop) && data[LEXICON.hOP](prop)) {
515
var templateValue = template[prop];
516
var templateValueType = type(templateValue);
517
var templateIsComplex = templateValueType == TYPES.o;
518
var templateTypes = !COMPATIBILITY.isA(templateValue) ? [templateValue] : templateValue;
519
var dataDiffValue = diffData[prop];
520
var dataValue = data[prop];
521
var dataValueType = type(dataValue);
522
var propPrefix = prevPropName ? prevPropName + '.' : '';
523
var error = "The option \"" + propPrefix + prop + "\" wasn't set, because";
524
var errorPossibleTypes = [];
525
var errorRestrictedStrings = [];
526
var restrictedStringValuesSplit;
527
var restrictedStringValuesPossibilitiesSplit;
528
var isRestrictedValue;
535
dataDiffValue = dataDiffValue === undefined ? {} : dataDiffValue;
538
if (templateIsComplex && dataValueType == TYPES.o) {
539
validatedOptions[prop] = {};
540
validatedOptionsPrepared[prop] = {};
541
checkObjectProps(dataValue, templateValue, dataDiffValue, validatedOptions[prop], validatedOptionsPrepared[prop], propPrefix + prop);
542
FRAMEWORK.each([data, validatedOptions, validatedOptionsPrepared], function (index, value) {
543
if (isEmptyObj(value[prop])) {
548
else if (!templateIsComplex) {
549
for (i = 0; i < templateTypes[LEXICON.l]; i++) {
550
currType = templateTypes[i];
551
templateValueType = type(currType);
553
isRestrictedValue = templateValueType == TYPES.s && inArray(currType, possibleTemplateTypes) === -1;
554
if (isRestrictedValue) {
555
errorPossibleTypes.push(TYPES.s);
558
restrictedStringValuesSplit = currType.split(restrictedStringsSplit);
559
errorRestrictedStrings = errorRestrictedStrings.concat(restrictedStringValuesSplit);
560
for (v = 0; v < restrictedStringValuesSplit[LEXICON.l]; v++) {
562
restrictedStringValuesPossibilitiesSplit = restrictedStringValuesSplit[v].split(restrictedStringsPossibilitiesSplit);
563
mainPossibility = restrictedStringValuesPossibilitiesSplit[0];
564
for (j = 0; j < restrictedStringValuesPossibilitiesSplit[LEXICON.l]; j++) {
566
if (dataValue === restrictedStringValuesPossibilitiesSplit[j]) {
576
errorPossibleTypes.push(currType);
578
if (dataValueType === currType) {
586
isDiff = dataValue !== dataDiffValue;
589
validatedOptions[prop] = dataValue;
591
if (isRestrictedValue ? inArray(dataDiffValue, restrictedStringValuesPossibilitiesSplit) < 0 : isDiff)
592
validatedOptionsPrepared[prop] = isRestrictedValue ? mainPossibility : dataValue;
594
else if (writeErrors) {
595
console.warn(error + " it doesn't accept the type [ " + dataValueType.toUpperCase() + " ] with the value of \"" + dataValue + "\".\r\n" +
596
"Accepted types are: [ " + errorPossibleTypes.join(', ').toUpperCase() + " ]." +
597
(errorRestrictedStrings[length] > 0 ? "\r\nValid strings are: [ " + errorRestrictedStrings.join(', ').split(restrictedStringsPossibilitiesSplit).join(', ') + " ]." : ''));
604
checkObjectProps(objectCopy, template, diffObj || {}, validatedOptions, validatedOptionsPrepared);
614
if (!isEmptyObj(objectCopy) && writeErrors)
615
console.warn('The following options are discarded due to invalidity:\r\n' + window.JSON.stringify(objectCopy, null, 2));
618
_default: validatedOptions,
619
_prepared: validatedOptionsPrepared
628
function initOverlayScrollbarsStatics() {
629
if (!_pluginsGlobals)
630
_pluginsGlobals = new OverlayScrollbarsGlobals(_pluginsOptions._defaults);
631
if (!_pluginsAutoUpdateLoop)
632
_pluginsAutoUpdateLoop = new OverlayScrollbarsAutoUpdateLoop(_pluginsGlobals);
640
function OverlayScrollbarsGlobals(defaultOptions) {
642
var strOverflow = 'overflow';
643
var strHidden = 'hidden';
644
var strScroll = 'scroll';
645
var bodyElement = FRAMEWORK('body');
646
var scrollbarDummyElement = FRAMEWORK('<div id="os-dummy-scrollbar-size"><div></div></div>');
647
var scrollbarDummyElement0 = scrollbarDummyElement[0];
648
var dummyContainerChild = FRAMEWORK(scrollbarDummyElement.children('div').eq(0));
650
bodyElement.append(scrollbarDummyElement);
651
scrollbarDummyElement.hide().show();
653
var nativeScrollbarSize = calcNativeScrollbarSize(scrollbarDummyElement0);
654
var nativeScrollbarIsOverlaid = {
655
x: nativeScrollbarSize.x === 0,
656
y: nativeScrollbarSize.y === 0
658
var msie = (function () {
659
var ua = window.navigator.userAgent;
660
var strIndexOf = 'indexOf';
661
var strSubString = 'substring';
662
var msie = ua[strIndexOf]('MSIE ');
663
var trident = ua[strIndexOf]('Trident/');
664
var edge = ua[strIndexOf]('Edge/');
665
var rv = ua[strIndexOf]('rv:');
667
var parseIntFunc = parseInt;
671
result = parseIntFunc(ua[strSubString](msie + 5, ua[strIndexOf]('.', msie)), 10);
674
else if (trident > 0)
675
result = parseIntFunc(ua[strSubString](rv + 3, ua[strIndexOf]('.', rv)), 10);
679
result = parseIntFunc(ua[strSubString](edge + 5, ua[strIndexOf]('.', edge)), 10);
685
FRAMEWORK.extend(_base, {
686
defaultOptions: defaultOptions,
688
autoUpdateLoop: false,
689
autoUpdateRecommended: !COMPATIBILITY.mO(),
690
nativeScrollbarSize: nativeScrollbarSize,
691
nativeScrollbarIsOverlaid: nativeScrollbarIsOverlaid,
692
nativeScrollbarStyling: (function () {
694
scrollbarDummyElement.addClass('os-viewport-native-scrollbars-invisible');
696
result = (scrollbarDummyElement.css('scrollbar-width') === 'none' && (msie > 9 || !msie)) || window.getComputedStyle(scrollbarDummyElement0, '::-webkit-scrollbar').getPropertyValue('display') === 'none';
706
overlayScrollbarDummySize: { x: 30, y: 30 },
707
cssCalc: VENDORS._cssPropertyValue('width', 'calc', '(1px)') || null,
708
restrictedMeasuring: (function () {
711
scrollbarDummyElement.css(strOverflow, strHidden);
713
w: scrollbarDummyElement0[LEXICON.sW],
714
h: scrollbarDummyElement0[LEXICON.sH]
716
scrollbarDummyElement.css(strOverflow, 'visible');
718
w: scrollbarDummyElement0[LEXICON.sW],
719
h: scrollbarDummyElement0[LEXICON.sH]
721
return (scrollSize.w - scrollSize2.w) !== 0 || (scrollSize.h - scrollSize2.h) !== 0;
723
rtlScrollBehavior: (function () {
724
scrollbarDummyElement.css({ 'overflow-y': strHidden, 'overflow-x': strScroll, 'direction': 'rtl' }).scrollLeft(0);
725
var dummyContainerOffset = scrollbarDummyElement.offset();
726
var dummyContainerChildOffset = dummyContainerChild.offset();
728
scrollbarDummyElement.scrollLeft(-999);
729
var dummyContainerChildOffsetAfterScroll = dummyContainerChild.offset();
735
i: dummyContainerOffset.left === dummyContainerChildOffset.left,
740
n: dummyContainerChildOffset.left !== dummyContainerChildOffsetAfterScroll.left
743
supportTransform: !!VENDORS._cssProperty('transform'),
744
supportTransition: !!VENDORS._cssProperty('transition'),
745
supportPassiveEvents: (function () {
746
var supportsPassive = false;
748
window.addEventListener('test', null, Object.defineProperty({}, 'passive', {
750
supportsPassive = true;
754
return supportsPassive;
756
supportResizeObserver: !!COMPATIBILITY.rO(),
757
supportMutationObserver: !!COMPATIBILITY.mO()
760
scrollbarDummyElement.removeAttr(LEXICON.s).remove();
764
if (nativeScrollbarIsOverlaid.x && nativeScrollbarIsOverlaid.y)
768
var windowWidth = COMPATIBILITY.wW();
769
var windowHeight = COMPATIBILITY.wH();
770
var windowDpr = getWindowDPR();
771
var onResize = function () {
772
if (INSTANCES().length > 0) {
773
var newW = COMPATIBILITY.wW();
774
var newH = COMPATIBILITY.wH();
775
var deltaW = newW - windowWidth;
776
var deltaH = newH - windowHeight;
778
if (deltaW === 0 && deltaH === 0)
781
var deltaWRatio = MATH.round(newW / (windowWidth / 100.0));
782
var deltaHRatio = MATH.round(newH / (windowHeight / 100.0));
783
var absDeltaW = abs(deltaW);
784
var absDeltaH = abs(deltaH);
785
var absDeltaWRatio = abs(deltaWRatio);
786
var absDeltaHRatio = abs(deltaHRatio);
787
var newDPR = getWindowDPR();
789
var deltaIsBigger = absDeltaW > 2 && absDeltaH > 2;
790
var difference = !differenceIsBiggerThanOne(absDeltaWRatio, absDeltaHRatio);
791
var dprChanged = newDPR !== windowDpr && windowDpr > 0;
792
var isZoom = deltaIsBigger && difference && dprChanged;
793
var oldScrollbarSize = _base.nativeScrollbarSize;
794
var newScrollbarSize;
797
bodyElement.append(scrollbarDummyElement);
798
newScrollbarSize = _base.nativeScrollbarSize = calcNativeScrollbarSize(scrollbarDummyElement[0]);
799
scrollbarDummyElement.remove();
800
if (oldScrollbarSize.x !== newScrollbarSize.x || oldScrollbarSize.y !== newScrollbarSize.y) {
801
FRAMEWORK.each(INSTANCES(), function () {
803
INSTANCES(this).update('zoom');
814
function differenceIsBiggerThanOne(valOne, valTwo) {
815
var absValOne = abs(valOne);
816
var absValTwo = abs(valTwo);
817
return !(absValOne === absValTwo || absValOne + 1 === absValTwo || absValOne - 1 === absValTwo);
820
function getWindowDPR() {
821
var dDPI = window.screen.deviceXDPI || 0;
822
var sDPI = window.screen.logicalXDPI || 1;
823
return window.devicePixelRatio || (dDPI / sDPI);
826
FRAMEWORK(window).on('resize', onResize);
829
function calcNativeScrollbarSize(measureElement) {
831
x: measureElement[LEXICON.oH] - measureElement[LEXICON.cH],
832
y: measureElement[LEXICON.oW] - measureElement[LEXICON.cW]
841
function OverlayScrollbarsAutoUpdateLoop(globals) {
843
var _inArray = FRAMEWORK.inArray;
844
var _getNow = COMPATIBILITY.now;
845
var _strAutoUpdate = 'autoUpdate';
846
var _strAutoUpdateInterval = _strAutoUpdate + 'Interval';
847
var _strLength = LEXICON.l;
848
var _loopingInstances = [];
849
var _loopingInstancesIntervalCache = [];
850
var _loopIsActive = false;
851
var _loopIntervalDefault = 33;
852
var _loopInterval = _loopIntervalDefault;
853
var _loopTimeOld = _getNow();
860
var loop = function () {
861
if (_loopingInstances[_strLength] > 0 && _loopIsActive) {
862
_loopID = COMPATIBILITY.rAF()(function () {
865
var timeNew = _getNow();
866
var timeDelta = timeNew - _loopTimeOld;
870
var instanceAutoUpdateAllowed;
871
var instanceAutoUpdateInterval;
874
if (timeDelta > _loopInterval) {
875
_loopTimeOld = timeNew - (timeDelta % _loopInterval);
876
lowestInterval = _loopIntervalDefault;
877
for (var i = 0; i < _loopingInstances[_strLength]; i++) {
878
instance = _loopingInstances[i];
879
if (instance !== undefined) {
880
instanceOptions = instance.options();
881
instanceAutoUpdateAllowed = instanceOptions[_strAutoUpdate];
882
instanceAutoUpdateInterval = MATH.max(1, instanceOptions[_strAutoUpdateInterval]);
885
if ((instanceAutoUpdateAllowed === true || instanceAutoUpdateAllowed === null) && (now - _loopingInstancesIntervalCache[i]) > instanceAutoUpdateInterval) {
886
instance.update('auto');
887
_loopingInstancesIntervalCache[i] = new Date(now += instanceAutoUpdateInterval);
890
lowestInterval = MATH.max(1, MATH.min(lowestInterval, instanceAutoUpdateInterval));
893
_loopInterval = lowestInterval;
896
_loopInterval = _loopIntervalDefault;
904
_base.add = function (instance) {
905
if (_inArray(instance, _loopingInstances) === -1) {
906
_loopingInstances.push(instance);
907
_loopingInstancesIntervalCache.push(_getNow());
908
if (_loopingInstances[_strLength] > 0 && !_loopIsActive) {
909
_loopIsActive = true;
910
globals.autoUpdateLoop = _loopIsActive;
920
_base.remove = function (instance) {
921
var index = _inArray(instance, _loopingInstances);
924
_loopingInstancesIntervalCache.splice(index, 1);
925
_loopingInstances.splice(index, 1);
928
if (_loopingInstances[_strLength] === 0 && _loopIsActive) {
929
_loopIsActive = false;
930
globals.autoUpdateLoop = _loopIsActive;
931
if (_loopID !== undefined) {
932
COMPATIBILITY.cAF()(_loopID);
950
function OverlayScrollbarsInstance(pluginTargetElement, options, extensions, globals, autoUpdateLoop) {
952
var type = COMPATIBILITY.type;
953
var inArray = FRAMEWORK.inArray;
954
var each = FRAMEWORK.each;
957
var _base = new _plugin();
958
var _frameworkProto = FRAMEWORK[LEXICON.p];
961
if (!isHTMLElement(pluginTargetElement))
965
if (INSTANCES(pluginTargetElement)) {
966
var inst = INSTANCES(pluginTargetElement);
967
inst.options(options);
972
var _nativeScrollbarIsOverlaid;
973
var _overlayScrollbarDummySize;
974
var _rtlScrollBehavior;
975
var _autoUpdateRecommended;
977
var _nativeScrollbarStyling;
979
var _nativeScrollbarSize;
980
var _supportTransition;
981
var _supportTransform;
982
var _supportPassiveEvents;
983
var _supportResizeObserver;
984
var _supportMutationObserver;
985
var _restrictedMeasuring;
997
var _sizeAutoObserverAdded;
1006
var _contentBorderSize = {};
1007
var _scrollHorizontalInfo = {};
1008
var _scrollVerticalInfo = {};
1009
var _viewportSize = {};
1010
var _nativeScrollbarMinSize = {};
1013
var _strMinusHidden = '-hidden';
1014
var _strMarginMinus = 'margin-';
1015
var _strPaddingMinus = 'padding-';
1016
var _strBorderMinus = 'border-';
1017
var _strTop = 'top';
1018
var _strRight = 'right';
1019
var _strBottom = 'bottom';
1020
var _strLeft = 'left';
1021
var _strMinMinus = 'min-';
1022
var _strMaxMinus = 'max-';
1023
var _strWidth = 'width';
1024
var _strHeight = 'height';
1025
var _strFloat = 'float';
1027
var _strAuto = 'auto';
1028
var _strSync = 'sync';
1029
var _strScroll = 'scroll';
1030
var _strHundredPercent = '100%';
1034
var _strSpace = ' ';
1035
var _strScrollbar = 'scrollbar';
1036
var _strMinusHorizontal = '-horizontal';
1037
var _strMinusVertical = '-vertical';
1038
var _strScrollLeft = _strScroll + 'Left';
1039
var _strScrollTop = _strScroll + 'Top';
1040
var _strMouseTouchDownEvent = 'mousedown touchstart';
1041
var _strMouseTouchUpEvent = 'mouseup touchend touchcancel';
1042
var _strMouseTouchMoveEvent = 'mousemove touchmove';
1043
var _strMouseEnter = 'mouseenter';
1044
var _strMouseLeave = 'mouseleave';
1045
var _strKeyDownEvent = 'keydown';
1046
var _strKeyUpEvent = 'keyup';
1047
var _strSelectStartEvent = 'selectstart';
1048
var _strTransitionEndEvent = 'transitionend webkitTransitionEnd oTransitionEnd';
1049
var _strResizeObserverProperty = '__overlayScrollbarsRO__';
1052
var _cassNamesPrefix = 'os-';
1053
var _classNameHTMLElement = _cassNamesPrefix + 'html';
1054
var _classNameHostElement = _cassNamesPrefix + 'host';
1055
var _classNameHostElementForeign = _classNameHostElement + '-foreign';
1056
var _classNameHostTextareaElement = _classNameHostElement + '-textarea';
1057
var _classNameHostScrollbarHorizontalHidden = _classNameHostElement + '-' + _strScrollbar + _strMinusHorizontal + _strMinusHidden;
1058
var _classNameHostScrollbarVerticalHidden = _classNameHostElement + '-' + _strScrollbar + _strMinusVertical + _strMinusHidden;
1059
var _classNameHostTransition = _classNameHostElement + '-transition';
1060
var _classNameHostRTL = _classNameHostElement + '-rtl';
1061
var _classNameHostResizeDisabled = _classNameHostElement + '-resize-disabled';
1062
var _classNameHostScrolling = _classNameHostElement + '-scrolling';
1063
var _classNameHostOverflow = _classNameHostElement + '-overflow';
1064
var _classNameHostOverflow = _classNameHostElement + '-overflow';
1065
var _classNameHostOverflowX = _classNameHostOverflow + '-x';
1066
var _classNameHostOverflowY = _classNameHostOverflow + '-y';
1067
var _classNameTextareaElement = _cassNamesPrefix + 'textarea';
1068
var _classNameTextareaCoverElement = _classNameTextareaElement + '-cover';
1069
var _classNamePaddingElement = _cassNamesPrefix + 'padding';
1070
var _classNameViewportElement = _cassNamesPrefix + 'viewport';
1071
var _classNameViewportNativeScrollbarsInvisible = _classNameViewportElement + '-native-scrollbars-invisible';
1072
var _classNameViewportNativeScrollbarsOverlaid = _classNameViewportElement + '-native-scrollbars-overlaid';
1073
var _classNameContentElement = _cassNamesPrefix + 'content';
1074
var _classNameContentArrangeElement = _cassNamesPrefix + 'content-arrange';
1075
var _classNameContentGlueElement = _cassNamesPrefix + 'content-glue';
1076
var _classNameSizeAutoObserverElement = _cassNamesPrefix + 'size-auto-observer';
1077
var _classNameResizeObserverElement = _cassNamesPrefix + 'resize-observer';
1078
var _classNameResizeObserverItemElement = _cassNamesPrefix + 'resize-observer-item';
1079
var _classNameResizeObserverItemFinalElement = _classNameResizeObserverItemElement + '-final';
1080
var _classNameTextInherit = _cassNamesPrefix + 'text-inherit';
1081
var _classNameScrollbar = _cassNamesPrefix + _strScrollbar;
1082
var _classNameScrollbarTrack = _classNameScrollbar + '-track';
1083
var _classNameScrollbarTrackOff = _classNameScrollbarTrack + '-off';
1084
var _classNameScrollbarHandle = _classNameScrollbar + '-handle';
1085
var _classNameScrollbarHandleOff = _classNameScrollbarHandle + '-off';
1086
var _classNameScrollbarUnusable = _classNameScrollbar + '-unusable';
1087
var _classNameScrollbarAutoHidden = _classNameScrollbar + '-' + _strAuto + _strMinusHidden;
1088
var _classNameScrollbarCorner = _classNameScrollbar + '-corner';
1089
var _classNameScrollbarCornerResize = _classNameScrollbarCorner + '-resize';
1090
var _classNameScrollbarCornerResizeB = _classNameScrollbarCornerResize + '-both';
1091
var _classNameScrollbarCornerResizeH = _classNameScrollbarCornerResize + _strMinusHorizontal;
1092
var _classNameScrollbarCornerResizeV = _classNameScrollbarCornerResize + _strMinusVertical;
1093
var _classNameScrollbarHorizontal = _classNameScrollbar + _strMinusHorizontal;
1094
var _classNameScrollbarVertical = _classNameScrollbar + _strMinusVertical;
1095
var _classNameDragging = _cassNamesPrefix + 'dragging';
1096
var _classNameThemeNone = _cassNamesPrefix + 'theme-none';
1097
var _classNamesDynamicDestroy = [
1098
_classNameViewportNativeScrollbarsInvisible,
1099
_classNameViewportNativeScrollbarsOverlaid,
1100
_classNameScrollbarTrackOff,
1101
_classNameScrollbarHandleOff,
1102
_classNameScrollbarUnusable,
1103
_classNameScrollbarAutoHidden,
1104
_classNameScrollbarCornerResize,
1105
_classNameScrollbarCornerResizeB,
1106
_classNameScrollbarCornerResizeH,
1107
_classNameScrollbarCornerResizeV,
1108
_classNameDragging].join(_strSpace);
1111
var _callbacksInitQeueue = [];
1114
var _viewportAttrsFromTarget = [LEXICON.ti];
1117
var _defaultOptions;
1118
var _currentOptions;
1119
var _currentPreparedOptions;
1122
var _extensions = {};
1123
var _extensionsPrivateMethods = 'added removed on contract';
1126
var _lastUpdateTime;
1127
var _swallowedUpdateHints = {};
1128
var _swallowedUpdateTimeout;
1129
var _swallowUpdateLag = 42;
1130
var _updateOnLoadEventName = 'load';
1131
var _updateOnLoadElms = [];
1135
var _documentElement;
1140
var _sizeAutoObserverElement;
1141
var _sizeObserverElement;
1142
var _paddingElement;
1143
var _viewportElement;
1144
var _contentElement;
1145
var _contentArrangeElement;
1146
var _contentGlueElement;
1147
var _textareaCoverElement;
1148
var _scrollbarCornerElement;
1149
var _scrollbarHorizontalElement;
1150
var _scrollbarHorizontalTrackElement;
1151
var _scrollbarHorizontalHandleElement;
1152
var _scrollbarVerticalElement;
1153
var _scrollbarVerticalTrackElement;
1154
var _scrollbarVerticalHandleElement;
1155
var _windowElementNative;
1156
var _documentElementNative;
1157
var _targetElementNative;
1158
var _hostElementNative;
1159
var _sizeAutoObserverElementNative;
1160
var _sizeObserverElementNative;
1161
var _paddingElementNative;
1162
var _viewportElementNative;
1163
var _contentElementNative;
1167
var _contentScrollSizeCache;
1168
var _arrangeContentSizeCache;
1169
var _hasOverflowCache;
1170
var _hideOverflowCache;
1171
var _widthAutoCache;
1172
var _heightAutoCache;
1173
var _cssBoxSizingCache;
1174
var _cssPaddingCache;
1175
var _cssBorderCache;
1176
var _cssMarginCache;
1177
var _cssDirectionCache;
1178
var _cssDirectionDetectedCache;
1179
var _paddingAbsoluteCache;
1180
var _clipAlwaysCache;
1181
var _contentGlueSizeCache;
1182
var _overflowBehaviorCache;
1183
var _overflowAmountCache;
1184
var _ignoreOverlayScrollbarHidingCache;
1185
var _autoUpdateCache;
1186
var _sizeAutoCapableCache;
1187
var _contentElementScrollSizeChangeDetectedCache;
1188
var _hostElementSizeChangeDetectedCache;
1189
var _scrollbarsVisibilityCache;
1190
var _scrollbarsAutoHideCache;
1191
var _scrollbarsClickScrollingCache;
1192
var _scrollbarsDragScrollingCache;
1194
var _normalizeRTLCache;
1195
var _classNameCache;
1197
var _textareaAutoWrappingCache;
1198
var _textareaInfoCache;
1199
var _textareaSizeCache;
1200
var _textareaDynHeightCache;
1201
var _textareaDynWidthCache;
1202
var _bodyMinSizeCache;
1203
var _updateAutoCache = {};
1206
var _mutationObserverHost;
1207
var _mutationObserverContent;
1208
var _mutationObserverHostCallback;
1209
var _mutationObserverContentCallback;
1210
var _mutationObserversConnected;
1211
var _mutationObserverAttrsTextarea = ['wrap', 'cols', 'rows'];
1212
var _mutationObserverAttrsHost = [LEXICON.i, LEXICON.c, LEXICON.s, 'open'].concat(_viewportAttrsFromTarget);
1215
var _destroyEvents = [];
1218
var _textareaHasFocus;
1221
var _scrollbarsAutoHideTimeoutId;
1222
var _scrollbarsAutoHideMoveTimeoutId;
1223
var _scrollbarsAutoHideDelay;
1224
var _scrollbarsAutoHideNever;
1225
var _scrollbarsAutoHideScroll;
1226
var _scrollbarsAutoHideMove;
1227
var _scrollbarsAutoHideLeave;
1228
var _scrollbarsHandleHovered;
1229
var _scrollbarsHandlesDefineScrollPos;
1234
var _resizeHorizontal;
1235
var _resizeVertical;
1248
function setupResponsiveEventListener(element, eventNames, listener, remove, passiveOrOptions) {
1249
var collected = COMPATIBILITY.isA(eventNames) && COMPATIBILITY.isA(listener);
1250
var method = remove ? 'removeEventListener' : 'addEventListener';
1251
var onOff = remove ? 'off' : 'on';
1252
var events = collected ? false : eventNames.split(_strSpace)
1255
var passiveOrOptionsIsObj = FRAMEWORK.isPlainObject(passiveOrOptions);
1256
var passive = (_supportPassiveEvents && (passiveOrOptionsIsObj ? (passiveOrOptions._passive) : passiveOrOptions)) || false;
1257
var capture = passiveOrOptionsIsObj && (passiveOrOptions._capture || false);
1258
var nativeParam = _supportPassiveEvents ? {
1264
for (; i < eventNames[LEXICON.l]; i++)
1265
setupResponsiveEventListener(element, eventNames[i], listener[i], remove, passiveOrOptions);
1268
for (; i < events[LEXICON.l]; i++) {
1269
if(_supportPassiveEvents) {
1270
element[0][method](events[i], listener, nativeParam);
1273
element[onOff](events[i], listener);
1280
function addDestroyEventListener(element, eventNames, listener, passive) {
1281
setupResponsiveEventListener(element, eventNames, listener, false, passive);
1282
_destroyEvents.push(COMPATIBILITY.bind(setupResponsiveEventListener, 0, element, eventNames, listener, true, passive));
1292
function setupResizeObserver(targetElement, onElementResizedCallback) {
1293
if (targetElement) {
1294
var resizeObserver = COMPATIBILITY.rO();
1295
var strAnimationStartEvent = 'animationstart mozAnimationStart webkitAnimationStart MSAnimationStart';
1296
var strChildNodes = 'childNodes';
1297
var constScroll = 3333333;
1298
var callback = function () {
1299
targetElement[_strScrollTop](constScroll)[_strScrollLeft](_isRTL ? _rtlScrollBehavior.n ? -constScroll : _rtlScrollBehavior.i ? 0 : constScroll : constScroll);
1300
onElementResizedCallback();
1303
if (onElementResizedCallback) {
1304
if (_supportResizeObserver) {
1305
var element = targetElement.addClass('observed').append(generateDiv(_classNameResizeObserverElement)).contents()[0];
1306
var observer = element[_strResizeObserverProperty] = new resizeObserver(callback);
1307
observer.observe(element);
1310
if (_msieVersion > 9 || !_autoUpdateRecommended) {
1311
targetElement.prepend(
1312
generateDiv(_classNameResizeObserverElement,
1313
generateDiv({ c: _classNameResizeObserverItemElement, dir: 'ltr' },
1314
generateDiv(_classNameResizeObserverItemElement,
1315
generateDiv(_classNameResizeObserverItemFinalElement)
1317
generateDiv(_classNameResizeObserverItemElement,
1318
generateDiv({ c: _classNameResizeObserverItemFinalElement, style: 'width: 200%; height: 200%' })
1324
var observerElement = targetElement[0][strChildNodes][0][strChildNodes][0];
1325
var shrinkElement = FRAMEWORK(observerElement[strChildNodes][1]);
1326
var expandElement = FRAMEWORK(observerElement[strChildNodes][0]);
1327
var expandElementChild = FRAMEWORK(expandElement[0][strChildNodes][0]);
1328
var widthCache = observerElement[LEXICON.oW];
1329
var heightCache = observerElement[LEXICON.oH];
1335
var nativeScrollbarSize = globals.nativeScrollbarSize;
1336
var reset = function () {
1349
expandElement[_strScrollLeft](constScroll)[_strScrollTop](constScroll);
1350
shrinkElement[_strScrollLeft](constScroll)[_strScrollTop](constScroll);
1352
var onResized = function () {
1357
widthCache = currWidth;
1358
heightCache = currHeight;
1361
var onScroll = function (event) {
1362
currWidth = observerElement[LEXICON.oW];
1363
currHeight = observerElement[LEXICON.oH];
1364
isDirty = currWidth != widthCache || currHeight != heightCache;
1366
if (event && isDirty && !rAFId) {
1367
COMPATIBILITY.cAF()(rAFId);
1368
rAFId = COMPATIBILITY.rAF()(onResized);
1375
COMPATIBILITY.prvD(event);
1376
COMPATIBILITY.stpP(event);
1380
var expandChildCSS = {};
1381
var observerElementCSS = {};
1383
setTopRightBottomLeft(observerElementCSS, _strEmpty, [
1384
-((nativeScrollbarSize.y + 1) * factor),
1385
nativeScrollbarSize.x * -factor,
1386
nativeScrollbarSize.y * -factor,
1387
-((nativeScrollbarSize.x + 1) * factor)
1390
FRAMEWORK(observerElement).css(observerElementCSS);
1391
expandElement.on(_strScroll, onScroll);
1392
shrinkElement.on(_strScroll, onScroll);
1393
targetElement.on(strAnimationStartEvent, function () {
1397
expandChildCSS[_strWidth] = constScroll;
1398
expandChildCSS[_strHeight] = constScroll;
1399
expandElementChild.css(expandChildCSS);
1404
var attachEvent = _documentElementNative.attachEvent;
1405
var isIE = _msieVersion !== undefined;
1407
targetElement.prepend(generateDiv(_classNameResizeObserverElement));
1408
findFirst(targetElement, _strDot + _classNameResizeObserverElement)[0].attachEvent('onresize', callback);
1411
var obj = _documentElementNative.createElement(TYPES.o);
1412
obj.setAttribute(LEXICON.ti, '-1');
1413
obj.setAttribute(LEXICON.c, _classNameResizeObserverElement);
1414
obj.onload = function () {
1415
var wnd = this.contentDocument.defaultView;
1416
wnd.addEventListener('resize', callback);
1417
wnd.document.documentElement.style.display = 'none';
1419
obj.type = 'text/html';
1421
targetElement.prepend(obj);
1422
obj.data = 'about:blank';
1424
targetElement.prepend(obj);
1425
targetElement.on(strAnimationStartEvent, callback);
1430
if (targetElement[0] === _sizeObserverElementNative) {
1431
var directionChanged = function () {
1432
var dir = _hostElement.css('direction');
1434
var scrollLeftValue = 0;
1436
if (dir !== _cssDirectionDetectedCache) {
1437
if (dir === 'ltr') {
1439
css[_strRight] = _strAuto;
1440
scrollLeftValue = constScroll;
1443
css[_strLeft] = _strAuto;
1445
scrollLeftValue = _rtlScrollBehavior.n ? -constScroll : _rtlScrollBehavior.i ? 0 : constScroll;
1448
_sizeObserverElement.children().eq(0).css(css);
1449
_sizeObserverElement[_strScrollLeft](scrollLeftValue)[_strScrollTop](constScroll);
1450
_cssDirectionDetectedCache = dir;
1456
addDestroyEventListener(targetElement, _strScroll, function (event) {
1457
if (directionChanged())
1459
COMPATIBILITY.prvD(event);
1460
COMPATIBILITY.stpP(event);
1467
if (_supportResizeObserver) {
1468
var element = targetElement.contents()[0];
1469
var resizeObserverObj = element[_strResizeObserverProperty];
1470
if (resizeObserverObj) {
1471
resizeObserverObj.disconnect();
1472
delete element[_strResizeObserverProperty];
1476
remove(targetElement.children(_strDot + _classNameResizeObserverElement).eq(0));
1526
function createMutationObservers() {
1527
if (_supportMutationObserver) {
1528
var mutationObserverContentLag = 11;
1529
var mutationObserver = COMPATIBILITY.mO();
1530
var contentLastUpdate = COMPATIBILITY.now();
1532
var mutationAttrName;
1533
var mutationIsClass;
1536
var hostClassNameRegex;
1542
_mutationObserverHostCallback = function (mutations) {
1544
var doUpdate = false;
1545
var doUpdateForce = false;
1547
var mutatedAttrs = [];
1549
if (_initialized && !_sleeping) {
1550
each(mutations, function () {
1552
mutationTarget = mutation.target;
1553
mutationAttrName = mutation.attributeName;
1554
mutationIsClass = mutationAttrName === LEXICON.c;
1555
oldMutationVal = mutation.oldValue;
1556
newClassVal = mutationTarget.className;
1558
if (_domExists && mutationIsClass && !doUpdateForce) {
1560
if (oldMutationVal.indexOf(_classNameHostElementForeign) > -1 && newClassVal.indexOf(_classNameHostElementForeign) < 0) {
1561
hostClassNameRegex = createHostClassNameRegExp(true);
1562
_hostElementNative.className = newClassVal.split(_strSpace).concat(oldMutationVal.split(_strSpace).filter(function (name) {
1563
return name.match(hostClassNameRegex);
1564
})).join(_strSpace);
1565
doUpdate = doUpdateForce = true;
1570
doUpdate = mutationIsClass
1571
? hostClassNamesChanged(oldMutationVal, newClassVal)
1572
: mutationAttrName === LEXICON.s
1573
? oldMutationVal !== mutationTarget[LEXICON.s].cssText
1577
mutatedAttrs.push(mutationAttrName);
1580
updateViewportAttrsFromTarget(mutatedAttrs);
1583
_base.update(doUpdateForce || _strAuto);
1587
_mutationObserverContentCallback = function (mutations) {
1588
var doUpdate = false;
1591
if (_initialized && !_sleeping) {
1592
each(mutations, function () {
1594
doUpdate = isUnknownMutation(mutation);
1599
now = COMPATIBILITY.now();
1600
sizeAuto = (_heightAutoCache || _widthAutoCache);
1601
action = function () {
1603
contentLastUpdate = now;
1612
_base.update(_strAuto);
1615
clearTimeout(contentTimeout);
1616
if (mutationObserverContentLag <= 0 || now - contentLastUpdate > mutationObserverContentLag || !sizeAuto)
1619
contentTimeout = setTimeout(action, mutationObserverContentLag);
1625
_mutationObserverHost = new mutationObserver(_mutationObserverHostCallback);
1626
_mutationObserverContent = new mutationObserver(_mutationObserverContentCallback);
1633
function connectMutationObservers() {
1634
if (_supportMutationObserver && !_mutationObserversConnected) {
1635
_mutationObserverHost.observe(_hostElementNative, {
1637
attributeOldValue: true,
1638
attributeFilter: _mutationObserverAttrsHost
1641
_mutationObserverContent.observe(_isTextarea ? _targetElementNative : _contentElementNative, {
1643
attributeOldValue: true,
1644
subtree: !_isTextarea,
1645
childList: !_isTextarea,
1646
characterData: !_isTextarea,
1647
attributeFilter: _isTextarea ? _mutationObserverAttrsTextarea : _mutationObserverAttrsHost
1650
_mutationObserversConnected = true;
1657
function disconnectMutationObservers() {
1658
if (_supportMutationObserver && _mutationObserversConnected) {
1659
_mutationObserverHost.disconnect();
1660
_mutationObserverContent.disconnect();
1662
_mutationObserversConnected = false;
1674
function hostOnResized() {
1678
w: _sizeObserverElementNative[LEXICON.sW],
1679
h: _sizeObserverElementNative[LEXICON.sH]
1682
changed = checkCache(hostSize, _hostElementSizeChangeDetectedCache);
1683
_hostElementSizeChangeDetectedCache = hostSize;
1685
update({ _hostSizeChanged: true });
1692
function hostOnMouseEnter() {
1693
if (_scrollbarsAutoHideLeave)
1694
refreshScrollbarsAutoHide(true);
1700
function hostOnMouseLeave() {
1701
if (_scrollbarsAutoHideLeave && !_bodyElement.hasClass(_classNameDragging))
1702
refreshScrollbarsAutoHide(false);
1708
function hostOnMouseMove() {
1709
if (_scrollbarsAutoHideMove) {
1710
refreshScrollbarsAutoHide(true);
1711
clearTimeout(_scrollbarsAutoHideMoveTimeoutId);
1712
_scrollbarsAutoHideMoveTimeoutId = setTimeout(function () {
1713
if (_scrollbarsAutoHideMove && !_destroyed)
1714
refreshScrollbarsAutoHide(false);
1723
function documentOnSelectStart(event) {
1724
COMPATIBILITY.prvD(event);
1731
function updateOnLoadCallback(event) {
1732
var elm = FRAMEWORK(event.target);
1734
eachUpdateOnLoad(function (i, updateOnLoadSelector) {
1735
if (elm.is(updateOnLoadSelector)) {
1736
update({ _contentSizeChanged: true });
1745
function setupHostMouseTouchEvents(destroy) {
1747
setupHostMouseTouchEvents(true);
1749
setupResponsiveEventListener(_hostElement,
1750
_strMouseTouchMoveEvent.split(_strSpace)[0],
1752
(!_scrollbarsAutoHideMove || destroy), true);
1753
setupResponsiveEventListener(_hostElement,
1754
[_strMouseEnter, _strMouseLeave],
1755
[hostOnMouseEnter, hostOnMouseLeave],
1756
(!_scrollbarsAutoHideLeave || destroy), true);
1759
if (!_initialized && !destroy)
1760
_hostElement.one('mouseover', hostOnMouseEnter);
1770
function bodyMinSizeChanged() {
1771
var bodyMinSize = {};
1772
if (_isBody && _contentArrangeElement) {
1773
bodyMinSize.w = parseToZeroOrNumber(_contentArrangeElement.css(_strMinMinus + _strWidth));
1774
bodyMinSize.h = parseToZeroOrNumber(_contentArrangeElement.css(_strMinMinus + _strHeight));
1775
bodyMinSize.c = checkCache(bodyMinSize, _bodyMinSizeCache);
1776
bodyMinSize.f = true;
1778
_bodyMinSizeCache = bodyMinSize;
1779
return !!bodyMinSize.c;
1788
function hostClassNamesChanged(oldClassNames, newClassNames) {
1789
var currClasses = typeof newClassNames == TYPES.s ? newClassNames.split(_strSpace) : [];
1790
var oldClasses = typeof oldClassNames == TYPES.s ? oldClassNames.split(_strSpace) : [];
1791
var diff = getArrayDifferences(oldClasses, currClasses);
1794
var idx = inArray(_classNameThemeNone, diff);
1799
diff.splice(idx, 1);
1801
if (diff[LEXICON.l] > 0) {
1802
regex = createHostClassNameRegExp(true, true);
1803
for (i = 0; i < diff.length; i++) {
1804
if (!diff[i].match(regex)) {
1817
function isUnknownMutation(mutation) {
1818
var attributeName = mutation.attributeName;
1819
var mutationTarget = mutation.target;
1820
var mutationType = mutation.type;
1821
var strClosest = 'closest';
1823
if (mutationTarget === _contentElementNative)
1824
return attributeName === null;
1825
if (mutationType === 'attributes' && (attributeName === LEXICON.c || attributeName === LEXICON.s) && !_isTextarea) {
1827
if (attributeName === LEXICON.c && FRAMEWORK(mutationTarget).hasClass(_classNameHostElement))
1828
return hostClassNamesChanged(mutation.oldValue, mutationTarget.className);
1831
if (typeof mutationTarget[strClosest] != TYPES.f)
1833
if (mutationTarget[strClosest](_strDot + _classNameResizeObserverElement) !== null ||
1834
mutationTarget[strClosest](_strDot + _classNameScrollbar) !== null ||
1835
mutationTarget[strClosest](_strDot + _classNameScrollbarCorner) !== null)
1845
function updateAutoContentSizeChanged() {
1849
var contentMeasureElement = getContentMeasureElement();
1850
var textareaValueLength = _isTextarea && _widthAutoCache && !_textareaAutoWrappingCache ? _targetElement.val().length : 0;
1851
var setCSS = !_mutationObserversConnected && _widthAutoCache && !_isTextarea;
1856
var contentElementScrollSize;
1859
float = _contentElement.css(_strFloat);
1860
css[_strFloat] = _isRTL ? _strRight : _strLeft;
1861
css[_strWidth] = _strAuto;
1862
_contentElement.css(css);
1864
contentElementScrollSize = {
1865
w: contentMeasureElement[LEXICON.sW] + textareaValueLength,
1866
h: contentMeasureElement[LEXICON.sH] + textareaValueLength
1869
css[_strFloat] = float;
1870
css[_strWidth] = _strHundredPercent;
1871
_contentElement.css(css);
1874
bodyMinSizeC = bodyMinSizeChanged();
1875
changed = checkCache(contentElementScrollSize, _contentElementScrollSizeChangeDetectedCache);
1877
_contentElementScrollSizeChangeDetectedCache = contentElementScrollSize;
1879
return changed || bodyMinSizeC;
1886
function meaningfulAttrsChanged() {
1887
if (_sleeping || _mutationObserversConnected)
1893
var changedAttrs = [];
1896
_elem: _hostElement,
1897
_attrs: _mutationObserverAttrsHost.concat(':visible')
1900
_elem: _isTextarea ? _targetElement : undefined,
1901
_attrs: _mutationObserverAttrsTextarea
1905
each(checks, function (index, check) {
1908
each(check._attrs, function (index, attr) {
1909
curr = attr.charAt(0) === ':' ? elem.is(attr) : elem.attr(attr);
1910
cache = _updateAutoCache[attr];
1912
if (checkCache(curr, cache)) {
1913
changedAttrs.push(attr);
1916
_updateAutoCache[attr] = curr;
1921
updateViewportAttrsFromTarget(changedAttrs);
1923
return changedAttrs[LEXICON.l] > 0;
1931
function isSizeAffectingCSSProperty(propertyName) {
1934
var flexGrow = 'flex-grow';
1935
var flexShrink = 'flex-shrink';
1936
var flexBasis = 'flex-basis';
1937
var affectingPropsX = [
1939
_strMinMinus + _strWidth,
1940
_strMaxMinus + _strWidth,
1941
_strMarginMinus + _strLeft,
1942
_strMarginMinus + _strRight,
1951
var affectingPropsXContentBox = [
1952
_strPaddingMinus + _strLeft,
1953
_strPaddingMinus + _strRight,
1954
_strBorderMinus + _strLeft + _strWidth,
1955
_strBorderMinus + _strRight + _strWidth
1957
var affectingPropsY = [
1959
_strMinMinus + _strHeight,
1960
_strMaxMinus + _strHeight,
1961
_strMarginMinus + _strTop,
1962
_strMarginMinus + _strBottom,
1970
var affectingPropsYContentBox = [
1971
_strPaddingMinus + _strTop,
1972
_strPaddingMinus + _strBottom,
1973
_strBorderMinus + _strTop + _strWidth,
1974
_strBorderMinus + _strBottom + _strWidth
1978
var checkX = _overflowBehaviorCache.x === _strS || _overflowBehaviorCache.x === _strVS;
1979
var checkY = _overflowBehaviorCache.y === _strS || _overflowBehaviorCache.y === _strVS;
1980
var sizeIsAffected = false;
1981
var checkPropertyName = function (arr, name) {
1982
for (var i = 0; i < arr[LEXICON.l]; i++) {
1983
if (arr[i] === name)
1990
sizeIsAffected = checkPropertyName(affectingPropsY, propertyName);
1991
if (!sizeIsAffected && !_isBorderBox)
1992
sizeIsAffected = checkPropertyName(affectingPropsYContentBox, propertyName);
1994
if (checkX && !sizeIsAffected) {
1995
sizeIsAffected = checkPropertyName(affectingPropsX, propertyName);
1996
if (!sizeIsAffected && !_isBorderBox)
1997
sizeIsAffected = checkPropertyName(affectingPropsXContentBox, propertyName);
1999
return sizeIsAffected;
2010
function updateViewportAttrsFromTarget(attrs) {
2011
attrs = attrs || _viewportAttrsFromTarget;
2012
each(attrs, function (index, attr) {
2013
if (COMPATIBILITY.inA(attr, _viewportAttrsFromTarget) > -1) {
2014
var targetAttr = _targetElement.attr(attr);
2015
if (type(targetAttr) == TYPES.s) {
2016
_viewportElement.attr(attr, targetAttr);
2019
_viewportElement.removeAttr(attr);
2028
function textareaUpdate() {
2030
var wrapAttrOff = !_textareaAutoWrappingCache;
2031
var minWidth = _viewportSize.w;
2032
var minHeight = _viewportSize.h;
2034
var doMeasure = _widthAutoCache || wrapAttrOff;
2041
css[_strMinMinus + _strWidth] = _strEmpty;
2042
css[_strMinMinus + _strHeight] = _strEmpty;
2045
css[_strWidth] = _strAuto;
2046
_targetElement.css(css);
2049
origWidth = _targetElementNative[LEXICON.oW];
2050
width = doMeasure ? MATH.max(origWidth, _targetElementNative[LEXICON.sW] - 1) : 1;
2054
css[_strWidth] = _widthAutoCache ? _strAuto : _strHundredPercent;
2055
css[_strMinMinus + _strWidth] = _strHundredPercent;
2058
css[_strHeight] = _strAuto;
2059
_targetElement.css(css);
2062
origHeight = _targetElementNative[LEXICON.oH];
2063
height = MATH.max(origHeight, _targetElementNative[LEXICON.sH] - 1);
2066
css[_strWidth] = width;
2067
css[_strHeight] = height;
2068
_textareaCoverElement.css(css);
2071
css[_strMinMinus + _strWidth] = minWidth ;
2072
css[_strMinMinus + _strHeight] = minHeight ;
2073
_targetElement.css(css);
2076
_originalWidth: origWidth,
2077
_originalHeight: origHeight,
2078
_dynamicWidth: width,
2079
_dynamicHeight: height
2095
function update(updateHints) {
2096
clearTimeout(_swallowedUpdateTimeout);
2097
updateHints = updateHints || {};
2098
_swallowedUpdateHints._hostSizeChanged |= updateHints._hostSizeChanged;
2099
_swallowedUpdateHints._contentSizeChanged |= updateHints._contentSizeChanged;
2100
_swallowedUpdateHints._force |= updateHints._force;
2102
var now = COMPATIBILITY.now();
2103
var hostSizeChanged = !!_swallowedUpdateHints._hostSizeChanged;
2104
var contentSizeChanged = !!_swallowedUpdateHints._contentSizeChanged;
2105
var force = !!_swallowedUpdateHints._force;
2106
var changedOptions = updateHints._changedOptions;
2107
var swallow = _swallowUpdateLag > 0 && _initialized && !_destroyed && !force && !changedOptions && (now - _lastUpdateTime) < _swallowUpdateLag && (!_heightAutoCache && !_widthAutoCache);
2108
var displayIsHidden;
2111
_swallowedUpdateTimeout = setTimeout(update, _swallowUpdateLag);
2118
if (_destroyed || swallow || (_sleeping && !changedOptions) || (_initialized && !force && (displayIsHidden = _hostElement.is(':hidden'))) || _hostElement.css('display') === 'inline')
2121
_lastUpdateTime = now;
2122
_swallowedUpdateHints = {};
2125
if (_nativeScrollbarStyling && !(_nativeScrollbarIsOverlaid.x && _nativeScrollbarIsOverlaid.y)) {
2127
_nativeScrollbarSize.x = 0;
2128
_nativeScrollbarSize.y = 0;
2132
_nativeScrollbarSize = extendDeep({}, globals.nativeScrollbarSize);
2139
_nativeScrollbarMinSize = {
2140
x: (_nativeScrollbarSize.x + (_nativeScrollbarIsOverlaid.x ? 0 : 3)) * 3,
2141
y: (_nativeScrollbarSize.y + (_nativeScrollbarIsOverlaid.y ? 0 : 3)) * 3
2144
changedOptions = changedOptions || {};
2148
var checkCacheAutoForce = function () {
2149
return checkCache.apply(this, [].slice.call(arguments).concat([force]));
2154
x: _viewportElement[_strScrollLeft](),
2155
y: _viewportElement[_strScrollTop]()
2158
var currentPreparedOptionsScrollbars = _currentPreparedOptions.scrollbars;
2159
var currentPreparedOptionsTextarea = _currentPreparedOptions.textarea;
2162
var scrollbarsVisibility = currentPreparedOptionsScrollbars.visibility;
2163
var scrollbarsVisibilityChanged = checkCacheAutoForce(scrollbarsVisibility, _scrollbarsVisibilityCache);
2166
var scrollbarsAutoHide = currentPreparedOptionsScrollbars.autoHide;
2167
var scrollbarsAutoHideChanged = checkCacheAutoForce(scrollbarsAutoHide, _scrollbarsAutoHideCache);
2170
var scrollbarsClickScrolling = currentPreparedOptionsScrollbars.clickScrolling;
2171
var scrollbarsClickScrollingChanged = checkCacheAutoForce(scrollbarsClickScrolling, _scrollbarsClickScrollingCache);
2174
var scrollbarsDragScrolling = currentPreparedOptionsScrollbars.dragScrolling;
2175
var scrollbarsDragScrollingChanged = checkCacheAutoForce(scrollbarsDragScrolling, _scrollbarsDragScrollingCache);
2178
var className = _currentPreparedOptions.className;
2179
var classNameChanged = checkCacheAutoForce(className, _classNameCache);
2182
var resize = _currentPreparedOptions.resize;
2183
var resizeChanged = checkCacheAutoForce(resize, _resizeCache) && !_isBody;
2186
var paddingAbsolute = _currentPreparedOptions.paddingAbsolute;
2187
var paddingAbsoluteChanged = checkCacheAutoForce(paddingAbsolute, _paddingAbsoluteCache);
2190
var clipAlways = _currentPreparedOptions.clipAlways;
2191
var clipAlwaysChanged = checkCacheAutoForce(clipAlways, _clipAlwaysCache);
2194
var sizeAutoCapable = _currentPreparedOptions.sizeAutoCapable && !_isBody;
2195
var sizeAutoCapableChanged = checkCacheAutoForce(sizeAutoCapable, _sizeAutoCapableCache);
2198
var ignoreOverlayScrollbarHiding = _currentPreparedOptions.nativeScrollbarsOverlaid.showNativeScrollbars;
2199
var ignoreOverlayScrollbarHidingChanged = checkCacheAutoForce(ignoreOverlayScrollbarHiding, _ignoreOverlayScrollbarHidingCache);
2202
var autoUpdate = _currentPreparedOptions.autoUpdate;
2203
var autoUpdateChanged = checkCacheAutoForce(autoUpdate, _autoUpdateCache);
2206
var overflowBehavior = _currentPreparedOptions.overflowBehavior;
2207
var overflowBehaviorChanged = checkCacheAutoForce(overflowBehavior, _overflowBehaviorCache, force);
2210
var textareaDynWidth = currentPreparedOptionsTextarea.dynWidth;
2211
var textareaDynWidthChanged = checkCacheAutoForce(_textareaDynWidthCache, textareaDynWidth);
2214
var textareaDynHeight = currentPreparedOptionsTextarea.dynHeight;
2215
var textareaDynHeightChanged = checkCacheAutoForce(_textareaDynHeightCache, textareaDynHeight);
2218
_scrollbarsAutoHideNever = scrollbarsAutoHide === 'n';
2219
_scrollbarsAutoHideScroll = scrollbarsAutoHide === 's';
2220
_scrollbarsAutoHideMove = scrollbarsAutoHide === 'm';
2221
_scrollbarsAutoHideLeave = scrollbarsAutoHide === 'l';
2224
_scrollbarsAutoHideDelay = currentPreparedOptionsScrollbars.autoHideDelay;
2227
_oldClassName = _classNameCache;
2230
_resizeNone = resize === 'n';
2231
_resizeBoth = resize === 'b';
2232
_resizeHorizontal = resize === 'h';
2233
_resizeVertical = resize === 'v';
2236
_normalizeRTLCache = _currentPreparedOptions.normalizeRTL;
2239
ignoreOverlayScrollbarHiding = ignoreOverlayScrollbarHiding && (_nativeScrollbarIsOverlaid.x && _nativeScrollbarIsOverlaid.y);
2242
_scrollbarsVisibilityCache = scrollbarsVisibility;
2243
_scrollbarsAutoHideCache = scrollbarsAutoHide;
2244
_scrollbarsClickScrollingCache = scrollbarsClickScrolling;
2245
_scrollbarsDragScrollingCache = scrollbarsDragScrolling;
2246
_classNameCache = className;
2247
_resizeCache = resize;
2248
_paddingAbsoluteCache = paddingAbsolute;
2249
_clipAlwaysCache = clipAlways;
2250
_sizeAutoCapableCache = sizeAutoCapable;
2251
_ignoreOverlayScrollbarHidingCache = ignoreOverlayScrollbarHiding;
2252
_autoUpdateCache = autoUpdate;
2253
_overflowBehaviorCache = extendDeep({}, overflowBehavior);
2254
_textareaDynWidthCache = textareaDynWidth;
2255
_textareaDynHeightCache = textareaDynHeight;
2256
_hasOverflowCache = _hasOverflowCache || { x: false, y: false };
2259
if (classNameChanged) {
2260
removeClass(_hostElement, _oldClassName + _strSpace + _classNameThemeNone);
2261
addClass(_hostElement, className !== undefined && className !== null && className.length > 0 ? className : _classNameThemeNone);
2265
if (autoUpdateChanged) {
2266
if (autoUpdate === true || (autoUpdate === null && _autoUpdateRecommended)) {
2267
disconnectMutationObservers();
2268
autoUpdateLoop.add(_base);
2271
autoUpdateLoop.remove(_base);
2272
connectMutationObservers();
2277
if (sizeAutoCapableChanged) {
2278
if (sizeAutoCapable) {
2279
if (_contentGlueElement) {
2280
_contentGlueElement.show();
2283
_contentGlueElement = FRAMEWORK(generateDiv(_classNameContentGlueElement));
2284
_paddingElement.before(_contentGlueElement);
2286
if (_sizeAutoObserverAdded) {
2287
_sizeAutoObserverElement.show();
2290
_sizeAutoObserverElement = FRAMEWORK(generateDiv(_classNameSizeAutoObserverElement));
2291
_sizeAutoObserverElementNative = _sizeAutoObserverElement[0];
2293
_contentGlueElement.before(_sizeAutoObserverElement);
2294
var oldSize = { w: -1, h: -1 };
2295
setupResizeObserver(_sizeAutoObserverElement, function () {
2297
w: _sizeAutoObserverElementNative[LEXICON.oW],
2298
h: _sizeAutoObserverElementNative[LEXICON.oH]
2300
if (checkCache(newSize, oldSize)) {
2301
if (_initialized && (_heightAutoCache && newSize.h > 0) || (_widthAutoCache && newSize.w > 0)) {
2304
else if (_initialized && (!_heightAutoCache && newSize.h === 0) || (!_widthAutoCache && newSize.w === 0)) {
2310
_sizeAutoObserverAdded = true;
2313
if (_cssCalc !== null)
2314
_sizeAutoObserverElement.css(_strHeight, _cssCalc + '(100% + 1px)');
2318
if (_sizeAutoObserverAdded)
2319
_sizeAutoObserverElement.hide();
2320
if (_contentGlueElement)
2321
_contentGlueElement.hide();
2327
_sizeObserverElement.find('*').trigger(_strScroll);
2328
if (_sizeAutoObserverAdded)
2329
_sizeAutoObserverElement.find('*').trigger(_strScroll);
2333
displayIsHidden = displayIsHidden === undefined ? _hostElement.is(':hidden') : displayIsHidden;
2336
var textareaAutoWrapping = _isTextarea ? _targetElement.attr('wrap') !== 'off' : false;
2337
var textareaAutoWrappingChanged = checkCacheAutoForce(textareaAutoWrapping, _textareaAutoWrappingCache);
2340
var cssDirection = _hostElement.css('direction');
2341
var cssDirectionChanged = checkCacheAutoForce(cssDirection, _cssDirectionCache);
2344
var boxSizing = _hostElement.css('box-sizing');
2345
var boxSizingChanged = checkCacheAutoForce(boxSizing, _cssBoxSizingCache);
2348
var padding = getTopRightBottomLeftHost(_strPaddingMinus);
2351
var sizeAutoObserverElementBCRect;
2354
sizeAutoObserverElementBCRect = _sizeAutoObserverAdded ? _sizeAutoObserverElementNative[LEXICON.bCR]() : null;
2359
_isRTL = cssDirection === 'rtl';
2360
_isBorderBox = (boxSizing === 'border-box');
2361
var isRTLLeft = _isRTL ? _strLeft : _strRight;
2362
var isRTLRight = _isRTL ? _strRight : _strLeft;
2365
var widthAutoResizeDetection = false;
2366
var widthAutoObserverDetection = (_sizeAutoObserverAdded && (_hostElement.css(_strFloat) !== 'none' )) ? (MATH.round(sizeAutoObserverElementBCRect.right - sizeAutoObserverElementBCRect.left) === 0) && (!paddingAbsolute ? (_hostElementNative[LEXICON.cW] - _paddingX) > 0 : true) : false;
2367
if (sizeAutoCapable && !widthAutoObserverDetection) {
2368
var tmpCurrHostWidth = _hostElementNative[LEXICON.oW];
2369
var tmpCurrContentGlueWidth = _contentGlueElement.css(_strWidth);
2370
_contentGlueElement.css(_strWidth, _strAuto);
2372
var tmpNewHostWidth = _hostElementNative[LEXICON.oW];
2373
_contentGlueElement.css(_strWidth, tmpCurrContentGlueWidth);
2374
widthAutoResizeDetection = tmpCurrHostWidth !== tmpNewHostWidth;
2375
if (!widthAutoResizeDetection) {
2376
_contentGlueElement.css(_strWidth, tmpCurrHostWidth + 1);
2377
tmpNewHostWidth = _hostElementNative[LEXICON.oW];
2378
_contentGlueElement.css(_strWidth, tmpCurrContentGlueWidth);
2379
widthAutoResizeDetection = tmpCurrHostWidth !== tmpNewHostWidth;
2382
var widthAuto = (widthAutoObserverDetection || widthAutoResizeDetection) && sizeAutoCapable && !displayIsHidden;
2383
var widthAutoChanged = checkCacheAutoForce(widthAuto, _widthAutoCache);
2384
var wasWidthAuto = !widthAuto && _widthAutoCache;
2387
var heightAuto = _sizeAutoObserverAdded && sizeAutoCapable && !displayIsHidden ? (MATH.round(sizeAutoObserverElementBCRect.bottom - sizeAutoObserverElementBCRect.top) === 0) : false;
2388
var heightAutoChanged = checkCacheAutoForce(heightAuto, _heightAutoCache);
2389
var wasHeightAuto = !heightAuto && _heightAutoCache;
2393
var updateBorderX = (widthAuto && _isBorderBox) || !_isBorderBox;
2394
var updateBorderY = (heightAuto && _isBorderBox) || !_isBorderBox;
2395
var border = getTopRightBottomLeftHost(_strBorderMinus, '-' + _strWidth, !updateBorderX, !updateBorderY)
2398
var margin = getTopRightBottomLeftHost(_strMarginMinus);
2401
var contentElementCSS = {};
2402
var contentGlueElementCSS = {};
2405
var getHostSize = function () {
2408
w: _hostElementNative[LEXICON.cW],
2409
h: _hostElementNative[LEXICON.cH]
2412
var getViewportSize = function () {
2417
w: _paddingElementNative[LEXICON.oW] + MATH.max(0, _contentElementNative[LEXICON.cW] - _contentElementNative[LEXICON.sW]),
2418
h: _paddingElementNative[LEXICON.oH] + MATH.max(0, _contentElementNative[LEXICON.cH] - _contentElementNative[LEXICON.sH])
2423
var paddingAbsoluteX = _paddingX = padding.l + padding.r;
2424
var paddingAbsoluteY = _paddingY = padding.t + padding.b;
2425
paddingAbsoluteX *= paddingAbsolute ? 1 : 0;
2426
paddingAbsoluteY *= paddingAbsolute ? 1 : 0;
2427
padding.c = checkCacheAutoForce(padding, _cssPaddingCache);
2430
_borderX = border.l + border.r;
2431
_borderY = border.t + border.b;
2432
border.c = checkCacheAutoForce(border, _cssBorderCache);
2435
_marginX = margin.l + margin.r;
2436
_marginY = margin.t + margin.b;
2437
margin.c = checkCacheAutoForce(margin, _cssMarginCache);
2440
_textareaAutoWrappingCache = textareaAutoWrapping;
2441
_cssDirectionCache = cssDirection;
2442
_cssBoxSizingCache = boxSizing;
2443
_widthAutoCache = widthAuto;
2444
_heightAutoCache = heightAuto;
2445
_cssPaddingCache = padding;
2446
_cssBorderCache = border;
2447
_cssMarginCache = margin;
2450
if (cssDirectionChanged && _sizeAutoObserverAdded)
2451
_sizeAutoObserverElement.css(_strFloat, isRTLRight);
2454
if (padding.c || cssDirectionChanged || paddingAbsoluteChanged || widthAutoChanged || heightAutoChanged || boxSizingChanged || sizeAutoCapableChanged) {
2455
var paddingElementCSS = {};
2456
var textareaCSS = {};
2457
var paddingValues = [padding.t, padding.r, padding.b, padding.l];
2459
setTopRightBottomLeft(contentGlueElementCSS, _strMarginMinus, [-padding.t, -padding.r, -padding.b, -padding.l]);
2460
if (paddingAbsolute) {
2461
setTopRightBottomLeft(paddingElementCSS, _strEmpty, paddingValues);
2462
setTopRightBottomLeft(_isTextarea ? textareaCSS : contentElementCSS, _strPaddingMinus);
2465
setTopRightBottomLeft(paddingElementCSS, _strEmpty);
2466
setTopRightBottomLeft(_isTextarea ? textareaCSS : contentElementCSS, _strPaddingMinus, paddingValues);
2469
_paddingElement.css(paddingElementCSS);
2470
_targetElement.css(textareaCSS);
2474
_viewportSize = getViewportSize();
2477
var textareaSize = _isTextarea ? textareaUpdate() : false;
2478
var textareaSizeChanged = _isTextarea && checkCacheAutoForce(textareaSize, _textareaSizeCache);
2479
var textareaDynOrigSize = _isTextarea && textareaSize ? {
2480
w: textareaDynWidth ? textareaSize._dynamicWidth : textareaSize._originalWidth,
2481
h: textareaDynHeight ? textareaSize._dynamicHeight : textareaSize._originalHeight
2483
_textareaSizeCache = textareaSize;
2486
if (heightAuto && (heightAutoChanged || paddingAbsoluteChanged || boxSizingChanged || padding.c || border.c)) {
2487
contentElementCSS[_strHeight] = _strAuto;
2489
else if (heightAutoChanged || paddingAbsoluteChanged) {
2490
contentElementCSS[_strHeight] = _strHundredPercent;
2492
if (widthAuto && (widthAutoChanged || paddingAbsoluteChanged || boxSizingChanged || padding.c || border.c || cssDirectionChanged)) {
2493
contentElementCSS[_strWidth] = _strAuto;
2494
contentGlueElementCSS[_strMaxMinus + _strWidth] = _strHundredPercent;
2496
else if (widthAutoChanged || paddingAbsoluteChanged) {
2497
contentElementCSS[_strWidth] = _strHundredPercent;
2498
contentElementCSS[_strFloat] = _strEmpty;
2499
contentGlueElementCSS[_strMaxMinus + _strWidth] = _strEmpty;
2503
contentGlueElementCSS[_strWidth] = _strAuto;
2505
contentElementCSS[_strWidth] = VENDORS._cssPropertyValue(_strWidth, 'max-content intrinsic') || _strAuto;
2506
contentElementCSS[_strFloat] = isRTLRight;
2509
contentGlueElementCSS[_strWidth] = _strEmpty;
2513
contentGlueElementCSS[_strHeight] = textareaDynOrigSize.h || _contentElementNative[LEXICON.cH];
2516
contentGlueElementCSS[_strHeight] = _strEmpty;
2518
if (sizeAutoCapable)
2519
_contentGlueElement.css(contentGlueElementCSS);
2520
_contentElement.css(contentElementCSS);
2523
contentElementCSS = {};
2524
contentGlueElementCSS = {};
2527
if (hostSizeChanged || contentSizeChanged || textareaSizeChanged || cssDirectionChanged || boxSizingChanged || paddingAbsoluteChanged || widthAutoChanged || widthAuto || heightAutoChanged || heightAuto || ignoreOverlayScrollbarHidingChanged || overflowBehaviorChanged || clipAlwaysChanged || resizeChanged || scrollbarsVisibilityChanged || scrollbarsAutoHideChanged || scrollbarsDragScrollingChanged || scrollbarsClickScrollingChanged || textareaDynWidthChanged || textareaDynHeightChanged || textareaAutoWrappingChanged) {
2528
var strOverflow = 'overflow';
2529
var strOverflowX = strOverflow + '-x';
2530
var strOverflowY = strOverflow + '-y';
2531
var strHidden = 'hidden';
2532
var strVisible = 'visible';
2536
if (!_nativeScrollbarStyling) {
2537
var viewportElementResetCSS = {};
2538
var resetXTmp = _hasOverflowCache.y && _hideOverflowCache.ys && !ignoreOverlayScrollbarHiding ? (_nativeScrollbarIsOverlaid.y ? _viewportElement.css(isRTLLeft) : -_nativeScrollbarSize.y) : 0;
2539
var resetBottomTmp = _hasOverflowCache.x && _hideOverflowCache.xs && !ignoreOverlayScrollbarHiding ? (_nativeScrollbarIsOverlaid.x ? _viewportElement.css(_strBottom) : -_nativeScrollbarSize.x) : 0;
2540
setTopRightBottomLeft(viewportElementResetCSS, _strEmpty);
2541
_viewportElement.css(viewportElementResetCSS);
2545
var contentMeasureElement = getContentMeasureElement();
2549
w: textareaDynOrigSize.w || contentMeasureElement[LEXICON.cW],
2550
h: textareaDynOrigSize.h || contentMeasureElement[LEXICON.cH]
2553
w: contentMeasureElement[LEXICON.sW],
2554
h: contentMeasureElement[LEXICON.sH]
2558
if (!_nativeScrollbarStyling) {
2559
viewportElementResetCSS[_strBottom] = wasHeightAuto ? _strEmpty : resetBottomTmp;
2560
viewportElementResetCSS[isRTLLeft] = wasWidthAuto ? _strEmpty : resetXTmp;
2561
_viewportElement.css(viewportElementResetCSS);
2563
_viewportSize = getViewportSize();
2566
var hostSize = getHostSize();
2567
var hostAbsoluteRectSize = {
2568
w: hostSize.w - _marginX - _borderX - (_isBorderBox ? 0 : _paddingX),
2569
h: hostSize.h - _marginY - _borderY - (_isBorderBox ? 0 : _paddingY)
2571
var contentGlueSize = {
2574
w: MATH.max((widthAuto ? contentSize.w : scrollSize.w) + paddingAbsoluteX, hostAbsoluteRectSize.w),
2575
h: MATH.max((heightAuto ? contentSize.h : scrollSize.h) + paddingAbsoluteY, hostAbsoluteRectSize.h)
2577
contentGlueSize.c = checkCacheAutoForce(contentGlueSize, _contentGlueSizeCache);
2578
_contentGlueSizeCache = contentGlueSize;
2581
if (sizeAutoCapable) {
2583
if (contentGlueSize.c || (heightAuto || widthAuto)) {
2584
contentGlueElementCSS[_strWidth] = contentGlueSize.w;
2585
contentGlueElementCSS[_strHeight] = contentGlueSize.h;
2591
w: contentMeasureElement[LEXICON.cW],
2592
h: contentMeasureElement[LEXICON.cH]
2596
var textareaCoverCSS = {};
2597
var setContentGlueElementCSSfunction = function (horizontal) {
2598
var scrollbarVars = getScrollbarVars(horizontal);
2599
var wh = scrollbarVars._w_h;
2600
var strWH = scrollbarVars._width_height;
2601
var autoSize = horizontal ? widthAuto : heightAuto;
2602
var borderSize = horizontal ? _borderX : _borderY;
2603
var paddingSize = horizontal ? _paddingX : _paddingY;
2604
var marginSize = horizontal ? _marginX : _marginY;
2605
var viewportSize = _viewportSize[wh] - borderSize - marginSize - (_isBorderBox ? 0 : paddingSize);
2608
if (!autoSize || (!autoSize && border.c))
2609
contentGlueElementCSS[strWH] = hostAbsoluteRectSize[wh] - 1;
2612
if (autoSize && (contentSize[wh] < viewportSize) && (horizontal && _isTextarea ? !textareaAutoWrapping : true)) {
2614
textareaCoverCSS[strWH] = parseToZeroOrNumber(_textareaCoverElement.css(strWH)) - 1;
2615
contentGlueElementCSS[strWH] -= 1;
2619
if (contentSize[wh] > 0)
2620
contentGlueElementCSS[strWH] = MATH.max(1, contentGlueElementCSS[strWH]);
2622
setContentGlueElementCSSfunction(true);
2623
setContentGlueElementCSSfunction(false);
2626
_textareaCoverElement.css(textareaCoverCSS);
2627
_contentGlueElement.css(contentGlueElementCSS);
2630
contentElementCSS[_strWidth] = _strHundredPercent;
2631
if (widthAuto && !_isBorderBox && !_mutationObserversConnected)
2632
contentElementCSS[_strFloat] = 'none';
2635
_contentElement.css(contentElementCSS);
2636
contentElementCSS = {};
2639
var contentScrollSize = {
2640
w: contentMeasureElement[LEXICON.sW],
2641
h: contentMeasureElement[LEXICON.sH],
2643
contentScrollSize.c = contentSizeChanged = checkCacheAutoForce(contentScrollSize, _contentScrollSizeCache);
2644
_contentScrollSizeCache = contentScrollSize;
2647
_viewportSize = getViewportSize();
2649
hostSize = getHostSize();
2650
hostSizeChanged = checkCacheAutoForce(hostSize, _hostSizeCache);
2651
_hostSizeCache = hostSize;
2653
var hideOverflowForceTextarea = _isTextarea && (_viewportSize.w === 0 || _viewportSize.h === 0);
2654
var previousOverflowAmount = _overflowAmountCache;
2655
var overflowBehaviorIsVS = {};
2656
var overflowBehaviorIsVH = {};
2657
var overflowBehaviorIsS = {};
2658
var overflowAmount = {};
2659
var hasOverflow = {};
2660
var hideOverflow = {};
2662
var viewportRect = _paddingElementNative[LEXICON.bCR]();
2663
var setOverflowVariables = function (horizontal) {
2664
var scrollbarVars = getScrollbarVars(horizontal);
2665
var scrollbarVarsInverted = getScrollbarVars(!horizontal);
2666
var xyI = scrollbarVarsInverted._x_y;
2667
var xy = scrollbarVars._x_y;
2668
var wh = scrollbarVars._w_h;
2669
var widthHeight = scrollbarVars._width_height;
2670
var scrollMax = _strScroll + scrollbarVars._Left_Top + 'Max';
2671
var fractionalOverflowAmount = viewportRect[widthHeight] ? MATH.abs(viewportRect[widthHeight] - _viewportSize[wh]) : 0;
2672
var checkFractionalOverflowAmount = previousOverflowAmount && previousOverflowAmount[xy] > 0 && _viewportElementNative[scrollMax] === 0;
2673
overflowBehaviorIsVS[xy] = overflowBehavior[xy] === 'v-s';
2674
overflowBehaviorIsVH[xy] = overflowBehavior[xy] === 'v-h';
2675
overflowBehaviorIsS[xy] = overflowBehavior[xy] === 's';
2676
overflowAmount[xy] = MATH.max(0, MATH.round((contentScrollSize[wh] - _viewportSize[wh]) * 100) / 100);
2677
overflowAmount[xy] *= (hideOverflowForceTextarea || (checkFractionalOverflowAmount && fractionalOverflowAmount > 0 && fractionalOverflowAmount < 1)) ? 0 : 1;
2678
hasOverflow[xy] = overflowAmount[xy] > 0;
2683
hideOverflow[xy] = overflowBehaviorIsVS[xy] || overflowBehaviorIsVH[xy] ? (hasOverflow[xyI] && !overflowBehaviorIsVS[xyI] && !overflowBehaviorIsVH[xyI]) : hasOverflow[xy];
2684
hideOverflow[xy + 's'] = hideOverflow[xy] ? (overflowBehaviorIsS[xy] || overflowBehaviorIsVS[xy]) : false;
2686
canScroll[xy] = hasOverflow[xy] && hideOverflow[xy + 's'];
2688
setOverflowVariables(true);
2689
setOverflowVariables(false);
2691
overflowAmount.c = checkCacheAutoForce(overflowAmount, _overflowAmountCache);
2692
_overflowAmountCache = overflowAmount;
2693
hasOverflow.c = checkCacheAutoForce(hasOverflow, _hasOverflowCache);
2694
_hasOverflowCache = hasOverflow;
2695
hideOverflow.c = checkCacheAutoForce(hideOverflow, _hideOverflowCache);
2696
_hideOverflowCache = hideOverflow;
2699
if (_nativeScrollbarIsOverlaid.x || _nativeScrollbarIsOverlaid.y) {
2700
var borderDesign = 'px solid transparent';
2701
var contentArrangeElementCSS = {};
2702
var arrangeContent = {};
2703
var arrangeChanged = force;
2704
var setContentElementCSS;
2706
if (hasOverflow.x || hasOverflow.y) {
2707
arrangeContent.w = _nativeScrollbarIsOverlaid.y && hasOverflow.y ? contentScrollSize.w + _overlayScrollbarDummySize.y : _strEmpty;
2708
arrangeContent.h = _nativeScrollbarIsOverlaid.x && hasOverflow.x ? contentScrollSize.h + _overlayScrollbarDummySize.x : _strEmpty;
2709
arrangeChanged = checkCacheAutoForce(arrangeContent, _arrangeContentSizeCache);
2710
_arrangeContentSizeCache = arrangeContent;
2713
if (hasOverflow.c || hideOverflow.c || contentScrollSize.c || cssDirectionChanged || widthAutoChanged || heightAutoChanged || widthAuto || heightAuto || ignoreOverlayScrollbarHidingChanged) {
2714
contentElementCSS[_strMarginMinus + isRTLRight] = contentElementCSS[_strBorderMinus + isRTLRight] = _strEmpty;
2715
setContentElementCSS = function (horizontal) {
2716
var scrollbarVars = getScrollbarVars(horizontal);
2717
var scrollbarVarsInverted = getScrollbarVars(!horizontal);
2718
var xy = scrollbarVars._x_y;
2719
var strDirection = horizontal ? _strBottom : isRTLLeft;
2720
var invertedAutoSize = horizontal ? heightAuto : widthAuto;
2722
if (_nativeScrollbarIsOverlaid[xy] && hasOverflow[xy] && hideOverflow[xy + 's']) {
2723
contentElementCSS[_strMarginMinus + strDirection] = invertedAutoSize ? (ignoreOverlayScrollbarHiding ? _strEmpty : _overlayScrollbarDummySize[xy]) : _strEmpty;
2724
contentElementCSS[_strBorderMinus + strDirection] = ((horizontal ? !invertedAutoSize : true) && !ignoreOverlayScrollbarHiding) ? (_overlayScrollbarDummySize[xy] + borderDesign) : _strEmpty;
2727
arrangeContent[scrollbarVarsInverted._w_h] =
2728
contentElementCSS[_strMarginMinus + strDirection] =
2729
contentElementCSS[_strBorderMinus + strDirection] = _strEmpty;
2730
arrangeChanged = true;
2734
if (_nativeScrollbarStyling) {
2735
addRemoveClass(_viewportElement, _classNameViewportNativeScrollbarsInvisible, !ignoreOverlayScrollbarHiding)
2738
setContentElementCSS(true);
2739
setContentElementCSS(false);
2742
if (ignoreOverlayScrollbarHiding) {
2743
arrangeContent.w = arrangeContent.h = _strEmpty;
2744
arrangeChanged = true;
2746
if (arrangeChanged && !_nativeScrollbarStyling) {
2747
contentArrangeElementCSS[_strWidth] = hideOverflow.y ? arrangeContent.w : _strEmpty;
2748
contentArrangeElementCSS[_strHeight] = hideOverflow.x ? arrangeContent.h : _strEmpty;
2750
if (!_contentArrangeElement) {
2751
_contentArrangeElement = FRAMEWORK(generateDiv(_classNameContentArrangeElement));
2752
_viewportElement.prepend(_contentArrangeElement);
2754
_contentArrangeElement.css(contentArrangeElementCSS);
2756
_contentElement.css(contentElementCSS);
2759
var viewportElementCSS = {};
2760
var paddingElementCSS = {};
2762
if (hostSizeChanged || hasOverflow.c || hideOverflow.c || contentScrollSize.c || overflowBehaviorChanged || boxSizingChanged || ignoreOverlayScrollbarHidingChanged || cssDirectionChanged || clipAlwaysChanged || heightAutoChanged) {
2763
viewportElementCSS[isRTLRight] = _strEmpty;
2764
setViewportCSS = function (horizontal) {
2765
var scrollbarVars = getScrollbarVars(horizontal);
2766
var scrollbarVarsInverted = getScrollbarVars(!horizontal);
2767
var xy = scrollbarVars._x_y;
2768
var XY = scrollbarVars._X_Y;
2769
var strDirection = horizontal ? _strBottom : isRTLLeft;
2771
var reset = function () {
2772
viewportElementCSS[strDirection] = _strEmpty;
2773
_contentBorderSize[scrollbarVarsInverted._w_h] = 0;
2775
if (hasOverflow[xy] && hideOverflow[xy + 's']) {
2776
viewportElementCSS[strOverflow + XY] = _strScroll;
2777
if (ignoreOverlayScrollbarHiding || _nativeScrollbarStyling) {
2781
viewportElementCSS[strDirection] = -(_nativeScrollbarIsOverlaid[xy] ? _overlayScrollbarDummySize[xy] : _nativeScrollbarSize[xy]);
2782
_contentBorderSize[scrollbarVarsInverted._w_h] = _nativeScrollbarIsOverlaid[xy] ? _overlayScrollbarDummySize[scrollbarVarsInverted._x_y] : 0;
2785
viewportElementCSS[strOverflow + XY] = _strEmpty;
2789
setViewportCSS(true);
2790
setViewportCSS(false);
2797
if (!_nativeScrollbarStyling
2798
&& (_viewportSize.h < _nativeScrollbarMinSize.x || _viewportSize.w < _nativeScrollbarMinSize.y)
2799
&& ((hasOverflow.x && hideOverflow.x && !_nativeScrollbarIsOverlaid.x) || (hasOverflow.y && hideOverflow.y && !_nativeScrollbarIsOverlaid.y))) {
2800
viewportElementCSS[_strPaddingMinus + _strTop] = _nativeScrollbarMinSize.x;
2801
viewportElementCSS[_strMarginMinus + _strTop] = -_nativeScrollbarMinSize.x;
2803
viewportElementCSS[_strPaddingMinus + isRTLRight] = _nativeScrollbarMinSize.y;
2804
viewportElementCSS[_strMarginMinus + isRTLRight] = -_nativeScrollbarMinSize.y;
2807
viewportElementCSS[_strPaddingMinus + _strTop] =
2808
viewportElementCSS[_strMarginMinus + _strTop] =
2809
viewportElementCSS[_strPaddingMinus + isRTLRight] =
2810
viewportElementCSS[_strMarginMinus + isRTLRight] = _strEmpty;
2812
viewportElementCSS[_strPaddingMinus + isRTLLeft] =
2813
viewportElementCSS[_strMarginMinus + isRTLLeft] = _strEmpty;
2816
if ((hasOverflow.x && hideOverflow.x) || (hasOverflow.y && hideOverflow.y) || hideOverflowForceTextarea) {
2818
if (_isTextarea && hideOverflowForceTextarea) {
2819
paddingElementCSS[strOverflowX] =
2820
paddingElementCSS[strOverflowY] = strHidden;
2824
if (!clipAlways || (overflowBehaviorIsVH.x || overflowBehaviorIsVS.x || overflowBehaviorIsVH.y || overflowBehaviorIsVS.y)) {
2827
paddingElementCSS[strOverflowX] =
2828
paddingElementCSS[strOverflowY] = _strEmpty;
2830
viewportElementCSS[strOverflowX] =
2831
viewportElementCSS[strOverflowY] = strVisible;
2835
_paddingElement.css(paddingElementCSS);
2836
_viewportElement.css(viewportElementCSS);
2837
viewportElementCSS = {};
2840
if ((hasOverflow.c || boxSizingChanged || widthAutoChanged || heightAutoChanged) && !(_nativeScrollbarIsOverlaid.x && _nativeScrollbarIsOverlaid.y)) {
2841
var elementStyle = _contentElementNative[LEXICON.s];
2843
elementStyle.webkitTransform = 'scale(1)';
2844
elementStyle.display = 'run-in';
2845
dump = _contentElementNative[LEXICON.oH];
2846
elementStyle.display = _strEmpty;
2847
elementStyle.webkitTransform = _strEmpty;
2861
contentElementCSS = {};
2862
if (cssDirectionChanged || widthAutoChanged || heightAutoChanged) {
2863
if (_isRTL && widthAuto) {
2864
var floatTmp = _contentElement.css(_strFloat);
2865
var posLeftWithoutFloat = MATH.round(_contentElement.css(_strFloat, _strEmpty).css(_strLeft, _strEmpty).position().left);
2866
_contentElement.css(_strFloat, floatTmp);
2867
var posLeftWithFloat = MATH.round(_contentElement.position().left);
2869
if (posLeftWithoutFloat !== posLeftWithFloat)
2870
contentElementCSS[_strLeft] = posLeftWithoutFloat;
2873
contentElementCSS[_strLeft] = _strEmpty;
2876
_contentElement.css(contentElementCSS);
2879
if (_isTextarea && contentSizeChanged) {
2880
var textareaInfo = getTextareaInfo();
2882
var textareaRowsChanged = _textareaInfoCache === undefined ? true : textareaInfo._rows !== _textareaInfoCache._rows;
2883
var cursorRow = textareaInfo._cursorRow;
2884
var cursorCol = textareaInfo._cursorColumn;
2885
var widestRow = textareaInfo._widestRow;
2886
var lastRow = textareaInfo._rows;
2887
var lastCol = textareaInfo._columns;
2888
var cursorPos = textareaInfo._cursorPosition;
2889
var cursorMax = textareaInfo._cursorMax;
2890
var cursorIsLastPosition = (cursorPos >= cursorMax && _textareaHasFocus);
2891
var textareaScrollAmount = {
2892
x: (!textareaAutoWrapping && (cursorCol === lastCol && cursorRow === widestRow)) ? _overflowAmountCache.x : -1,
2893
y: (textareaAutoWrapping ? cursorIsLastPosition || textareaRowsChanged && (previousOverflowAmount ? (currScroll.y === previousOverflowAmount.y) : false) : (cursorIsLastPosition || textareaRowsChanged) && cursorRow === lastRow) ? _overflowAmountCache.y : -1
2895
currScroll.x = textareaScrollAmount.x > -1 ? (_isRTL && _normalizeRTLCache && _rtlScrollBehavior.i ? 0 : textareaScrollAmount.x) : currScroll.x;
2896
currScroll.y = textareaScrollAmount.y > -1 ? textareaScrollAmount.y : currScroll.y;
2898
_textareaInfoCache = textareaInfo;
2900
if (_isRTL && _rtlScrollBehavior.i && _nativeScrollbarIsOverlaid.y && hasOverflow.x && _normalizeRTLCache)
2901
currScroll.x += _contentBorderSize.w || 0;
2903
_hostElement[_strScrollLeft](0);
2905
_hostElement[_strScrollTop](0);
2906
_viewportElement[_strScrollLeft](currScroll.x)[_strScrollTop](currScroll.y);
2909
var scrollbarsVisibilityVisible = scrollbarsVisibility === 'v';
2910
var scrollbarsVisibilityHidden = scrollbarsVisibility === 'h';
2911
var scrollbarsVisibilityAuto = scrollbarsVisibility === 'a';
2912
var refreshScrollbarsVisibility = function (showX, showY) {
2913
showY = showY === undefined ? showX : showY;
2914
refreshScrollbarAppearance(true, showX, canScroll.x)
2915
refreshScrollbarAppearance(false, showY, canScroll.y)
2919
addRemoveClass(_hostElement, _classNameHostOverflow, hideOverflow.x || hideOverflow.y);
2920
addRemoveClass(_hostElement, _classNameHostOverflowX, hideOverflow.x);
2921
addRemoveClass(_hostElement, _classNameHostOverflowY, hideOverflow.y);
2924
if (cssDirectionChanged && !_isBody) {
2925
addRemoveClass(_hostElement, _classNameHostRTL, _isRTL);
2930
addClass(_hostElement, _classNameHostResizeDisabled);
2931
if (resizeChanged) {
2932
addRemoveClass(_hostElement, _classNameHostResizeDisabled, _resizeNone);
2933
addRemoveClass(_scrollbarCornerElement, _classNameScrollbarCornerResize, !_resizeNone);
2934
addRemoveClass(_scrollbarCornerElement, _classNameScrollbarCornerResizeB, _resizeBoth);
2935
addRemoveClass(_scrollbarCornerElement, _classNameScrollbarCornerResizeH, _resizeHorizontal);
2936
addRemoveClass(_scrollbarCornerElement, _classNameScrollbarCornerResizeV, _resizeVertical);
2940
if (scrollbarsVisibilityChanged || overflowBehaviorChanged || hideOverflow.c || hasOverflow.c || ignoreOverlayScrollbarHidingChanged) {
2941
if (ignoreOverlayScrollbarHiding) {
2942
if (ignoreOverlayScrollbarHidingChanged) {
2943
removeClass(_hostElement, _classNameHostScrolling);
2944
if (ignoreOverlayScrollbarHiding) {
2945
refreshScrollbarsVisibility(false);
2949
else if (scrollbarsVisibilityAuto) {
2950
refreshScrollbarsVisibility(canScroll.x, canScroll.y);
2952
else if (scrollbarsVisibilityVisible) {
2953
refreshScrollbarsVisibility(true);
2955
else if (scrollbarsVisibilityHidden) {
2956
refreshScrollbarsVisibility(false);
2961
if (scrollbarsAutoHideChanged || ignoreOverlayScrollbarHidingChanged) {
2962
setupHostMouseTouchEvents(!_scrollbarsAutoHideLeave && !_scrollbarsAutoHideMove);
2963
refreshScrollbarsAutoHide(_scrollbarsAutoHideNever, !_scrollbarsAutoHideNever);
2967
if (hostSizeChanged || overflowAmount.c || heightAutoChanged || widthAutoChanged || resizeChanged || boxSizingChanged || paddingAbsoluteChanged || ignoreOverlayScrollbarHidingChanged || cssDirectionChanged) {
2968
refreshScrollbarHandleLength(true);
2969
refreshScrollbarHandleOffset(true);
2970
refreshScrollbarHandleLength(false);
2971
refreshScrollbarHandleOffset(false);
2975
if (scrollbarsClickScrollingChanged)
2976
refreshScrollbarsInteractive(true, scrollbarsClickScrolling);
2977
if (scrollbarsDragScrollingChanged)
2978
refreshScrollbarsInteractive(false, scrollbarsDragScrolling);
2981
dispatchCallback('onDirectionChanged', {
2984
}, cssDirectionChanged);
2985
dispatchCallback('onHostSizeChanged', {
2986
width: _hostSizeCache.w,
2987
height: _hostSizeCache.h
2988
}, hostSizeChanged);
2989
dispatchCallback('onContentSizeChanged', {
2990
width: _contentScrollSizeCache.w,
2991
height: _contentScrollSizeCache.h
2992
}, contentSizeChanged);
2993
dispatchCallback('onOverflowChanged', {
2996
xScrollable: hideOverflow.xs,
2997
yScrollable: hideOverflow.ys,
2998
clipped: hideOverflow.x || hideOverflow.y
2999
}, hasOverflow.c || hideOverflow.c);
3000
dispatchCallback('onOverflowAmountChanged', {
3001
x: overflowAmount.x,
3003
}, overflowAmount.c);
3007
if (_isBody && _bodyMinSizeCache && (_hasOverflowCache.c || _bodyMinSizeCache.c)) {
3009
if (!_bodyMinSizeCache.f)
3010
bodyMinSizeChanged();
3011
if (_nativeScrollbarIsOverlaid.y && _hasOverflowCache.x)
3012
_contentElement.css(_strMinMinus + _strWidth, _bodyMinSizeCache.w + _overlayScrollbarDummySize.y);
3013
if (_nativeScrollbarIsOverlaid.x && _hasOverflowCache.y)
3014
_contentElement.css(_strMinMinus + _strHeight, _bodyMinSizeCache.h + _overlayScrollbarDummySize.x);
3015
_bodyMinSizeCache.c = false;
3018
if (_initialized && changedOptions.updateOnLoad) {
3019
updateElementsOnLoad();
3025
dispatchCallback('onUpdated', { forced: force });
3031
function updateElementsOnLoad() {
3033
eachUpdateOnLoad(function (i, updateOnLoadSelector) {
3034
_contentElement.find(updateOnLoadSelector).each(function (i, el) {
3036
if (COMPATIBILITY.inA(el, _updateOnLoadElms) < 0) {
3037
_updateOnLoadElms.push(el);
3039
.off(_updateOnLoadEventName, updateOnLoadCallback)
3040
.on(_updateOnLoadEventName, updateOnLoadCallback);
3054
function setOptions(newOptions) {
3055
var validatedOpts = _pluginsOptions._validate(newOptions, _pluginsOptions._template, true, _currentOptions)
3057
_currentOptions = extendDeep({}, _currentOptions, validatedOpts._default);
3058
_currentPreparedOptions = extendDeep({}, _currentPreparedOptions, validatedOpts._prepared);
3060
return validatedOpts._prepared;
3074
function setupStructureDOM(destroy) {
3075
var strParent = 'parent';
3076
var classNameResizeObserverHost = 'os-resize-observer-host';
3077
var classNameTextareaElementFull = _classNameTextareaElement + _strSpace + _classNameTextInherit;
3078
var textareaClass = _isTextarea ? _strSpace + _classNameTextInherit : _strEmpty;
3079
var adoptAttrs = _currentPreparedOptions.textarea.inheritedAttrs;
3080
var adoptAttrsMap = {};
3081
var applyAdoptedAttrs = function () {
3082
var applyAdoptedAttrsElm = destroy ? _targetElement : _hostElement;
3083
each(adoptAttrsMap, function (key, value) {
3084
if (type(value) == TYPES.s) {
3085
if (key == LEXICON.c)
3086
applyAdoptedAttrsElm.addClass(value);
3088
applyAdoptedAttrsElm.attr(key, value);
3092
var hostElementClassNames = [
3093
_classNameHostElement,
3094
_classNameHostElementForeign,
3095
_classNameHostTextareaElement,
3096
_classNameHostResizeDisabled,
3098
_classNameHostScrollbarHorizontalHidden,
3099
_classNameHostScrollbarVerticalHidden,
3100
_classNameHostTransition,
3101
_classNameHostScrolling,
3102
_classNameHostOverflow,
3103
_classNameHostOverflowX,
3104
_classNameHostOverflowY,
3105
_classNameThemeNone,
3106
_classNameTextareaElement,
3107
_classNameTextInherit,
3108
_classNameCache].join(_strSpace);
3109
var hostElementCSS = {};
3112
_hostElement = _hostElement || (_isTextarea ? (_domExists ? _targetElement[strParent]()[strParent]()[strParent]()[strParent]() : FRAMEWORK(generateDiv(_classNameHostTextareaElement))) : _targetElement);
3113
_contentElement = _contentElement || selectOrGenerateDivByClass(_classNameContentElement + textareaClass);
3114
_viewportElement = _viewportElement || selectOrGenerateDivByClass(_classNameViewportElement + textareaClass);
3115
_paddingElement = _paddingElement || selectOrGenerateDivByClass(_classNamePaddingElement + textareaClass);
3116
_sizeObserverElement = _sizeObserverElement || selectOrGenerateDivByClass(classNameResizeObserverHost);
3117
_textareaCoverElement = _textareaCoverElement || (_isTextarea ? selectOrGenerateDivByClass(_classNameTextareaCoverElement) : undefined);
3121
addClass(_hostElement, _classNameHostElementForeign);
3126
removeClass(_hostElement, hostElementClassNames);
3129
adoptAttrs = type(adoptAttrs) == TYPES.s ? adoptAttrs.split(_strSpace) : adoptAttrs;
3130
if (COMPATIBILITY.isA(adoptAttrs) && _isTextarea) {
3131
each(adoptAttrs, function (i, v) {
3132
if (type(v) == TYPES.s) {
3133
adoptAttrsMap[v] = destroy ? _hostElement.attr(v) : _targetElement.attr(v);
3140
if (!_currentPreparedOptions.sizeAutoCapable) {
3141
hostElementCSS[_strWidth] = _targetElement.css(_strWidth);
3142
hostElementCSS[_strHeight] = _targetElement.css(_strHeight);
3146
_targetElement.addClass(_classNameTextInherit).wrap(_hostElement);
3149
_hostElement = _targetElement[strParent]().css(hostElementCSS);
3154
addClass(_targetElement, _isTextarea ? classNameTextareaElementFull : _classNameHostElement);
3157
_hostElement.wrapInner(_contentElement)
3158
.wrapInner(_viewportElement)
3159
.wrapInner(_paddingElement)
3160
.prepend(_sizeObserverElement);
3163
_contentElement = findFirst(_hostElement, _strDot + _classNameContentElement);
3164
_viewportElement = findFirst(_hostElement, _strDot + _classNameViewportElement);
3165
_paddingElement = findFirst(_hostElement, _strDot + _classNamePaddingElement);
3168
_contentElement.prepend(_textareaCoverElement);
3169
applyAdoptedAttrs();
3173
if (_nativeScrollbarStyling)
3174
addClass(_viewportElement, _classNameViewportNativeScrollbarsInvisible);
3175
if (_nativeScrollbarIsOverlaid.x && _nativeScrollbarIsOverlaid.y)
3176
addClass(_viewportElement, _classNameViewportNativeScrollbarsOverlaid);
3178
addClass(_htmlElement, _classNameHTMLElement);
3180
_sizeObserverElementNative = _sizeObserverElement[0];
3181
_hostElementNative = _hostElement[0];
3182
_paddingElementNative = _paddingElement[0];
3183
_viewportElementNative = _viewportElement[0];
3184
_contentElementNative = _contentElement[0];
3186
updateViewportAttrsFromTarget();
3189
if (_domExists && _initialized) {
3191
_sizeObserverElement.children().remove();
3194
each([_paddingElement, _viewportElement, _contentElement, _textareaCoverElement], function (i, elm) {
3196
removeClass(elm.removeAttr(LEXICON.s), _classNamesDynamicDestroy);
3201
addClass(_hostElement, _isTextarea ? _classNameHostTextareaElement : _classNameHostElement);
3205
remove(_sizeObserverElement);
3208
_contentElement.contents()
3214
_targetElement.unwrap();
3215
remove(_hostElement);
3216
remove(_textareaCoverElement);
3217
applyAdoptedAttrs();
3222
_targetElement.removeAttr(LEXICON.s);
3225
removeClass(_htmlElement, _classNameHTMLElement);
3233
function setupStructureEvents() {
3234
var textareaKeyDownRestrictedKeyCodes = [
3235
112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 123,
3238
16, 17, 18, 19, 20, 144
3240
var textareaKeyDownKeyCodesList = [];
3241
var textareaUpdateIntervalID;
3242
var scrollStopTimeoutId;
3243
var scrollStopDelay = 175;
3244
var strFocus = 'focus';
3246
function updateTextarea(doClearInterval) {
3248
_base.update(_strAuto);
3249
if (doClearInterval && _autoUpdateRecommended)
3250
clearInterval(textareaUpdateIntervalID);
3252
function textareaOnScroll(event) {
3253
_targetElement[_strScrollLeft](_rtlScrollBehavior.i && _normalizeRTLCache ? 9999999 : 0);
3254
_targetElement[_strScrollTop](0);
3255
COMPATIBILITY.prvD(event);
3256
COMPATIBILITY.stpP(event);
3259
function textareaOnDrop(event) {
3260
setTimeout(function () {
3265
function textareaOnFocus() {
3266
_textareaHasFocus = true;
3267
addClass(_hostElement, strFocus);
3269
function textareaOnFocusout() {
3270
_textareaHasFocus = false;
3271
textareaKeyDownKeyCodesList = [];
3272
removeClass(_hostElement, strFocus);
3273
updateTextarea(true);
3275
function textareaOnKeyDown(event) {
3276
var keyCode = event.keyCode;
3278
if (inArray(keyCode, textareaKeyDownRestrictedKeyCodes) < 0) {
3279
if (!textareaKeyDownKeyCodesList[LEXICON.l]) {
3281
textareaUpdateIntervalID = setInterval(updateTextarea, 1000 / 60);
3283
if (inArray(keyCode, textareaKeyDownKeyCodesList) < 0)
3284
textareaKeyDownKeyCodesList.push(keyCode);
3287
function textareaOnKeyUp(event) {
3288
var keyCode = event.keyCode;
3289
var index = inArray(keyCode, textareaKeyDownKeyCodesList);
3291
if (inArray(keyCode, textareaKeyDownRestrictedKeyCodes) < 0) {
3293
textareaKeyDownKeyCodesList.splice(index, 1);
3294
if (!textareaKeyDownKeyCodesList[LEXICON.l])
3295
updateTextarea(true);
3298
function contentOnTransitionEnd(event) {
3299
if (_autoUpdateCache === true)
3301
event = event.originalEvent || event;
3302
if (isSizeAffectingCSSProperty(event.propertyName))
3303
_base.update(_strAuto);
3305
function viewportOnScroll(event) {
3307
if (scrollStopTimeoutId !== undefined)
3308
clearTimeout(scrollStopTimeoutId);
3310
if (_scrollbarsAutoHideScroll || _scrollbarsAutoHideMove)
3311
refreshScrollbarsAutoHide(true);
3313
if (!nativeOverlayScrollbarsAreActive())
3314
addClass(_hostElement, _classNameHostScrolling);
3316
dispatchCallback('onScrollStart', event);
3322
if (!_scrollbarsHandlesDefineScrollPos) {
3323
refreshScrollbarHandleOffset(true);
3324
refreshScrollbarHandleOffset(false);
3326
dispatchCallback('onScroll', event);
3328
scrollStopTimeoutId = setTimeout(function () {
3331
clearTimeout(scrollStopTimeoutId);
3332
scrollStopTimeoutId = undefined;
3334
if (_scrollbarsAutoHideScroll || _scrollbarsAutoHideMove)
3335
refreshScrollbarsAutoHide(false);
3337
if (!nativeOverlayScrollbarsAreActive())
3338
removeClass(_hostElement, _classNameHostScrolling);
3340
dispatchCallback('onScrollStop', event);
3342
}, scrollStopDelay);
3348
if (_msieVersion > 9 || !_autoUpdateRecommended) {
3349
addDestroyEventListener(_targetElement, 'input', updateTextarea);
3352
addDestroyEventListener(_targetElement,
3353
[_strKeyDownEvent, _strKeyUpEvent],
3354
[textareaOnKeyDown, textareaOnKeyUp]);
3357
addDestroyEventListener(_targetElement,
3358
[_strScroll, 'drop', strFocus, strFocus + 'out'],
3359
[textareaOnScroll, textareaOnDrop, textareaOnFocus, textareaOnFocusout]);
3362
addDestroyEventListener(_contentElement, _strTransitionEndEvent, contentOnTransitionEnd);
3364
addDestroyEventListener(_viewportElement, _strScroll, viewportOnScroll, true);
3374
function setupScrollbarsDOM(destroy) {
3375
var selectOrGenerateScrollbarDOM = function (isHorizontal) {
3376
var scrollbarClassName = isHorizontal ? _classNameScrollbarHorizontal : _classNameScrollbarVertical;
3377
var scrollbar = selectOrGenerateDivByClass(_classNameScrollbar + _strSpace + scrollbarClassName, true);
3378
var track = selectOrGenerateDivByClass(_classNameScrollbarTrack, scrollbar);
3379
var handle = selectOrGenerateDivByClass(_classNameScrollbarHandle, scrollbar);
3381
if (!_domExists && !destroy) {
3382
scrollbar.append(track);
3383
track.append(handle);
3387
_scrollbar: scrollbar,
3392
function resetScrollbarDOM(isHorizontal) {
3393
var scrollbarVars = getScrollbarVars(isHorizontal);
3394
var scrollbar = scrollbarVars._scrollbar;
3395
var track = scrollbarVars._track;
3396
var handle = scrollbarVars._handle;
3398
if (_domExists && _initialized) {
3399
each([scrollbar, track, handle], function (i, elm) {
3400
removeClass(elm.removeAttr(LEXICON.s), _classNamesDynamicDestroy);
3404
remove(scrollbar || selectOrGenerateScrollbarDOM(isHorizontal)._scrollbar);
3407
var horizontalElements;
3408
var verticalElements;
3411
horizontalElements = selectOrGenerateScrollbarDOM(true);
3412
verticalElements = selectOrGenerateScrollbarDOM();
3414
_scrollbarHorizontalElement = horizontalElements._scrollbar;
3415
_scrollbarHorizontalTrackElement = horizontalElements._track;
3416
_scrollbarHorizontalHandleElement = horizontalElements._handle;
3417
_scrollbarVerticalElement = verticalElements._scrollbar;
3418
_scrollbarVerticalTrackElement = verticalElements._track;
3419
_scrollbarVerticalHandleElement = verticalElements._handle;
3422
_paddingElement.after(_scrollbarVerticalElement);
3423
_paddingElement.after(_scrollbarHorizontalElement);
3427
resetScrollbarDOM(true);
3428
resetScrollbarDOM();
3436
function setupScrollbarEvents(isHorizontal) {
3437
var scrollbarVars = getScrollbarVars(isHorizontal);
3438
var scrollbarVarsInfo = scrollbarVars._info;
3439
var insideIFrame = _windowElementNative.top !== _windowElementNative;
3440
var xy = scrollbarVars._x_y;
3441
var XY = scrollbarVars._X_Y;
3442
var scroll = _strScroll + scrollbarVars._Left_Top;
3443
var strActive = 'active';
3444
var strSnapHandle = 'snapHandle';
3445
var strClickEvent = 'click';
3446
var scrollDurationFactor = 1;
3447
var increaseDecreaseScrollAmountKeyCodes = [16, 17];
3449
var mouseDownScroll;
3450
var mouseDownOffset;
3451
var mouseDownInvertedScale;
3453
function getPointerPosition(event) {
3454
return _msieVersion && insideIFrame ? event['screen' + XY] : COMPATIBILITY.page(event)[xy];
3456
function getPreparedScrollbarsOption(name) {
3457
return _currentPreparedOptions.scrollbars[name];
3459
function increaseTrackScrollAmount() {
3460
scrollDurationFactor = 0.5;
3462
function decreaseTrackScrollAmount() {
3463
scrollDurationFactor = 1;
3465
function stopClickEventPropagation(event) {
3466
COMPATIBILITY.stpP(event);
3468
function documentKeyDown(event) {
3469
if (inArray(event.keyCode, increaseDecreaseScrollAmountKeyCodes) > -1)
3470
increaseTrackScrollAmount();
3472
function documentKeyUp(event) {
3473
if (inArray(event.keyCode, increaseDecreaseScrollAmountKeyCodes) > -1)
3474
decreaseTrackScrollAmount();
3476
function onMouseTouchDownContinue(event) {
3477
var originalEvent = event.originalEvent || event;
3478
var isTouchEvent = originalEvent.touches !== undefined;
3479
return _sleeping || _destroyed || nativeOverlayScrollbarsAreActive() || !_scrollbarsDragScrollingCache || (isTouchEvent && !getPreparedScrollbarsOption('touchSupport')) ? false : COMPATIBILITY.mBtn(event) === 1 || isTouchEvent;
3481
function documentDragMove(event) {
3482
if (onMouseTouchDownContinue(event)) {
3483
var trackLength = scrollbarVarsInfo._trackLength;
3484
var handleLength = scrollbarVarsInfo._handleLength;
3485
var scrollRange = scrollbarVarsInfo._maxScroll;
3486
var scrollRaw = (getPointerPosition(event) - mouseDownOffset) * mouseDownInvertedScale;
3487
var scrollDeltaPercent = scrollRaw / (trackLength - handleLength);
3488
var scrollDelta = (scrollRange * scrollDeltaPercent);
3489
scrollDelta = isFinite(scrollDelta) ? scrollDelta : 0;
3490
if (_isRTL && isHorizontal && !_rtlScrollBehavior.i)
3493
_viewportElement[scroll](MATH.round(mouseDownScroll + scrollDelta));
3495
if (_scrollbarsHandlesDefineScrollPos)
3496
refreshScrollbarHandleOffset(isHorizontal, mouseDownScroll + scrollDelta);
3498
if (!_supportPassiveEvents)
3499
COMPATIBILITY.prvD(event);
3502
documentMouseTouchUp(event);
3504
function documentMouseTouchUp(event) {
3505
event = event || event.originalEvent;
3507
setupResponsiveEventListener(_documentElement,
3508
[_strMouseTouchMoveEvent, _strMouseTouchUpEvent, _strKeyDownEvent, _strKeyUpEvent, _strSelectStartEvent],
3509
[documentDragMove, documentMouseTouchUp, documentKeyDown, documentKeyUp, documentOnSelectStart],
3511
COMPATIBILITY.rAF()(function() {
3512
setupResponsiveEventListener(_documentElement, strClickEvent, stopClickEventPropagation, true, { _capture: true });
3516
if (_scrollbarsHandlesDefineScrollPos)
3517
refreshScrollbarHandleOffset(isHorizontal, true);
3519
_scrollbarsHandlesDefineScrollPos = false;
3520
removeClass(_bodyElement, _classNameDragging);
3521
removeClass(scrollbarVars._handle, strActive);
3522
removeClass(scrollbarVars._track, strActive);
3523
removeClass(scrollbarVars._scrollbar, strActive);
3525
mouseDownScroll = undefined;
3526
mouseDownOffset = undefined;
3527
mouseDownInvertedScale = 1;
3529
decreaseTrackScrollAmount();
3531
if (trackTimeout !== undefined) {
3533
clearTimeout(trackTimeout);
3534
trackTimeout = undefined;
3538
var rect = _hostElementNative[LEXICON.bCR]();
3539
var mouseInsideHost = event.clientX >= rect.left && event.clientX <= rect.right && event.clientY >= rect.top && event.clientY <= rect.bottom;
3542
if (!mouseInsideHost)
3545
if (_scrollbarsAutoHideScroll || _scrollbarsAutoHideMove)
3546
refreshScrollbarsAutoHide(false);
3549
function onHandleMouseTouchDown(event) {
3550
if (onMouseTouchDownContinue(event))
3551
onHandleMouseTouchDownAction(event);
3553
function onHandleMouseTouchDownAction(event) {
3554
mouseDownScroll = _viewportElement[scroll]();
3555
mouseDownScroll = isNaN(mouseDownScroll) ? 0 : mouseDownScroll;
3556
if (_isRTL && isHorizontal && !_rtlScrollBehavior.n || !_isRTL)
3557
mouseDownScroll = mouseDownScroll < 0 ? 0 : mouseDownScroll;
3559
mouseDownInvertedScale = getHostElementInvertedScale()[xy];
3560
mouseDownOffset = getPointerPosition(event);
3562
_scrollbarsHandlesDefineScrollPos = !getPreparedScrollbarsOption(strSnapHandle);
3563
addClass(_bodyElement, _classNameDragging);
3564
addClass(scrollbarVars._handle, strActive);
3565
addClass(scrollbarVars._scrollbar, strActive);
3567
setupResponsiveEventListener(_documentElement,
3568
[_strMouseTouchMoveEvent, _strMouseTouchUpEvent, _strSelectStartEvent],
3569
[documentDragMove, documentMouseTouchUp, documentOnSelectStart]);
3570
COMPATIBILITY.rAF()(function() {
3571
setupResponsiveEventListener(_documentElement, strClickEvent, stopClickEventPropagation, false, { _capture: true });
3575
if (_msieVersion || !_documentMixed)
3576
COMPATIBILITY.prvD(event);
3577
COMPATIBILITY.stpP(event);
3579
function onTrackMouseTouchDown(event) {
3580
if (onMouseTouchDownContinue(event)) {
3581
var handleToViewportRatio = scrollbarVars._info._handleLength / Math.round(MATH.min(1, _viewportSize[scrollbarVars._w_h] / _contentScrollSizeCache[scrollbarVars._w_h]) * scrollbarVars._info._trackLength);
3582
var scrollDistance = MATH.round(_viewportSize[scrollbarVars._w_h] * handleToViewportRatio);
3583
var scrollBaseDuration = 270 * handleToViewportRatio;
3584
var scrollFirstIterationDelay = 400 * handleToViewportRatio;
3585
var trackOffset = scrollbarVars._track.offset()[scrollbarVars._left_top];
3586
var ctrlKey = event.ctrlKey;
3587
var instantScroll = event.shiftKey;
3588
var instantScrollTransition = instantScroll && ctrlKey;
3589
var isFirstIteration = true;
3590
var easing = 'linear';
3592
var finishedCondition;
3593
var scrollActionFinsished = function (transition) {
3594
if (_scrollbarsHandlesDefineScrollPos)
3595
refreshScrollbarHandleOffset(isHorizontal, transition);
3597
var scrollActionInstantFinished = function () {
3598
scrollActionFinsished();
3599
onHandleMouseTouchDownAction(event);
3601
var scrollAction = function () {
3603
var mouseOffset = (mouseDownOffset - trackOffset) * mouseDownInvertedScale;
3604
var handleOffset = scrollbarVarsInfo._handleOffset;
3605
var trackLength = scrollbarVarsInfo._trackLength;
3606
var handleLength = scrollbarVarsInfo._handleLength;
3607
var scrollRange = scrollbarVarsInfo._maxScroll;
3608
var currScroll = scrollbarVarsInfo._currentScroll;
3609
var scrollDuration = scrollBaseDuration * scrollDurationFactor;
3610
var timeoutDelay = isFirstIteration ? MATH.max(scrollFirstIterationDelay, scrollDuration) : scrollDuration;
3611
var instantScrollPosition = scrollRange * ((mouseOffset - (handleLength / 2)) / (trackLength - handleLength));
3612
var rtlIsNormal = _isRTL && isHorizontal && ((!_rtlScrollBehavior.i && !_rtlScrollBehavior.n) || _normalizeRTLCache);
3613
var decreaseScrollCondition = rtlIsNormal ? handleOffset < mouseOffset : handleOffset > mouseOffset;
3615
var animationObj = {
3617
step: function (now) {
3618
if (_scrollbarsHandlesDefineScrollPos) {
3619
_viewportElement[scroll](now);
3620
refreshScrollbarHandleOffset(isHorizontal, now);
3624
instantScrollPosition = isFinite(instantScrollPosition) ? instantScrollPosition : 0;
3625
instantScrollPosition = _isRTL && isHorizontal && !_rtlScrollBehavior.i ? (scrollRange - instantScrollPosition) : instantScrollPosition;
3629
if (instantScroll) {
3630
_viewportElement[scroll](instantScrollPosition);
3631
if (instantScrollTransition) {
3634
instantScrollPosition = _viewportElement[scroll]();
3636
_viewportElement[scroll](currScroll);
3638
instantScrollPosition = rtlIsNormal && _rtlScrollBehavior.i ? (scrollRange - instantScrollPosition) : instantScrollPosition;
3639
instantScrollPosition = rtlIsNormal && _rtlScrollBehavior.n ? -instantScrollPosition : instantScrollPosition;
3641
scrollObj[xy] = instantScrollPosition;
3642
_base.scroll(scrollObj, extendDeep(animationObj, {
3644
complete: scrollActionInstantFinished
3648
scrollActionInstantFinished();
3651
decreaseScroll = isFirstIteration ? decreaseScrollCondition : decreaseScroll;
3652
finishedCondition = rtlIsNormal
3653
? (decreaseScroll ? handleOffset + handleLength >= mouseOffset : handleOffset <= mouseOffset)
3654
: (decreaseScroll ? handleOffset <= mouseOffset : handleOffset + handleLength >= mouseOffset);
3656
if (finishedCondition) {
3657
clearTimeout(trackTimeout);
3659
trackTimeout = undefined;
3660
scrollActionFinsished(true);
3663
trackTimeout = setTimeout(scrollAction, timeoutDelay);
3665
scrollObj[xy] = (decreaseScroll ? '-=' : '+=') + scrollDistance;
3666
_base.scroll(scrollObj, extendDeep(animationObj, {
3667
duration: scrollDuration
3670
isFirstIteration = false;
3675
increaseTrackScrollAmount();
3677
mouseDownInvertedScale = getHostElementInvertedScale()[xy];
3678
mouseDownOffset = COMPATIBILITY.page(event)[xy];
3680
_scrollbarsHandlesDefineScrollPos = !getPreparedScrollbarsOption(strSnapHandle);
3681
addClass(_bodyElement, _classNameDragging);
3682
addClass(scrollbarVars._track, strActive);
3683
addClass(scrollbarVars._scrollbar, strActive);
3685
setupResponsiveEventListener(_documentElement,
3686
[_strMouseTouchUpEvent, _strKeyDownEvent, _strKeyUpEvent, _strSelectStartEvent],
3687
[documentMouseTouchUp, documentKeyDown, documentKeyUp, documentOnSelectStart]);
3690
COMPATIBILITY.prvD(event);
3691
COMPATIBILITY.stpP(event);
3694
function onTrackMouseTouchEnter(event) {
3696
_scrollbarsHandleHovered = true;
3697
if (_scrollbarsAutoHideScroll || _scrollbarsAutoHideMove)
3698
refreshScrollbarsAutoHide(true);
3700
function onTrackMouseTouchLeave(event) {
3701
_scrollbarsHandleHovered = false;
3702
if (_scrollbarsAutoHideScroll || _scrollbarsAutoHideMove)
3703
refreshScrollbarsAutoHide(false);
3705
function onScrollbarMouseTouchDown(event) {
3706
COMPATIBILITY.stpP(event);
3709
addDestroyEventListener(scrollbarVars._handle,
3710
_strMouseTouchDownEvent,
3711
onHandleMouseTouchDown);
3712
addDestroyEventListener(scrollbarVars._track,
3713
[_strMouseTouchDownEvent, _strMouseEnter, _strMouseLeave],
3714
[onTrackMouseTouchDown, onTrackMouseTouchEnter, onTrackMouseTouchLeave]);
3715
addDestroyEventListener(scrollbarVars._scrollbar,
3716
_strMouseTouchDownEvent,
3717
onScrollbarMouseTouchDown);
3719
if (_supportTransition) {
3720
addDestroyEventListener(scrollbarVars._scrollbar, _strTransitionEndEvent, function (event) {
3721
if (event.target !== scrollbarVars._scrollbar[0])
3723
refreshScrollbarHandleLength(isHorizontal);
3724
refreshScrollbarHandleOffset(isHorizontal);
3735
function refreshScrollbarAppearance(isHorizontal, shallBeVisible, canScroll) {
3736
var scrollbarHiddenClassName = isHorizontal ? _classNameHostScrollbarHorizontalHidden : _classNameHostScrollbarVerticalHidden;
3737
var scrollbarElement = isHorizontal ? _scrollbarHorizontalElement : _scrollbarVerticalElement;
3739
addRemoveClass(_hostElement, scrollbarHiddenClassName, !shallBeVisible);
3740
addRemoveClass(scrollbarElement, _classNameScrollbarUnusable, !canScroll);
3748
function refreshScrollbarsAutoHide(shallBeVisible, delayfree) {
3749
clearTimeout(_scrollbarsAutoHideTimeoutId);
3750
if (shallBeVisible) {
3752
removeClass(_scrollbarHorizontalElement, _classNameScrollbarAutoHidden);
3754
removeClass(_scrollbarVerticalElement, _classNameScrollbarAutoHidden);
3758
var strActive = 'active';
3759
var hide = function () {
3760
if (!_scrollbarsHandleHovered && !_destroyed) {
3761
anyActive = _scrollbarHorizontalHandleElement.hasClass(strActive) || _scrollbarVerticalHandleElement.hasClass(strActive);
3762
if (!anyActive && (_scrollbarsAutoHideScroll || _scrollbarsAutoHideMove || _scrollbarsAutoHideLeave))
3763
addClass(_scrollbarHorizontalElement, _classNameScrollbarAutoHidden);
3764
if (!anyActive && (_scrollbarsAutoHideScroll || _scrollbarsAutoHideMove || _scrollbarsAutoHideLeave))
3765
addClass(_scrollbarVerticalElement, _classNameScrollbarAutoHidden);
3768
if (_scrollbarsAutoHideDelay > 0 && delayfree !== true)
3769
_scrollbarsAutoHideTimeoutId = setTimeout(hide, _scrollbarsAutoHideDelay);
3779
function refreshScrollbarHandleLength(isHorizontal) {
3781
var scrollbarVars = getScrollbarVars(isHorizontal);
3782
var scrollbarVarsInfo = scrollbarVars._info;
3783
var digit = 1000000;
3785
var handleRatio = MATH.min(1, _viewportSize[scrollbarVars._w_h] / _contentScrollSizeCache[scrollbarVars._w_h]);
3786
handleCSS[scrollbarVars._width_height] = (MATH.floor(handleRatio * 100 * digit) / digit) + '%';
3788
if (!nativeOverlayScrollbarsAreActive())
3789
scrollbarVars._handle.css(handleCSS);
3792
scrollbarVarsInfo._handleLength = scrollbarVars._handle[0]['offset' + scrollbarVars._Width_Height];
3793
scrollbarVarsInfo._handleLengthRatio = handleRatio;
3801
function refreshScrollbarHandleOffset(isHorizontal, scrollOrTransition) {
3802
var transition = type(scrollOrTransition) == TYPES.b;
3803
var transitionDuration = 250;
3804
var isRTLisHorizontal = _isRTL && isHorizontal;
3805
var scrollbarVars = getScrollbarVars(isHorizontal);
3806
var scrollbarVarsInfo = scrollbarVars._info;
3807
var strTranslateBrace = 'translate(';
3808
var strTransform = VENDORS._cssProperty('transform');
3809
var strTransition = VENDORS._cssProperty('transition');
3810
var nativeScroll = isHorizontal ? _viewportElement[_strScrollLeft]() : _viewportElement[_strScrollTop]();
3811
var currentScroll = scrollOrTransition === undefined || transition ? nativeScroll : scrollOrTransition;
3814
var handleLength = scrollbarVarsInfo._handleLength;
3815
var trackLength = scrollbarVars._track[0]['offset' + scrollbarVars._Width_Height];
3816
var handleTrackDiff = trackLength - handleLength;
3818
var transformOffset;
3824
var maxScroll = (_viewportElementNative[_strScroll + scrollbarVars._Width_Height] - _viewportElementNative['client' + scrollbarVars._Width_Height]) * (_rtlScrollBehavior.n && isRTLisHorizontal ? -1 : 1);
3825
var getScrollRatio = function (base) {
3826
return isNaN(base / maxScroll) ? 0 : MATH.max(0, MATH.min(1, base / maxScroll));
3828
var getHandleOffset = function (scrollRatio) {
3829
var offset = handleTrackDiff * scrollRatio;
3830
offset = isNaN(offset) ? 0 : offset;
3831
offset = (isRTLisHorizontal && !_rtlScrollBehavior.i) ? (trackLength - handleLength - offset) : offset;
3832
offset = MATH.max(0, offset);
3835
var scrollRatio = getScrollRatio(nativeScroll);
3836
var unsnappedScrollRatio = getScrollRatio(currentScroll);
3837
var handleOffset = getHandleOffset(unsnappedScrollRatio);
3838
var snappedHandleOffset = getHandleOffset(scrollRatio);
3840
scrollbarVarsInfo._maxScroll = maxScroll;
3841
scrollbarVarsInfo._currentScroll = nativeScroll;
3842
scrollbarVarsInfo._currentScrollRatio = scrollRatio;
3844
if (_supportTransform) {
3845
transformOffset = isRTLisHorizontal ? -(trackLength - handleLength - handleOffset) : handleOffset;
3847
translateValue = isHorizontal ? strTranslateBrace + transformOffset + 'px, 0)' : strTranslateBrace + '0, ' + transformOffset + 'px)';
3849
handleCSS[strTransform] = translateValue;
3852
if (_supportTransition)
3853
handleCSS[strTransition] = transition && MATH.abs(handleOffset - scrollbarVarsInfo._handleOffset) > 1 ? getCSSTransitionString(scrollbarVars._handle) + ', ' + (strTransform + _strSpace + transitionDuration + 'ms') : _strEmpty;
3856
handleCSS[scrollbarVars._left_top] = handleOffset;
3860
if (!nativeOverlayScrollbarsAreActive()) {
3861
scrollbarVars._handle.css(handleCSS);
3864
if (_supportTransform && _supportTransition && transition) {
3865
scrollbarVars._handle.one(_strTransitionEndEvent, function () {
3867
scrollbarVars._handle.css(strTransition, _strEmpty);
3872
scrollbarVarsInfo._handleOffset = handleOffset;
3873
scrollbarVarsInfo._snappedHandleOffset = snappedHandleOffset;
3874
scrollbarVarsInfo._trackLength = trackLength;
3882
function refreshScrollbarsInteractive(isTrack, value) {
3883
var action = value ? 'removeClass' : 'addClass';
3884
var element1 = isTrack ? _scrollbarHorizontalTrackElement : _scrollbarHorizontalHandleElement;
3885
var element2 = isTrack ? _scrollbarVerticalTrackElement : _scrollbarVerticalHandleElement;
3886
var className = isTrack ? _classNameScrollbarTrackOff : _classNameScrollbarHandleOff;
3888
element1[action](className);
3889
element2[action](className);
3897
function getScrollbarVars(isHorizontal) {
3899
_width_height: isHorizontal ? _strWidth : _strHeight,
3900
_Width_Height: isHorizontal ? 'Width' : 'Height',
3901
_left_top: isHorizontal ? _strLeft : _strTop,
3902
_Left_Top: isHorizontal ? 'Left' : 'Top',
3903
_x_y: isHorizontal ? _strX : _strY,
3904
_X_Y: isHorizontal ? 'X' : 'Y',
3905
_w_h: isHorizontal ? 'w' : 'h',
3906
_l_t: isHorizontal ? 'l' : 't',
3907
_track: isHorizontal ? _scrollbarHorizontalTrackElement : _scrollbarVerticalTrackElement,
3908
_handle: isHorizontal ? _scrollbarHorizontalHandleElement : _scrollbarVerticalHandleElement,
3909
_scrollbar: isHorizontal ? _scrollbarHorizontalElement : _scrollbarVerticalElement,
3910
_info: isHorizontal ? _scrollHorizontalInfo : _scrollVerticalInfo
3921
function setupScrollbarCornerDOM(destroy) {
3922
_scrollbarCornerElement = _scrollbarCornerElement || selectOrGenerateDivByClass(_classNameScrollbarCorner, true);
3926
_hostElement.append(_scrollbarCornerElement);
3930
if (_domExists && _initialized) {
3931
removeClass(_scrollbarCornerElement.removeAttr(LEXICON.s), _classNamesDynamicDestroy);
3934
remove(_scrollbarCornerElement);
3942
function setupScrollbarCornerEvents() {
3943
var insideIFrame = _windowElementNative.top !== _windowElementNative;
3944
var mouseDownPosition = {};
3945
var mouseDownSize = {};
3946
var mouseDownInvertedScale = {};
3947
var reconnectMutationObserver;
3949
function documentDragMove(event) {
3950
if (onMouseTouchDownContinue(event)) {
3951
var pageOffset = getCoordinates(event);
3952
var hostElementCSS = {};
3953
if (_resizeHorizontal || _resizeBoth)
3954
hostElementCSS[_strWidth] = (mouseDownSize.w + (pageOffset.x - mouseDownPosition.x) * mouseDownInvertedScale.x);
3955
if (_resizeVertical || _resizeBoth)
3956
hostElementCSS[_strHeight] = (mouseDownSize.h + (pageOffset.y - mouseDownPosition.y) * mouseDownInvertedScale.y);
3957
_hostElement.css(hostElementCSS);
3958
COMPATIBILITY.stpP(event);
3961
documentMouseTouchUp(event);
3964
function documentMouseTouchUp(event) {
3965
var eventIsTrusted = event !== undefined;
3967
setupResponsiveEventListener(_documentElement,
3968
[_strSelectStartEvent, _strMouseTouchMoveEvent, _strMouseTouchUpEvent],
3969
[documentOnSelectStart, documentDragMove, documentMouseTouchUp],
3972
removeClass(_bodyElement, _classNameDragging);
3973
if (_scrollbarCornerElement.releaseCapture)
3974
_scrollbarCornerElement.releaseCapture();
3976
if (eventIsTrusted) {
3977
if (reconnectMutationObserver)
3978
connectMutationObservers();
3979
_base.update(_strAuto);
3981
reconnectMutationObserver = false;
3983
function onMouseTouchDownContinue(event) {
3984
var originalEvent = event.originalEvent || event;
3985
var isTouchEvent = originalEvent.touches !== undefined;
3986
return _sleeping || _destroyed ? false : COMPATIBILITY.mBtn(event) === 1 || isTouchEvent;
3988
function getCoordinates(event) {
3989
return _msieVersion && insideIFrame ? { x: event.screenX, y: event.screenY } : COMPATIBILITY.page(event);
3992
addDestroyEventListener(_scrollbarCornerElement, _strMouseTouchDownEvent, function (event) {
3993
if (onMouseTouchDownContinue(event) && !_resizeNone) {
3994
if (_mutationObserversConnected) {
3995
reconnectMutationObserver = true;
3996
disconnectMutationObservers();
3999
mouseDownPosition = getCoordinates(event);
4001
mouseDownSize.w = _hostElementNative[LEXICON.oW] - (!_isBorderBox ? _paddingX : 0);
4002
mouseDownSize.h = _hostElementNative[LEXICON.oH] - (!_isBorderBox ? _paddingY : 0);
4003
mouseDownInvertedScale = getHostElementInvertedScale();
4005
setupResponsiveEventListener(_documentElement,
4006
[_strSelectStartEvent, _strMouseTouchMoveEvent, _strMouseTouchUpEvent],
4007
[documentOnSelectStart, documentDragMove, documentMouseTouchUp]);
4009
addClass(_bodyElement, _classNameDragging);
4010
if (_scrollbarCornerElement.setCapture)
4011
_scrollbarCornerElement.setCapture();
4013
COMPATIBILITY.prvD(event);
4014
COMPATIBILITY.stpP(event);
4028
function dispatchCallback(name, args, dependent) {
4029
if (dependent === false)
4032
var callback = _currentPreparedOptions.callbacks[name];
4033
var extensionOnName = name;
4036
if (extensionOnName.substr(0, 2) === 'on')
4037
extensionOnName = extensionOnName.substr(2, 1).toLowerCase() + extensionOnName.substr(3);
4039
if (type(callback) == TYPES.f)
4040
callback.call(_base, args);
4042
each(_extensions, function () {
4044
if (type(ext.on) == TYPES.f)
4045
ext.on(extensionOnName, args);
4048
else if (!_destroyed)
4049
_callbacksInitQeueue.push({ n: name, a: args });
4059
function setTopRightBottomLeft(targetCSSObject, prefix, values) {
4060
prefix = prefix || _strEmpty;
4061
values = values || [_strEmpty, _strEmpty, _strEmpty, _strEmpty];
4063
targetCSSObject[prefix + _strTop] = values[0];
4064
targetCSSObject[prefix + _strRight] = values[1];
4065
targetCSSObject[prefix + _strBottom] = values[2];
4066
targetCSSObject[prefix + _strLeft] = values[3];
4077
function getTopRightBottomLeftHost(prefix, suffix, zeroX, zeroY) {
4078
suffix = suffix || _strEmpty;
4079
prefix = prefix || _strEmpty;
4081
t: zeroY ? 0 : parseToZeroOrNumber(_hostElement.css(prefix + _strTop + suffix)),
4082
r: zeroX ? 0 : parseToZeroOrNumber(_hostElement.css(prefix + _strRight + suffix)),
4083
b: zeroY ? 0 : parseToZeroOrNumber(_hostElement.css(prefix + _strBottom + suffix)),
4084
l: zeroX ? 0 : parseToZeroOrNumber(_hostElement.css(prefix + _strLeft + suffix))
4093
function getCSSTransitionString(element) {
4094
var transitionStr = VENDORS._cssProperty('transition');
4095
var assembledValue = element.css(transitionStr);
4097
return assembledValue;
4098
var regExpString = '\\s*(' + '([^,(]+(\\(.+?\\))?)+' + ')[\\s,]*';
4099
var regExpMain = new RegExp(regExpString);
4100
var regExpValidate = new RegExp('^(' + regExpString + ')+$');
4101
var properties = 'property duration timing-function delay'.split(' ');
4107
var splitCssStyleByComma = function (str) {
4109
if (!str.match(regExpValidate))
4111
while (str.match(regExpMain)) {
4112
strResult.push(RegExp.$1);
4113
str = str.replace(regExpMain, _strEmpty);
4118
for (; i < properties[LEXICON.l]; i++) {
4119
valueArray = splitCssStyleByComma(element.css(transitionStr + '-' + properties[i]));
4120
for (j = 0; j < valueArray[LEXICON.l]; j++)
4121
result[j] = (result[j] ? result[j] + _strSpace : _strEmpty) + valueArray[j];
4123
return result.join(', ');
4131
function createHostClassNameRegExp(withCurrClassNameOption, withOldClassNameOption) {
4135
var appendClasses = function (classes, condition) {
4137
if (condition && typeof classes == TYPES.s) {
4138
split = classes.split(_strSpace);
4139
for (i = 0; i < split[LEXICON.l]; i++)
4140
appendix += '|' + split[i] + '$';
4147
'(^' + _classNameHostElement + '([-_].+|)$)' +
4148
appendClasses(_classNameCache, withCurrClassNameOption) +
4149
appendClasses(_oldClassName, withOldClassNameOption), 'g');
4156
function getHostElementInvertedScale() {
4157
var rect = _paddingElementNative[LEXICON.bCR]();
4159
x: _supportTransform ? 1 / (MATH.round(rect.width) / _paddingElementNative[LEXICON.oW]) || 1 : 1,
4160
y: _supportTransform ? 1 / (MATH.round(rect.height) / _paddingElementNative[LEXICON.oH]) || 1 : 1
4169
function isHTMLElement(o) {
4170
var strOwnerDocument = 'ownerDocument';
4171
var strHTMLElement = 'HTMLElement';
4172
var wnd = o && o[strOwnerDocument] ? (o[strOwnerDocument].parentWindow || window) : window;
4174
typeof wnd[strHTMLElement] == TYPES.o ? o instanceof wnd[strHTMLElement] :
4175
o && typeof o == TYPES.o && o !== null && o.nodeType === 1 && typeof o.nodeName == TYPES.s
4185
function getArrayDifferences(a1, a2) {
4190
for (i = 0; i < a1.length; i++)
4192
for (i = 0; i < a2.length; i++) {
4208
function parseToZeroOrNumber(value, toFloat) {
4209
var num = toFloat ? parseFloat(value) : parseInt(value, 10);
4210
return isNaN(num) ? 0 : num;
4217
function getTextareaInfo() {
4219
var textareaCursorPosition = _targetElementNative.selectionStart;
4220
if (textareaCursorPosition === undefined)
4223
var textareaValue = _targetElement.val();
4224
var textareaLength = textareaValue[LEXICON.l];
4225
var textareaRowSplit = textareaValue.split('\n');
4226
var textareaLastRow = textareaRowSplit[LEXICON.l];
4227
var textareaCurrentCursorRowSplit = textareaValue.substr(0, textareaCursorPosition).split('\n');
4229
var textareaLastCol = 0;
4230
var cursorRow = textareaCurrentCursorRowSplit[LEXICON.l];
4231
var cursorCol = textareaCurrentCursorRowSplit[textareaCurrentCursorRowSplit[LEXICON.l] - 1][LEXICON.l];
4236
for (i = 0; i < textareaRowSplit[LEXICON.l]; i++) {
4237
rowCols = textareaRowSplit[i][LEXICON.l];
4238
if (rowCols > textareaLastCol) {
4240
textareaLastCol = rowCols;
4245
_cursorRow: cursorRow,
4246
_cursorColumn: cursorCol,
4247
_rows: textareaLastRow,
4248
_columns: textareaLastCol,
4249
_widestRow: widestRow,
4250
_cursorPosition: textareaCursorPosition,
4251
_cursorMax: textareaLength
4259
function nativeOverlayScrollbarsAreActive() {
4260
return (_ignoreOverlayScrollbarHidingCache && (_nativeScrollbarIsOverlaid.x && _nativeScrollbarIsOverlaid.y));
4267
function getContentMeasureElement() {
4268
return _isTextarea ? _textareaCoverElement[0] : _contentElementNative;
4277
function generateDiv(classesOrAttrs, content) {
4278
return '<div ' + (classesOrAttrs ? type(classesOrAttrs) == TYPES.s ?
4279
'class="' + classesOrAttrs + '"' :
4282
var attrs = _strEmpty;
4283
if (FRAMEWORK.isPlainObject(classesOrAttrs)) {
4284
for (key in classesOrAttrs)
4285
attrs += (key === 'c' ? 'class' : key) + '="' + classesOrAttrs[key] + '" ';
4291
(content || _strEmpty) +
4302
function selectOrGenerateDivByClass(className, selectParentOrOnlyChildren) {
4303
var onlyChildren = type(selectParentOrOnlyChildren) == TYPES.b;
4304
var selectParent = onlyChildren ? _hostElement : (selectParentOrOnlyChildren || _hostElement);
4306
return (_domExists && !selectParent[LEXICON.l])
4309
? selectParent[onlyChildren ? 'children' : 'find'](_strDot + className.replace(/\s/g, _strDot)).eq(0)
4310
: FRAMEWORK(generateDiv(className))
4319
function getObjectPropVal(obj, path) {
4320
var splits = path.split(_strDot);
4323
for (; i < splits.length; i++) {
4324
if (!obj[LEXICON.hOP](splits[i]))
4326
val = obj[splits[i]];
4327
if (i < splits.length && type(val) == TYPES.o)
4339
function setObjectPropVal(obj, path, val) {
4340
var splits = path.split(_strDot);
4341
var splitsLength = splits.length;
4344
var extendObjRoot = extendObj;
4345
for (; i < splitsLength; i++)
4346
extendObj = extendObj[splits[i]] = i + 1 < splitsLength ? {} : val;
4347
FRAMEWORK.extend(obj, extendObjRoot, true);
4354
function eachUpdateOnLoad(action) {
4355
var updateOnLoad = _currentPreparedOptions.updateOnLoad;
4356
updateOnLoad = type(updateOnLoad) == TYPES.s ? updateOnLoad.split(_strSpace) : updateOnLoad;
4358
if (COMPATIBILITY.isA(updateOnLoad) && !_destroyed) {
4359
each(updateOnLoad, action);
4373
function checkCache(current, cache, force) {
4376
if (type(current) == TYPES.o && type(cache) == TYPES.o) {
4377
for (var prop in current) {
4379
if (current[LEXICON.hOP](prop) && cache[LEXICON.hOP](prop)) {
4380
if (checkCache(current[prop], cache[prop]))
4390
return current !== cache;
4401
function extendDeep() {
4402
return FRAMEWORK.extend.apply(this, [true].concat([].slice.call(arguments)));
4408
function addClass(el, classes) {
4409
return _frameworkProto.addClass.call(el, classes);
4415
function removeClass(el, classes) {
4416
return _frameworkProto.removeClass.call(el, classes);
4422
function addRemoveClass(el, classes, doAdd) {
4423
return doAdd ? addClass(el, classes) : removeClass(el, classes);
4429
function remove(el) {
4430
return _frameworkProto.remove.call(el);
4439
function findFirst(el, selector) {
4440
return _frameworkProto.find.call(el, selector).eq(0);
4450
_base.sleep = function () {
4467
_base.update = function (force) {
4473
var isString = type(force) == TYPES.s;
4479
if (force === _strAuto) {
4480
attrsChanged = meaningfulAttrsChanged();
4481
contentSizeC = updateAutoContentSizeChanged();
4482
doUpdateAuto = attrsChanged || contentSizeC;
4485
_contentSizeChanged: contentSizeC,
4486
_changedOptions: _initialized ? undefined : _currentPreparedOptions
4490
else if (force === _strSync) {
4491
if (_mutationObserversConnected) {
4492
mutHost = _mutationObserverHostCallback(_mutationObserverHost.takeRecords());
4493
mutContent = _mutationObserverContentCallback(_mutationObserverContent.takeRecords());
4496
mutHost = _base.update(_strAuto);
4499
else if (force === 'zoom') {
4501
_hostSizeChanged: true,
4502
_contentSizeChanged: true
4507
force = _sleeping || force;
4509
if (!_base.update(_strSync) || force)
4510
update({ _force: force });
4513
updateElementsOnLoad();
4515
return doUpdateAuto || mutHost || mutContent;
4524
_base.options = function (newOptions, value) {
4529
if (FRAMEWORK.isEmptyObject(newOptions) || !FRAMEWORK.isPlainObject(newOptions)) {
4530
if (type(newOptions) == TYPES.s) {
4531
if (arguments.length > 1) {
4532
setObjectPropVal(option, newOptions, value);
4533
changedOps = setOptions(option);
4536
return getObjectPropVal(_currentOptions, newOptions);
4539
return _currentOptions;
4542
changedOps = setOptions(newOptions);
4545
if (!FRAMEWORK.isEmptyObject(changedOps)) {
4546
update({ _changedOptions: changedOps });
4553
_base.destroy = function () {
4558
autoUpdateLoop.remove(_base);
4561
disconnectMutationObservers();
4564
setupResizeObserver(_sizeObserverElement);
4565
setupResizeObserver(_sizeAutoObserverElement);
4568
for (var extName in _extensions)
4569
_base.removeExt(extName);
4572
while (_destroyEvents[LEXICON.l] > 0)
4573
_destroyEvents.pop()();
4576
setupHostMouseTouchEvents(true);
4579
if (_contentGlueElement)
4580
remove(_contentGlueElement);
4581
if (_contentArrangeElement)
4582
remove(_contentArrangeElement);
4583
if (_sizeAutoObserverAdded)
4584
remove(_sizeAutoObserverElement);
4587
setupScrollbarsDOM(true);
4588
setupScrollbarCornerDOM(true);
4589
setupStructureDOM(true);
4592
for (var i = 0; i < _updateOnLoadElms[LEXICON.l]; i++)
4593
FRAMEWORK(_updateOnLoadElms[i]).off(_updateOnLoadEventName, updateOnLoadCallback);
4594
_updateOnLoadElms = undefined;
4600
INSTANCES(pluginTargetElement, 0);
4601
dispatchCallback('onDestroyed');
4678
_base.scroll = function (coordinates, duration, easing, complete) {
4679
if (arguments.length === 0 || coordinates === undefined) {
4680
var infoX = _scrollHorizontalInfo;
4681
var infoY = _scrollVerticalInfo;
4682
var normalizeInvert = _normalizeRTLCache && _isRTL && _rtlScrollBehavior.i;
4683
var normalizeNegate = _normalizeRTLCache && _isRTL && _rtlScrollBehavior.n;
4684
var scrollX = infoX._currentScroll;
4685
var scrollXRatio = infoX._currentScrollRatio;
4686
var maxScrollX = infoX._maxScroll;
4687
scrollXRatio = normalizeInvert ? 1 - scrollXRatio : scrollXRatio;
4688
scrollX = normalizeInvert ? maxScrollX - scrollX : scrollX;
4689
scrollX *= normalizeNegate ? -1 : 1;
4690
maxScrollX *= normalizeNegate ? -1 : 1;
4695
y: infoY._currentScroll
4699
y: infoY._currentScrollRatio
4706
x: infoX._handleOffset,
4707
y: infoY._handleOffset
4710
x: infoX._handleLength,
4711
y: infoY._handleLength
4713
handleLengthRatio: {
4714
x: infoX._handleLengthRatio,
4715
y: infoY._handleLengthRatio
4718
x: infoX._trackLength,
4719
y: infoY._trackLength
4721
snappedHandleOffset: {
4722
x: infoX._snappedHandleOffset,
4723
y: infoY._snappedHandleOffset
4726
isRTLNormalized: _normalizeRTLCache
4730
_base.update(_strSync);
4732
var normalizeRTL = _normalizeRTLCache;
4733
var coordinatesXAxisProps = [_strX, _strLeft, 'l'];
4734
var coordinatesYAxisProps = [_strY, _strTop, 't'];
4735
var coordinatesOperators = ['+=', '-=', '*=', '/='];
4736
var durationIsObject = type(duration) == TYPES.o;
4737
var completeCallback = durationIsObject ? duration.complete : complete;
4739
var finalScroll = {};
4740
var specialEasing = {};
4743
var animationOptions;
4745
var strBegin = 'begin';
4746
var strCenter = 'center';
4747
var strNearest = 'nearest';
4748
var strAlways = 'always';
4749
var strNever = 'never';
4750
var strIfNeeded = 'ifneeded';
4751
var strLength = LEXICON.l;
4757
var elementObjSettingsAxisValues = [_strX, _strY, 'xy', 'yx'];
4758
var elementObjSettingsBlockValues = [strBegin, strEnd, strCenter, strNearest];
4759
var elementObjSettingsScrollValues = [strAlways, strNever, strIfNeeded];
4760
var coordinatesIsElementObj = coordinates[LEXICON.hOP]('el');
4761
var possibleElement = coordinatesIsElementObj ? coordinates.el : coordinates;
4762
var possibleElementIsJQuery = possibleElement instanceof FRAMEWORK || JQUERY ? possibleElement instanceof JQUERY : false;
4763
var possibleElementIsHTMLElement = possibleElementIsJQuery ? false : isHTMLElement(possibleElement);
4764
var updateScrollbarInfos = function () {
4766
refreshScrollbarHandleOffset(true);
4768
refreshScrollbarHandleOffset(false);
4770
var proxyCompleteCallback = type(completeCallback) != TYPES.f ? undefined : function () {
4771
updateScrollbarInfos();
4774
function checkSettingsStringValue(currValue, allowedValues) {
4775
for (i = 0; i < allowedValues[strLength]; i++) {
4776
if (currValue === allowedValues[i])
4781
function getRawScroll(isX, coordinates) {
4782
var coordinateProps = isX ? coordinatesXAxisProps : coordinatesYAxisProps;
4783
coordinates = type(coordinates) == TYPES.s || type(coordinates) == TYPES.n ? [coordinates, coordinates] : coordinates;
4785
if (COMPATIBILITY.isA(coordinates))
4786
return isX ? coordinates[0] : coordinates[1];
4787
else if (type(coordinates) == TYPES.o) {
4790
for (i = 0; i < coordinateProps[strLength]; i++)
4791
if (coordinateProps[i] in coordinates)
4792
return coordinates[coordinateProps[i]];
4795
function getFinalScroll(isX, rawScroll) {
4796
var isString = type(rawScroll) == TYPES.s;
4799
var scrollInfo = isX ? _scrollHorizontalInfo : _scrollVerticalInfo;
4800
var currScroll = scrollInfo._currentScroll;
4801
var maxScroll = scrollInfo._maxScroll;
4804
var isRTLisX = _isRTL && isX;
4805
var normalizeShortcuts = isRTLisX && _rtlScrollBehavior.n && !normalizeRTL;
4806
var strReplace = 'replace';
4807
var evalFunc = eval;
4808
var possibleOperator;
4811
if (rawScroll[strLength] > 2) {
4812
possibleOperator = rawScroll.substr(0, 2);
4813
if (inArray(possibleOperator, coordinatesOperators) > -1)
4814
operator = possibleOperator;
4818
rawScroll = operator ? rawScroll.substr(2) : rawScroll;
4819
rawScroll = rawScroll
4820
[strReplace](/min/g, 0)
4821
[strReplace](/</g, 0)
4822
[strReplace](/max/g, (normalizeShortcuts ? '-' : _strEmpty) + _strHundredPercent)
4823
[strReplace](/>/g, (normalizeShortcuts ? '-' : _strEmpty) + _strHundredPercent)
4824
[strReplace](/px/g, _strEmpty)
4825
[strReplace](/%/g, mult + (maxScroll * (isRTLisX && _rtlScrollBehavior.n ? -1 : 1) / 100.0))
4826
[strReplace](/vw/g, mult + _viewportSize.w)
4827
[strReplace](/vh/g, mult + _viewportSize.h);
4828
amount = parseToZeroOrNumber(isNaN(rawScroll) ? parseToZeroOrNumber(evalFunc(rawScroll), true).toFixed() : rawScroll);
4834
if (amount !== undefined && !isNaN(amount) && type(amount) == TYPES.n) {
4835
var normalizeIsRTLisX = normalizeRTL && isRTLisX;
4836
var operatorCurrScroll = currScroll * (normalizeIsRTLisX && _rtlScrollBehavior.n ? -1 : 1);
4837
var invert = normalizeIsRTLisX && _rtlScrollBehavior.i;
4838
var negate = normalizeIsRTLisX && _rtlScrollBehavior.n;
4839
operatorCurrScroll = invert ? (maxScroll - operatorCurrScroll) : operatorCurrScroll;
4842
finalValue = operatorCurrScroll + amount;
4845
finalValue = operatorCurrScroll - amount;
4848
finalValue = operatorCurrScroll * amount;
4851
finalValue = operatorCurrScroll / amount;
4854
finalValue = amount;
4857
finalValue = invert ? maxScroll - finalValue : finalValue;
4858
finalValue *= negate ? -1 : 1;
4859
finalValue = isRTLisX && _rtlScrollBehavior.n ? MATH.min(0, MATH.max(maxScroll, finalValue)) : MATH.max(0, MATH.min(maxScroll, finalValue));
4861
return finalValue === currScroll ? undefined : finalValue;
4863
function getPerAxisValue(value, valueInternalType, defaultValue, allowedValues) {
4864
var resultDefault = [defaultValue, defaultValue];
4865
var valueType = type(value);
4870
if (valueType == valueInternalType) {
4871
value = [value, value];
4873
else if (valueType == TYPES.a) {
4874
valueArrLength = value[strLength];
4875
if (valueArrLength > 2 || valueArrLength < 1)
4876
value = resultDefault;
4878
if (valueArrLength === 1)
4879
value[1] = defaultValue;
4880
for (i = 0; i < valueArrLength; i++) {
4881
valueArrItem = value[i];
4882
if (type(valueArrItem) != valueInternalType || !checkSettingsStringValue(valueArrItem, allowedValues)) {
4883
value = resultDefault;
4889
else if (valueType == TYPES.o)
4890
value = [value[_strX] || defaultValue, value[_strY] || defaultValue];
4892
value = resultDefault;
4893
return { x: value[0], y: value[1] };
4895
function generateMargin(marginTopRightBottomLeftArray) {
4899
var valueDirections = [_strTop, _strRight, _strBottom, _strLeft];
4900
for (i = 0; i < marginTopRightBottomLeftArray[strLength]; i++) {
4901
if (i === valueDirections[strLength])
4903
currValue = marginTopRightBottomLeftArray[i];
4904
currValueType = type(currValue);
4905
if (currValueType == TYPES.b)
4906
result.push(currValue ? parseToZeroOrNumber(finalElement.css(_strMarginMinus + valueDirections[i])) : 0);
4908
result.push(currValueType == TYPES.n ? currValue : 0);
4913
if (possibleElementIsJQuery || possibleElementIsHTMLElement) {
4915
var margin = coordinatesIsElementObj ? coordinates.margin : 0;
4916
var axis = coordinatesIsElementObj ? coordinates.axis : 0;
4917
var scroll = coordinatesIsElementObj ? coordinates.scroll : 0;
4918
var block = coordinatesIsElementObj ? coordinates.block : 0;
4919
var marginDefault = [0, 0, 0, 0];
4920
var marginType = type(margin);
4922
finalElement = possibleElementIsJQuery ? possibleElement : FRAMEWORK(possibleElement);
4924
if (finalElement[strLength] > 0) {
4926
if (marginType == TYPES.n || marginType == TYPES.b)
4927
margin = generateMargin([margin, margin, margin, margin]);
4928
else if (marginType == TYPES.a) {
4929
marginLength = margin[strLength];
4930
if (marginLength === 2)
4931
margin = generateMargin([margin[0], margin[1], margin[0], margin[1]]);
4932
else if (marginLength >= 4)
4933
margin = generateMargin(margin);
4935
margin = marginDefault;
4937
else if (marginType == TYPES.o)
4938
margin = generateMargin([margin[_strTop], margin[_strRight], margin[_strBottom], margin[_strLeft]]);
4940
margin = marginDefault;
4943
settingsAxis = checkSettingsStringValue(axis, elementObjSettingsAxisValues) ? axis : 'xy';
4944
settingsScroll = getPerAxisValue(scroll, TYPES.s, strAlways, elementObjSettingsScrollValues);
4945
settingsBlock = getPerAxisValue(block, TYPES.s, strBegin, elementObjSettingsBlockValues);
4946
settingsMargin = margin;
4948
var viewportScroll = {
4949
l: _scrollHorizontalInfo._currentScroll,
4950
t: _scrollVerticalInfo._currentScroll
4953
var viewportOffset = _paddingElement.offset();
4956
var elementOffset = finalElement.offset();
4958
x: settingsScroll.x == strNever || settingsAxis == _strY,
4959
y: settingsScroll.y == strNever || settingsAxis == _strX
4961
elementOffset[_strTop] -= settingsMargin[0];
4962
elementOffset[_strLeft] -= settingsMargin[3];
4963
var elementScrollCoordinates = {
4964
x: MATH.round(elementOffset[_strLeft] - viewportOffset[_strLeft] + viewportScroll.l),
4965
y: MATH.round(elementOffset[_strTop] - viewportOffset[_strTop] + viewportScroll.t)
4968
if (!_rtlScrollBehavior.n && !_rtlScrollBehavior.i)
4969
elementScrollCoordinates.x = MATH.round(viewportOffset[_strLeft] - elementOffset[_strLeft] + viewportScroll.l);
4970
if (_rtlScrollBehavior.n && normalizeRTL)
4971
elementScrollCoordinates.x *= -1;
4972
if (_rtlScrollBehavior.i && normalizeRTL)
4973
elementScrollCoordinates.x = MATH.round(viewportOffset[_strLeft] - elementOffset[_strLeft] + (_scrollHorizontalInfo._maxScroll - viewportScroll.l));
4977
if (settingsBlock.x != strBegin || settingsBlock.y != strBegin || settingsScroll.x == strIfNeeded || settingsScroll.y == strIfNeeded || _isRTL) {
4978
var measuringElm = finalElement[0];
4979
var rawElementSize = _supportTransform ? measuringElm[LEXICON.bCR]() : {
4980
width: measuringElm[LEXICON.oW],
4981
height: measuringElm[LEXICON.oH]
4984
w: rawElementSize[_strWidth] + settingsMargin[3] + settingsMargin[1],
4985
h: rawElementSize[_strHeight] + settingsMargin[0] + settingsMargin[2]
4987
var finalizeBlock = function (isX) {
4988
var vars = getScrollbarVars(isX);
4990
var lt = vars._left_top;
4992
var blockIsEnd = settingsBlock[xy] == (isX ? _isRTL ? strBegin : strEnd : strEnd);
4993
var blockIsCenter = settingsBlock[xy] == strCenter;
4994
var blockIsNearest = settingsBlock[xy] == strNearest;
4995
var scrollNever = settingsScroll[xy] == strNever;
4996
var scrollIfNeeded = settingsScroll[xy] == strIfNeeded;
4997
var vpSize = _viewportSize[wh];
4998
var vpOffset = viewportOffset[lt];
4999
var elSize = elementSize[wh];
5000
var elOffset = elementOffset[lt];
5001
var divide = blockIsCenter ? 2 : 1;
5002
var elementCenterOffset = elOffset + (elSize / 2);
5003
var viewportCenterOffset = vpOffset + (vpSize / 2);
5006
&& elOffset >= vpOffset
5007
&& elOffset + elSize <= vpOffset + vpSize;
5010
doNotScroll[xy] = true;
5011
else if (!doNotScroll[xy]) {
5012
if (blockIsNearest || scrollIfNeeded) {
5013
doNotScroll[xy] = scrollIfNeeded ? isInView : false;
5014
blockIsEnd = elSize < vpSize ? elementCenterOffset > viewportCenterOffset : elementCenterOffset < viewportCenterOffset;
5016
elementScrollCoordinates[xy] -= blockIsEnd || blockIsCenter ? ((vpSize / divide) - (elSize / divide)) * (isX && _isRTL && normalizeRTL ? -1 : 1) : 0;
5019
finalizeBlock(true);
5020
finalizeBlock(false);
5024
delete elementScrollCoordinates.y;
5026
delete elementScrollCoordinates.x;
5028
coordinates = elementScrollCoordinates;
5032
finalScroll[_strScrollLeft] = getFinalScroll(true, getRawScroll(true, coordinates));
5033
finalScroll[_strScrollTop] = getFinalScroll(false, getRawScroll(false, coordinates));
5034
doScrollLeft = finalScroll[_strScrollLeft] !== undefined;
5035
doScrollTop = finalScroll[_strScrollTop] !== undefined;
5037
if ((doScrollLeft || doScrollTop) && (duration > 0 || durationIsObject)) {
5038
if (durationIsObject) {
5039
duration.complete = proxyCompleteCallback;
5040
_viewportElement.animate(finalScroll, duration);
5043
animationOptions = {
5045
complete: proxyCompleteCallback
5047
if (COMPATIBILITY.isA(easing) || FRAMEWORK.isPlainObject(easing)) {
5048
specialEasing[_strScrollLeft] = easing[0] || easing.x;
5049
specialEasing[_strScrollTop] = easing[1] || easing.y;
5050
animationOptions.specialEasing = specialEasing;
5053
animationOptions.easing = easing;
5055
_viewportElement.animate(finalScroll, animationOptions);
5060
_viewportElement[_strScrollLeft](finalScroll[_strScrollLeft]);
5062
_viewportElement[_strScrollTop](finalScroll[_strScrollTop]);
5063
updateScrollbarInfos();
5071
_base.scrollStop = function (param1, param2, param3) {
5072
_viewportElement.stop(param1, param2, param3);
5081
_base.getElements = function (elementName) {
5083
target: _targetElementNative,
5084
host: _hostElementNative,
5085
padding: _paddingElementNative,
5086
viewport: _viewportElementNative,
5087
content: _contentElementNative,
5088
scrollbarHorizontal: {
5089
scrollbar: _scrollbarHorizontalElement[0],
5090
track: _scrollbarHorizontalTrackElement[0],
5091
handle: _scrollbarHorizontalHandleElement[0]
5093
scrollbarVertical: {
5094
scrollbar: _scrollbarVerticalElement[0],
5095
track: _scrollbarVerticalTrackElement[0],
5096
handle: _scrollbarVerticalHandleElement[0]
5098
scrollbarCorner: _scrollbarCornerElement[0]
5100
return type(elementName) == TYPES.s ? getObjectPropVal(obj, elementName) : obj;
5108
_base.getState = function (stateProperty) {
5109
function prepare(obj) {
5110
if (!FRAMEWORK.isPlainObject(obj))
5112
var extended = extendDeep({}, obj);
5113
var changePropertyName = function (from, to) {
5114
if (extended[LEXICON.hOP](from)) {
5115
extended[to] = extended[from];
5116
delete extended[from];
5119
changePropertyName('w', _strWidth);
5120
changePropertyName('h', _strHeight);
5125
destroyed: !!prepare(_destroyed),
5126
sleeping: !!prepare(_sleeping),
5127
autoUpdate: prepare(!_mutationObserversConnected),
5128
widthAuto: prepare(_widthAutoCache),
5129
heightAuto: prepare(_heightAutoCache),
5130
padding: prepare(_cssPaddingCache),
5131
overflowAmount: prepare(_overflowAmountCache),
5132
hideOverflow: prepare(_hideOverflowCache),
5133
hasOverflow: prepare(_hasOverflowCache),
5134
contentScrollSize: prepare(_contentScrollSizeCache),
5135
viewportSize: prepare(_viewportSize),
5136
hostSize: prepare(_hostSizeCache),
5137
documentMixed: prepare(_documentMixed)
5139
return type(stateProperty) == TYPES.s ? getObjectPropVal(obj, stateProperty) : obj;
5147
_base.ext = function (extName) {
5149
var privateMethods = _extensionsPrivateMethods.split(' ');
5151
if (type(extName) == TYPES.s) {
5152
if (_extensions[LEXICON.hOP](extName)) {
5153
result = extendDeep({}, _extensions[extName]);
5154
for (; i < privateMethods.length; i++)
5155
delete result[privateMethods[i]];
5160
for (i in _extensions)
5161
result[i] = extendDeep({}, _base.ext(i));
5172
_base.addExt = function (extName, extensionOptions) {
5173
var registeredExtensionObj = _plugin.extension(extName);
5176
var instanceContract;
5178
var contractFulfilled = true;
5179
if (registeredExtensionObj) {
5180
if (!_extensions[LEXICON.hOP](extName)) {
5181
instance = registeredExtensionObj.extensionFactory.call(_base,
5182
extendDeep({}, registeredExtensionObj.defaultOptions),
5187
instanceContract = instance.contract;
5188
if (type(instanceContract) == TYPES.f) {
5189
contractResult = instanceContract(window);
5190
contractFulfilled = type(contractResult) == TYPES.b ? contractResult : contractFulfilled;
5192
if (contractFulfilled) {
5193
_extensions[extName] = instance;
5194
instanceAdded = instance.added;
5195
if (type(instanceAdded) == TYPES.f)
5196
instanceAdded(extensionOptions);
5198
return _base.ext(extName);
5203
return _base.ext(extName);
5206
console.warn("A extension with the name \"" + extName + "\" isn't registered.");
5214
_base.removeExt = function (extName) {
5215
var instance = _extensions[extName];
5216
var instanceRemoved;
5218
delete _extensions[extName];
5220
instanceRemoved = instance.removed;
5221
if (type(instanceRemoved) == TYPES.f)
5236
function construct(targetElement, options, extensions) {
5237
_defaultOptions = globals.defaultOptions;
5238
_nativeScrollbarStyling = globals.nativeScrollbarStyling;
5239
_nativeScrollbarSize = extendDeep({}, globals.nativeScrollbarSize);
5240
_nativeScrollbarIsOverlaid = extendDeep({}, globals.nativeScrollbarIsOverlaid);
5241
_overlayScrollbarDummySize = extendDeep({}, globals.overlayScrollbarDummySize);
5242
_rtlScrollBehavior = extendDeep({}, globals.rtlScrollBehavior);
5245
setOptions(extendDeep({}, _defaultOptions, options));
5247
_cssCalc = globals.cssCalc;
5248
_msieVersion = globals.msie;
5249
_autoUpdateRecommended = globals.autoUpdateRecommended;
5250
_supportTransition = globals.supportTransition;
5251
_supportTransform = globals.supportTransform;
5252
_supportPassiveEvents = globals.supportPassiveEvents;
5253
_supportResizeObserver = globals.supportResizeObserver;
5254
_supportMutationObserver = globals.supportMutationObserver;
5255
_restrictedMeasuring = globals.restrictedMeasuring;
5256
_documentElement = FRAMEWORK(targetElement.ownerDocument);
5257
_documentElementNative = _documentElement[0];
5258
_windowElement = FRAMEWORK(_documentElementNative.defaultView || _documentElementNative.parentWindow);
5259
_windowElementNative = _windowElement[0];
5260
_htmlElement = findFirst(_documentElement, 'html');
5261
_bodyElement = findFirst(_htmlElement, 'body');
5262
_targetElement = FRAMEWORK(targetElement);
5263
_targetElementNative = _targetElement[0];
5264
_isTextarea = _targetElement.is('textarea');
5265
_isBody = _targetElement.is('body');
5266
_documentMixed = _documentElementNative !== document;
5327
_domExists = _isTextarea
5328
? _targetElement.hasClass(_classNameTextareaElement) && _targetElement.parent().hasClass(_classNameContentElement)
5329
: _targetElement.hasClass(_classNameHostElement) && _targetElement.children(_strDot + _classNamePaddingElement)[LEXICON.l];
5332
var bodyMouseTouchDownListener;
5335
if (_nativeScrollbarIsOverlaid.x && _nativeScrollbarIsOverlaid.y && !_currentPreparedOptions.nativeScrollbarsOverlaid.initialize) {
5336
dispatchCallback('onInitializationWithdrawn');
5338
setupStructureDOM(true);
5339
setupScrollbarsDOM(true);
5340
setupScrollbarCornerDOM(true);
5350
initBodyScroll = {};
5351
initBodyScroll.l = MATH.max(_targetElement[_strScrollLeft](), _htmlElement[_strScrollLeft](), _windowElement[_strScrollLeft]());
5352
initBodyScroll.t = MATH.max(_targetElement[_strScrollTop](), _htmlElement[_strScrollTop](), _windowElement[_strScrollTop]());
5354
bodyMouseTouchDownListener = function () {
5355
_viewportElement.removeAttr(LEXICON.ti);
5356
setupResponsiveEventListener(_viewportElement, _strMouseTouchDownEvent, bodyMouseTouchDownListener, true, true);
5361
setupStructureDOM();
5362
setupScrollbarsDOM();
5363
setupScrollbarCornerDOM();
5366
setupStructureEvents();
5367
setupScrollbarEvents(true);
5368
setupScrollbarEvents(false);
5369
setupScrollbarCornerEvents();
5372
createMutationObservers();
5375
setupResizeObserver(_sizeObserverElement, hostOnResized);
5379
_viewportElement[_strScrollLeft](initBodyScroll.l)[_strScrollTop](initBodyScroll.t);
5382
if (document.activeElement == targetElement && _viewportElementNative.focus) {
5384
_viewportElement.attr(LEXICON.ti, '-1');
5385
_viewportElementNative.focus();
5391
setupResponsiveEventListener(_viewportElement, _strMouseTouchDownEvent, bodyMouseTouchDownListener, false, true);
5396
_base.update(_strAuto);
5399
_initialized = true;
5400
dispatchCallback('onInitialized');
5403
each(_callbacksInitQeueue, function (index, value) { dispatchCallback(value.n, value.a); });
5404
_callbacksInitQeueue = [];
5407
if (type(extensions) == TYPES.s)
5408
extensions = [extensions];
5409
if (COMPATIBILITY.isA(extensions))
5410
each(extensions, function (index, value) { _base.addExt(value); });
5411
else if (FRAMEWORK.isPlainObject(extensions))
5412
each(extensions, function (key, value) { _base.addExt(key, value); });
5415
setTimeout(function () {
5416
if (_supportTransition && !_destroyed)
5417
addClass(_hostElement, _classNameHostTransition);
5423
if (_plugin.valid(construct(pluginTargetElement, options, extensions))) {
5424
INSTANCES(pluginTargetElement, _base);
5437
_plugin = window[PLUGINNAME] = function (pluginTargetElements, options, extensions) {
5438
if (arguments[LEXICON.l] === 0)
5442
var optsIsPlainObj = FRAMEWORK.isPlainObject(options);
5447
if (!pluginTargetElements)
5448
return optsIsPlainObj || !options ? result : arr;
5457
pluginTargetElements = pluginTargetElements[LEXICON.l] != undefined ? pluginTargetElements : [pluginTargetElements[0] || pluginTargetElements];
5458
initOverlayScrollbarsStatics();
5460
if (pluginTargetElements[LEXICON.l] > 0) {
5461
if (optsIsPlainObj) {
5462
FRAMEWORK.each(pluginTargetElements, function (i, v) {
5464
if (inst !== undefined)
5465
arr.push(OverlayScrollbarsInstance(inst, options, extensions, _pluginsGlobals, _pluginsAutoUpdateLoop));
5469
FRAMEWORK.each(pluginTargetElements, function (i, v) {
5470
inst = INSTANCES(v);
5471
if ((options === '!' && _plugin.valid(inst)) || (COMPATIBILITY.type(options) == TYPES.f && options(v, inst)))
5473
else if (options === undefined)
5477
result = arr[LEXICON.l] === 1 ? arr[0] : arr;
5486
_plugin.globals = function () {
5487
initOverlayScrollbarsStatics();
5488
var globals = FRAMEWORK.extend(true, {}, _pluginsGlobals);
5489
delete globals['msie'];
5497
_plugin.defaultOptions = function (newDefaultOptions) {
5498
initOverlayScrollbarsStatics();
5499
var currDefaultOptions = _pluginsGlobals.defaultOptions;
5500
if (newDefaultOptions === undefined)
5501
return FRAMEWORK.extend(true, {}, currDefaultOptions);
5504
_pluginsGlobals.defaultOptions = FRAMEWORK.extend(true, {}, currDefaultOptions, _pluginsOptions._validate(newDefaultOptions, _pluginsOptions._template, true, currDefaultOptions)._default);
5512
_plugin.valid = function (osInstance) {
5513
return osInstance instanceof _plugin && !osInstance.getState().destroyed;
5526
_plugin.extension = function (extensionName, extension, defaultOptions) {
5527
var extNameTypeString = COMPATIBILITY.type(extensionName) == TYPES.s;
5528
var argLen = arguments[LEXICON.l];
5530
if (argLen < 1 || !extNameTypeString) {
5532
return FRAMEWORK.extend(true, { length: _pluginsExtensions[LEXICON.l] }, _pluginsExtensions);
5534
else if (extNameTypeString) {
5535
if (COMPATIBILITY.type(extension) == TYPES.f) {
5537
_pluginsExtensions.push({
5538
name: extensionName,
5539
extensionFactory: extension,
5540
defaultOptions: defaultOptions
5544
for (; i < _pluginsExtensions[LEXICON.l]; i++) {
5545
if (_pluginsExtensions[i].name === extensionName) {
5547
_pluginsExtensions.splice(i, 1);
5549
return FRAMEWORK.extend(true, {}, _pluginsExtensions[i]);
5559
if (JQUERY && JQUERY.fn) {
5566
JQUERY.fn.overlayScrollbars = function (options, extensions) {
5567
var _elements = this;
5568
if (JQUERY.isPlainObject(options)) {
5569
JQUERY.each(_elements, function () { PLUGIN(this, options, extensions); });
5573
return PLUGIN(_elements, options);