UNPKG

ns-components-angular

Version:

Angular Wrapper Components for NSComponents

1 lines 64.6 kB
export declare const NSScrollerCode = "var nsModuleExport = function(root,name,prototype)\r\n\t{\r\n\t\tif(typeof exports === 'object' && typeof module === 'object')\r\n\t\t{\r\n\t\t\tmodule.exports[name] = prototype;\r\n\t\t}\r\n\t\telse if (typeof define === \"function\" && define.amd)\r\n\t\t{\r\n\t\t\tdefine(name,[], function () {return prototype;});\r\n\t\t}\r\n\t\telse if(typeof exports === 'object')\r\n\t\t{\r\n\t\t\texports[name] = prototype;\r\n\t\t}\r\n\t\telse\r\n\t\t{\r\n\t\t\troot[name] = prototype;\r\n\t\t}\r\n\t};var nsIsWeb = function(root)\r\n\t{\r\n\t\tif(typeof exports === 'object' && typeof module === 'object')\r\n\t\t{\r\n\t\t\treturn false;\r\n\t\t}\r\n\t\telse if (typeof define === \"function\" && define.amd)\r\n\t\t{\r\n\t\t\treturn false;\r\n\t\t}\r\n\t\telse if(typeof exports === 'object')\r\n\t\t{\r\n\t\t\treturn false;\r\n\t\t}\r\n\t\telse\r\n\t\t{\r\n\t\t\treturn true;\r\n\t\t}\r\n\t};if(!nsIsWeb())\r\n\t\t{\r\nvar nsutilRef = require('./nsUtil.min.js');\r\nvar NSUtil = nsutilRef.NSUtil;\r\nvar nscontainerbaseRef = require('./nsContainerBase.min.js');\r\nvar nsExtendPrototype = nscontainerbaseRef.nsExtendPrototype;\r\nvar NSContainerBase = nscontainerbaseRef.NSContainerBase;\r\n\r\n\t\t}\r\n\"use strict\";\r\nvar NSScrollAnimator = (function()\r\n{\r\n\tfunction NSScrollAnimator(config) \r\n\t{\r\n\t\tvar self = this;\r\n\t\tvar setting = {};\r\n\t\t\r\n\t\tvar util = null;\r\n\t\tvar stopScroll = false;\r\n\t\tvar start = 0;\r\n\t\tvar startTime = 0;\r\n\t\tvar destinationOffsetToScroll = 0;\r\n\t\tvar animationFunction = {};\r\n\t\tvar props = {};\r\n\t\tvar propItem = {};\r\n\t\tvar interval = null;\r\n\t\t\r\n\t\tvar initialize = function()\r\n\t\t{\r\n\t\t\tif(!config)\r\n\t\t\t{\r\n\t\t\t\tconfig = {};\r\n\t\t\t}\r\n\t\t\tutil = new NSUtil();\r\n\t\t\tinitAnimationFunc();\r\n\t\t\tsetting = {\r\n\t\t\t\telement: config[\"element\"] || window,\r\n\t\t\t\tdirection: config[\"direction\"] || \"vertical\",\r\n\t\t\t\tduration: !util.isUndefinedOrNull(config[\"duration\"]) ? parseInt(config[\"duration\"]) : 500,\r\n\t\t\t\teasing: config[\"easing\"] || \"easeInOutQuad\",\r\n\t\t\t\tcallback: config[\"callback\"] || null,\r\n\t\t\t};\r\n\t\t\tif(setting.element === window)\r\n\t\t\t{\r\n\t\t\t\tsetting.refElement = document.documentElement;\r\n\t\t\t}\r\n\t\t\telse \r\n\t\t\t{\r\n\t\t\t\tsetting.refElement = setting.element;\r\n\t\t\t}\r\n\t\t\tprops = { vertical:{scroll: \"scrollTop\", scrollSize: \"scrollHeight\",client: \"clientHeight\",offset: \"offsetHeight\",inner: \"innerHeight\",offsetPos: \"offsetTop\",},\r\n\t\t\t\t\t horizontal:{scroll: \"scrollLeft\", scrollSize: \"scrollWidth\",client: \"clientWidth\",offset: \"offsetWidth\",inner: \"innerWidth\",offsetPos: \"offsetLeft\",}\r\n\t\t\t};\r\n\t\t\tpropItem = props[setting.direction];\r\n\t\t};\r\n\t\t\r\n\t\tvar scrollTo = function(newPos)\r\n\t\t{\r\n\t\t\tif(!util.isUndefinedOrNull(newPos))\r\n\t\t\t{\r\n\t\t\t\tstart = setting.refElement[propItem.scroll];\r\n\t\t\t\tstartTime = 'now' in window.performance ? performance.now() : new Date().getTime();\r\n\t\t\t\tvar outerSize = Math.max(setting.refElement[propItem.scrollSize], setting.refElement[propItem.offset], setting.refElement[propItem.offset]);\r\n\t\t\t\tvar innerSize = setting.refElement[propItem.inner] || setting.refElement[propItem.offset];\r\n\t\t\t\tvar destinationOffset = typeof newPos === 'number' ? newPos : newPos[propItem.offsetPos];\r\n\t\t\t\tdestinationOffsetToScroll = Math.round(outerSize - destinationOffset < innerSize ? outerSize - innerSize : destinationOffset);\r\n\t\t\t\tanimateScroll();\r\n\t\t\t}\r\n\t\t};\r\n\t\t\r\n\t\tvar getMaxScrollPos = function()\r\n\t\t{\r\n\t\t\treturn setting.refElement[propItem.scrollSize] - setting.refElement[propItem.client];\r\n\t\t};\r\n\t\t\r\n\t\tvar getScrollPos = function()\r\n\t\t{\r\n\t\t\treturn setting.refElement[propItem.scroll];\r\n\t\t};\r\n\t\t\r\n\t\tvar stop = function()\r\n\t\t{\r\n\t\t\tstopScroll = true;\r\n\t\t};\r\n\t\t\r\n\t\tvar animateScroll = function() \r\n\t\t{\r\n if (!stopScroll) \r\n {\r\n \t var now = 'now' in window.performance ? performance.now() : new Date().getTime();\r\n \t var time = Math.min(1, ((now - startTime) / setting.duration));\r\n \t var timeFunction = animationFunction[setting.easing](time);\r\n \t var val = Math.ceil((timeFunction * (destinationOffsetToScroll - start)) + start);\r\n setting.refElement[propItem.scroll] = val;\r\n if (setting.refElement[propItem.scroll] === destinationOffsetToScroll) \r\n {\r\n \t if(setting.callback)\r\n {\r\n \t setting.callback();\r\n }\r\n \t return;\r\n }\r\n interval = util.getRequestAnimationFrame.bind(window)(animateScroll);\r\n }\r\n else\r\n {\r\n \t util.getCancelAnimationFrame.bind(window)(interval);\r\n \t setting.refElement[propItem.scroll] = destinationOffsetToScroll;\r\n \t if(setting.callback)\r\n \t {\r\n \t\t setting.callback();\r\n \t }\r\n }\r\n };\r\n \r\n var initAnimationFunc = function()\r\n {\r\n \t animationFunction = {\r\n\t\t\t\t linear: function(t) {\r\n\t\t\t\t return t;\r\n\t\t\t\t },\r\n\t\t\t\t easeInQuad: function(t) {\r\n\t\t\t\t return t * t;\r\n\t\t\t\t },\r\n\t\t\t\t easeOutQuad: function(t) {\r\n\t\t\t\t return t * (2 - t);\r\n\t\t\t\t },\r\n\t\t\t\t easeInOutQuad: function(t) {\r\n\t\t\t\t return t < 0.5 ? 2 * t * t : -1 + (4 - 2 * t) * t;\r\n\t\t\t\t },\r\n\t\t\t\t easeInCubic: function(t) {\r\n\t\t\t\t return t * t * t;\r\n\t\t\t\t },\r\n\t\t\t\t easeOutCubic: function(t) {\r\n\t\t\t\t return (--t) * t * t + 1;\r\n\t\t\t\t },\r\n\t\t\t\t easeInOutCubic: function(t) {\r\n\t\t\t\t return t < 0.5 ? 4 * t * t * t : (t - 1) * (2 * t - 2) * (2 * t - 2) + 1;\r\n\t\t\t\t },\r\n\t\t\t\t easeInQuart: function(t) {\r\n\t\t\t\t return t * t * t * t;\r\n\t\t\t\t },\r\n\t\t\t\t easeOutQuart: function(t) {\r\n\t\t\t\t return 1 - (--t) * t * t * t;\r\n\t\t\t\t },\r\n\t\t\t\t easeInOutQuart: function(t) {\r\n\t\t\t\t return t < 0.5 ? 8 * t * t * t * t : 1 - 8 * (--t) * t * t * t;\r\n\t\t\t\t },\r\n\t\t\t\t easeInQuint: function(t) {\r\n\t\t\t\t return t * t * t * t * t;\r\n\t\t\t\t },\r\n\t\t\t\t easeOutQuint: function(t) {\r\n\t\t\t\t return 1 + (--t) * t * t * t * t;\r\n\t\t\t\t },\r\n\t\t\t\t easeInOutQuint: function(t) {\r\n\t\t\t\t return t < 0.5 ? 16 * t * t * t * t * t : 1 + 16 * (--t) * t * t * t * t;\r\n\t\t\t\t }\r\n\t\t\t};\r\n\r\n };\r\n \r\n self.scrollTo = scrollTo;\r\n self.getScrollPos = getScrollPos;\r\n self.getMaxScrollPos = getMaxScrollPos;\r\n self.stop = stop;\r\n\t\t\r\n\t\tinitialize();\r\n\t};\r\n\treturn NSScrollAnimator;\r\n})();\r\nnsModuleExport(this,\"NSScrollAnimator\",NSScrollAnimator);var NSScroller = (function()\r\n{\r\n\tfunction NSScroller(setting)\r\n\t{\r\n\t\tvar self = this;\r\n\t\tvar util = null;\r\n\t\tvar config = {};\r\n\t\t\r\n\t\t//var parentNode = null;\r\n\t\tvar divScrollBarCorner = null;\r\n\t\t\r\n\t\tvar props = {};\r\n\t\t\r\n\t\tvar operaMaxScrollBarSize = 17;\r\n\t\tvar macScrollBarSize = 15;\r\n\t\tvar macFFRegex = /[\\s\\S]*Macintosh[\\s\\S]*\\) Gecko[\\s\\S]*/;\r\n\t\tvar isMacFF = macFFRegex.test(window.navigator && window.navigator.userAgent);\r\n\t\t\r\n\t\tvar selectedItem = null;\r\n\t\tvar interval = null;\r\n\t\tvar delayInterval = null;\r\n\t\tvar mouseWheelEndInterval = null;\r\n\t\tvar mutationObserver = null;\r\n\t\tvar lastScrollPos = -1;\r\n\t\tvar setIsInternalWithOutDelay = true;\r\n\t\tvar isInternalScroll = false;\r\n\t\tvar itemElementScrollInterval = -1;\r\n\t\tvar isSameElement = false;\r\n\t\t\r\n\t\tvar setScrollWidth = function(width)\r\n\t\t{\r\n\t\t\tconfig.scrollWidth = width;\r\n\t\t\tvar item = props.horizontal;\r\n\t\t\titem.inputSize = width;\r\n\t\t\tsetScrollElementSize(item);\r\n\t\t};\r\n\t\t\r\n\t\tvar setScrollHeight = function(height)\r\n\t\t{\r\n\t\t\tconfig.scrollHeight = height;\r\n\t\t\tvar item = props.vertical;\r\n\t\t\titem.inputSize = height;\r\n\t\t\tsetScrollElementSize(item);\r\n\t\t};\r\n\t\t\r\n\t\tvar setScrollTop = function(scrollTop)\r\n\t\t{\r\n\t\t\tvar item = props.vertical;\r\n\t\t\tsetScrollPos(item,scrollTop);\r\n\t\t};\r\n\t\t\r\n\t\tvar getScrollTop = function()\r\n\t\t{\r\n\t\t\tvar item = props.vertical;\r\n\t\t\treturn item.element[item.scroll];\r\n\t\t};\r\n\t\t\r\n\t\tvar setScrollLeft = function(scrollLeft)\r\n\t\t{\r\n\t\t\tvar item = props.horizontal;\r\n\t\t\tsetScrollPos(item,scrollLeft);\r\n\t\t};\r\n\t\t\r\n\t\tvar getScrollLeft = function()\r\n\t\t{\r\n\t\t\tvar item = props.horizontal;\r\n\t\t\treturn item.element[item.scroll];\r\n\t\t};\r\n\t\t\r\n\t\tvar getVerticalScrollHeight = function()\r\n\t\t{\r\n\t\t\tvar item = props.vertical;\r\n\t\t\treturn item.element[item.scrollSize];\r\n\t\t};\r\n\t\t\r\n\t\tvar getHorizontalScrollWidth = function()\r\n\t\t{\r\n\t\t\tvar item = props.horizontal;\r\n\t\t\treturn item.element[item.scrollSize];\r\n\t\t};\r\n\t\t\r\n\t\tvar hasHorizontalScroller = function()\r\n\t\t{\r\n\t\t\treturn hasScroll(props.horizontal);\r\n\t\t};\r\n\t\t\r\n\t\tvar hasVerticalScroller = function()\r\n\t\t{\r\n\t\t\treturn hasScroll(props.vertical);\r\n\t\t};\r\n\t\t\r\n\t\tvar getHorizontalScroller = function()\r\n\t\t{\r\n\t\t\tvar item = props.horizontal;\r\n\t\t\treturn item.container;\r\n\t\t};\r\n\t\t\r\n\t\tvar getVerticalScroller = function()\r\n\t\t{\r\n\t\t\tvar item = props.vertical;\r\n\t\t\treturn item.container;\r\n\t\t};\r\n\t\t\r\n\t\tvar getHorizontalBar = function()\r\n\t\t{\r\n\t\t\tvar item = props.horizontal;\r\n\t\t\treturn item.scroller;\r\n\t\t};\r\n\t\t\r\n\t\tvar getVertcialBar = function()\r\n\t\t{\r\n\t\t\tvar item = props.vertical;\r\n\t\t\treturn item.scroller;\r\n\t\t};\r\n\t\t\r\n\t\tvar initialize = function()\r\n\t\t{\r\n\t\t\tutil = new NSUtil();\r\n\t\t\tsetConfig();\r\n\t\t\tsetProps();\r\n\t\t\tcreateComponent();\r\n\t\t\tif(isSameElement)\r\n\t\t\t{\r\n\t\t\t\tvar element = props[Object.keys(props)[0]].target;\r\n\t\t\t\tutil.addStyleClass(element,\"nsScrollerScrollable\");\r\n\t\t\t\tutil.addStyleClass(element,\"nsScrollerElement\");\r\n\t\t\t\t//DOMMouseScroll for Firefox\r\n\t\t\t\tutil.addEvent(element,\"mousewheel DOMMouseScroll\",mouseWheelHandler);\r\n\t\t\t\tutil.addEvent(element,\"scroll\",bodyScrollHandler);\r\n\t\t\t}\r\n\t\t\tif(config.otherScrollableElement && config.otherScrollableElement.length > 0)\r\n\t\t\t{\r\n\t\t\t\tfor(var count = 0;count < config.otherScrollableElement.length;count++)\r\n\t\t\t\t{\r\n\t\t\t\t\tvar element = config.otherScrollableElement[count];\r\n\t\t\t\t\t//DOMMouseScroll for Firefox\r\n\t\t\t\t\tutil.addEvent(element,\"mousewheel DOMMouseScroll\",mouseWheelHandler);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\tupdateScrollBars();\r\n\t\t\tutil.addEvent(window,\"resize\",updateWithDelay);\r\n\t\t\taddObserver();\r\n\t\t};\r\n\t\t\r\n\t\tvar setConfig = function()\r\n\t\t{\r\n\t\t\tif(!setting)\r\n\t\t\t{\r\n\t\t\t\tsetting = {};\r\n\t\t\t}\r\n\t\t\tconfig = {\r\n\t\t\t\tparentElement : setting[\"parentElement\"],\r\n\t\t\t\telement : setting[\"element\"],\r\n\t\t\t\tverticalElement : setting[\"verticalElement\"] || setting[\"element\"],\r\n\t\t\t\tverticalParentElement : setting[\"verticalParentElement\"] || setting[\"parentElement\"],\r\n\t\t\t\thorizontalElement : setting[\"horizontalElement\"] || setting[\"element\"],\r\n\t\t\t\thorizontalParentElement : setting[\"horizontalParentElement\"] || setting[\"parentElement\"],\r\n\t\t\t\totherScrollableElement : setting[\"otherScrollableElement\"],//for Grid if we have left,center and right body\r\n\t\t\t\thorizontalScrollButtons: setting[\"horizontalScrollButtons\"] || {enable:false,leftHTML:null,rightHTML:null},\r\n\t\t\t\tverticalScrollButtons: setting[\"verticalScrollButtons\"] || {enable:false,topHTML:null,bottomHTML:null},\r\n\t\t\t\telementPosition: setting[\"elementPosition\"] || \"relative\" ,// if content has fixable headers then use static (values: static,relative,absolute)\r\n\t\t\t\tenableCustomHandler: Boolean.parse(setting[\"enableCustomHandler\"]),\r\n\t\t\t\tscrollWidth: setting[\"scrollWidth\"],\r\n\t\t\t\tscrollHeight: setting[\"scrollHeight\"],\r\n\t\t\t\tenableMoveOnClick: Boolean.parse(setting[\"enableMoveOnClick\"]),\r\n\t\t\t\tenableAnimation: Boolean.parse(setting[\"enableAnimation\"]),\r\n\t\t\t};\r\n\t\t\tif(!config.verticalElement && !config.horizontalElement)\r\n\t\t\t{\r\n\t\t\t\tutil.throwNSError(\"NSScroller\",\"Element in setting is missing\");\r\n\t\t\t}\r\n\t\t\tif(!config.verticalParentElement)\r\n\t\t\t{\r\n\t\t\t\tconfig.verticalParentElement = config.verticalElement.parentNode;\r\n\t\t\t}\r\n\t\t\tif(!config.horizontalParentElement)\r\n\t\t\t{\r\n\t\t\t\tconfig.horizontalParentElement = config.horizontalElement.parentNode;\r\n\t\t\t}\r\n\t\t\tif(config.verticalElement && config.horizontalElement && config.verticalElement == config.horizontalElement)\r\n\t\t\t{\r\n\t\t\t\tisSameElement = true;\r\n\t\t\t}\r\n\t\t\t//parentNode = config.element.parentNode;\r\n\t\t\tif(config.horizontalScrollButtons.enable)\r\n\t\t\t{\r\n\t\t\t\tif(!config.horizontalScrollButtons.leftHTML)\r\n\t\t\t\t{\r\n\t\t\t\t\tconfig.horizontalScrollButtons.leftHTML = '<span class=\"nsScrollerControlBtnLeft\"></span>';\r\n\t\t\t\t}\r\n\t\t\t\tif(!config.horizontalScrollButtons.rightHTML)\r\n\t\t\t\t{\r\n\t\t\t\t\tconfig.horizontalScrollButtons.rightHTML = '<span class=\"nsScrollerControlBtnRight\"></span>';\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\tif(config.verticalScrollButtons.enable)\r\n\t\t\t{\r\n\t\t\t\tif(!config.verticalScrollButtons.topHTML)\r\n\t\t\t\t{\r\n\t\t\t\t\tconfig.verticalScrollButtons.topHTML = '<span class=\"nsScrollerControlBtnUp\"></span>';\r\n\t\t\t\t}\r\n\t\t\t\tif(!config.verticalScrollButtons.bottomHTML)\r\n\t\t\t\t{\r\n\t\t\t\t\tconfig.verticalScrollButtons.bottomHTML = '<span class=\"nsScrollerControlBtnDown\"></span>';\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t};\r\n\t\t\r\n\t\tvar setProps = function()\r\n\t\t{\r\n\t\t\tprops = {\r\n\t\t\t\t vertical: {\r\n\t\t\t\t x: \"Y\",direction:\"v\", displayDirection:\"vertical\", pos: \"top\", \r\n\t\t\t\t size: \"height\",crossSize: \"width\", crossMinSize: \"min-width\", crossMaxSize: \"max-width\",\r\n\t\t\t\t client: \"clientHeight\", crossClient: \"clientWidth\",\r\n\t\t\t\t scrollEdge: \"scrollLeft\",offset: \"offsetHeight\", crossOffset: \"offsetWidth\", offsetPos: \"offsetTop\",\r\n\t\t\t\t scroll: \"scrollTop\", scrollSize: \"scrollHeight\",barTopLimit:0,containerCSS:\"nsScrollerVerticalContainer\",\r\n\t\t\t\t scrollerCSS:\"nsScrollerVerticalBar\",buttonProp:\"verticalScrollButtons\",beforeButtonProp:\"topHTML\",\r\n\t\t\t\t afterButtonProp:\"bottomHTML\",beforeButtonCSS:\"nsScrollerButtonUp\",afterButtonCSS:\"nsScrollerButtonDown\",\r\n\t\t\t\t elementPosition:config.elementPosition,inputSize:config.scrollHeight,decreaseScrollSize:false,\r\n\t\t\t\t targetProp:\"verticalElement\",targetParentProp:\"verticalParentElement\",isMouseWheelReq:true,\r\n\t\t\t\t eventProp:\"clientY\",paddingStart:\"paddingTop\",paddingEnd:\"paddingBottom\"\r\n\t\t\t\t },\r\n\t\t\t\t horizontal: {\r\n\t\t\t\t x: \"X\",direction:\"h\",displayDirection:\"horizontal\", pos: \"left\",\r\n\t\t\t\t size: \"width\",crossSize: \"height\", crossMinSize: \"min-height\", crossMaxSize: \"max-height\",\r\n\t\t\t\t client: \"clientWidth\", crossClient: \"clientHeight\",\r\n\t\t\t\t scrollEdge: \"scrollTop\",offset: \"offsetWidth\", crossOffset: \"offsetHeight\", offsetPos: \"offsetLeft\",\r\n\t\t\t\t scroll: \"scrollLeft\", scrollSize: \"scrollWidth\",barTopLimit:0,containerCSS:\"nsScrollerHorizontalContainer\",\r\n\t\t\t\t scrollerCSS:\"nsScrollerHorizontalBar\",buttonProp:\"horizontalScrollButtons\",beforeButtonProp:\"leftHTML\",\r\n\t\t\t\t afterButtonProp:\"rightHTML\",beforeButtonCSS:\"nsScrollerButtonLeft\",afterButtonCSS:\"nsScrollerButtonRight\",\r\n\t\t\t\t elementPosition:config.elementPosition,inputSize:config.scrollWidth,decreaseScrollSize:false,\r\n\t\t\t\t targetProp:\"horizontalElement\",targetParentProp:\"horizontalParentElement\",isMouseWheelReq:false,\r\n\t\t\t\t eventProp:\"clientX\",paddingStart:\"paddingLeft\",paddingEnd:\"paddingRight\"\r\n\t\t\t\t }\r\n\t\t\t};\r\n\t\t};\r\n\t\t\r\n\t\tvar setScrollPos = function(item,scrollPos)\r\n\t\t{\r\n\t\t\tselectedItem = item;\r\n\t\t\tif(selectedItem)\r\n\t\t\t{\r\n\t\t\t\tutil.addEvent(selectedItem.element,\"scroll\",scrollableElementScrollHandler);\r\n\t\t\t\tsetScrollableItems(selectedItem,scrollPos);\r\n\t\t\t}\r\n\t\t};\r\n\t\t\r\n\t\tvar applyStyle = function(item,on) \r\n\t\t{\r\n\t var overflow = on ? 'hidden' : null;\r\n\t var msOverflowStyle = on ? 'none' : null;\r\n\t\r\n\t util.css(item.target.parentNode, {\r\n\t overflow: overflow,\r\n\t msOverflowStyle: msOverflowStyle,\r\n\t position: (item.elementPosition == 'static') ? '' : 'relative'\r\n\t });\r\n\t\r\n\t var scroll = on ? 'scroll' : null;\r\n\t var axis = item.direction == 'v' ? 'y' : 'x';\r\n\t var css = {};\r\n\t\r\n\t css['overflow-' + axis] = scroll;\r\n\t css['box-sizing'] = 'border-box';\r\n\t css.margin = '0';\r\n\t css.border = '0';\r\n\t\r\n\t if(item.elementPosition == 'absolute') \r\n\t {\r\n\t \tcss.position = 'absolute';\r\n\t \tcss.top = '0';\r\n\t\r\n\t if (item.direction == 'h') \r\n\t {\r\n\t \tcss.left = '0';\r\n\t } \r\n\t else \r\n\t {\r\n\t \tcss.bottom = '0';\r\n\t \tcss.right = item.rtl ? '0' : '';\r\n\t \tcss.left = item.rtl ? '' : '0';\r\n\t }\r\n\t }\r\n\t util.css(item.target,css);\r\n\t };\r\n\t \r\n\t\tvar onScrollerMouseDown = function(event,scroller) \r\n\t\t{\r\n\t\t\tsetSelectedItem(event,null,true);\r\n\t\t\tif(selectedItem)\r\n\t\t\t{\r\n\t\t\t event.preventDefault();\r\n\t\t\t event.stopPropagation();\r\n\t\t\t if(selectedItem.activeCSS)\r\n\t\t\t {\r\n\t\t\t \tutil.addStyleClass(selectedItem.scroller,selectedItem.activeCSS);\r\n\t\t\t }\r\n\t\t\t dispatchScrollStartEvent(selectedItem,event);\r\n\t\t\t}\r\n\t\t};\r\n\t\t\r\n\t\tvar setSelectedItem = function(event,target,setScrollPos)\r\n\t\t{\r\n\t\t\ttarget = target ? target : event.target;\r\n\t\t\tselectedItem = getItemByScroller(target);\r\n\t\t\tif(selectedItem)\r\n\t\t\t{\r\n\t\t\t\tselectedItem.dragging = true;\r\n\t\t\t\tif(setScrollPos)\r\n\t\t\t\t{\r\n\t\t\t\t\tselectedItem.scrollerPos = getCursorPosition(selectedItem,event) - selectedItem.barPos;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t};\r\n\t\t\r\n\t\tvar getItemByScroller = function(scroller)\r\n\t\t{\r\n\t\t\tfor(var key in props)\r\n\t\t\t{\r\n\t\t\t\tvar item = props[key];\r\n\t\t\t\tif(item.scroller == scroller)\r\n\t\t\t\t{\r\n\t\t\t\t\treturn item;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\t\r\n\t\t\treturn null;\r\n\t\t};\r\n\t\t\r\n\t\tvar createComponent = function()\r\n\t\t{\r\n\t\t\tfor(var key in props)\r\n\t\t\t{\r\n\t\t\t\tvar item = props[key];\r\n\t\t\t\titem.target = config[item.targetProp];\r\n\t\t\t\titem.targetParent = config[item.targetParentProp];\r\n\t\t\t\tif(!isSameElement)\r\n\t\t\t\t{\r\n\t\t\t\t\tutil.addStyleClass(item.target,\"nsScrollerScrollable\");\r\n\t\t\t\t\tutil.addStyleClass(item.target,\"nsScrollerElement\");\r\n\t\t\t\t\tif(item.isMouseWheelReq)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tutil.addEvent(item.target,\"mousewheel\",mouseWheelHandler);\r\n\t\t\t\t\t}\r\n\t\t\t\t\t//util.addEvent(item.target,\"scroll\",bodyScrollHandler);\r\n\t\t\t\t}\r\n\t\t\t\tvar container = createScroller(null,item.containerCSS,item.scrollerCSS);\r\n\t\t\t\tvar scroller = container.children[0];\r\n\t\t\t\tvar eleBefore = null;\r\n\t\t\t\tvar eleAfter = null;\r\n\t\t\t\tvar scrollerParent = container;\r\n\t\t\t\tif(config[item.buttonProp][\"enable\"])\r\n\t\t\t\t{\r\n\t\t\t\t\tvar eleBefore = createButton(item,item.beforeButtonCSS,config[item.buttonProp][item.beforeButtonProp]);\r\n\t\t\t\t\tcontainer.appendChild(eleBefore);\r\n\t\t\t\t\tscrollerParent = util.createDiv(null,\"nsScrollerBarParent-\" + item.direction);\r\n\t\t\t\t\tscrollerParent.appendChild(scroller);\r\n\t\t\t\t\tcontainer.appendChild(scrollerParent);\r\n\t\t\t\t\tvar eleAfter = createButton(item,item.afterButtonCSS,config[item.buttonProp][item.afterButtonProp]);\r\n\t\t\t\t\tcontainer.appendChild(eleAfter);\r\n\t\t\t\t\titem.buttonBefore = eleBefore;\r\n\t\t\t\t\titem.buttonAfter = eleAfter;\r\n\t\t\t\t}\r\n\t\t\t\tutil.addStyleClass(scrollerParent,\"nsScrollerBarParent\");\r\n\t\t\t\titem.targetParent.appendChild(container);\r\n\t\t\t\t//container.style[item.crossSize] = scroller[item.crossOffset] + \"px\";\r\n\t\t\t\tvar setting = {element:scroller,restriction:\"parent\",enableXAxis:(item.direction != \"v\"),enableYAxis:(item.direction == \"v\"),\r\n\t\t\t\t\t\t\t dragStartingCallback:onScrollerMouseDown,draggingCallback:docMouseMoveHandler,dragEndCallback:docMouseUpHandler,\r\n\t\t\t\t\t\t\t enableMoveOnClick:config.enableMoveOnClick,moveOnClickCallback:scrollerClickHandler};\r\n\t\t\t\tvar objDrag = new nsScrollerDraggable(setting);\r\n\t\t\t\tvar divScrollCause = util.createDiv(null);\r\n\t\t\t\tdivScrollCause.innerHTML = \"&nbsp;\";\r\n\t\t\t\tvar divScroll = util.createDiv(\"divTest\" + item.x);\r\n\t\t\t\tvar css = {};\r\n\t\t\t\tcss[\"position\"] = \"absolute\";\r\n\t\t css[\"overflow-\" + item.x.toLowerCase()] = \"scroll\";\r\n\t\t css[\"left\"] = \"-9999px\";\r\n\t\t css[\"top\"] = \"-9999px\";\r\n\t\t util.css(divScroll,css);\r\n\t\t\t\tdivScroll.appendChild(divScrollCause);\r\n\t\t\t\tdocument.body.appendChild(divScroll);\r\n\t\t\t\titem.scrollContainer = container;\r\n\t\t\t\titem.container = scrollerParent;\r\n\t\t\t\titem.scroller = scroller;\r\n\t\t\t\titem.element = divScroll;\r\n\t\t\t\titem.scrollableElementCause = divScrollCause;\r\n\t\t\t\titem.objDrag = objDrag;\r\n\t\t\t\tsetScrollElementSize(item);\r\n\t\t\t}\r\n\t\t\tif(isSameElement)\r\n\t\t\t{\r\n\t\t\t\tdivScrollBarCorner = util.createDiv(null,\"nsScrollBarCorner\");\r\n\t\t\t\tprops[Object.keys(props)[0]].targetParent.appendChild(divScrollBarCorner);\r\n\t\t\t}\r\n\t\t};\r\n\t\t\r\n\t\tvar createScroller = function(id,cssContainer,cssScroller)\r\n\t\t{\r\n\t\t\tcssContainer = cssContainer ? cssContainer : \"\";\r\n\t\t\tcssScroller = cssScroller ? cssScroller : \"\";\r\n\t\t\tvar scrollContainer = util.createDiv(null,\"nsScrollerContainer \" + cssContainer);\r\n\t\t\tvar scroller = util.createDiv(null,\"nsScrollerBar \" + cssScroller);\r\n\t\t\tscrollContainer.appendChild(scroller);\r\n\t\t\treturn scrollContainer;\r\n\t\t};\r\n\t\t\r\n\t\tvar createButton = function(item,css,html)\r\n\t\t{\r\n\t\t\tvar div = util.createDiv(null,\"nsScrollerControl nsScrollerControl-\" + item.direction);\r\n\t\t\tdiv.innerHTML = html;\r\n\t\t\tutil.addStyleClass(div,css);\r\n\t\t\t//util.addEvent(div,\"click\",btnControlClickHandler);\r\n\t\t\tutil.addEvent(div,\"mousedown\",btnMouseDownHandler);\r\n\t\t\tutil.addEvent(div,\"dblclick\",btnMouseDownHandler);\r\n\t\t\tutil.addEvent(div,\"mouseup\",clearScroll);\r\n\t\t\tutil.addEvent(div,\"mouseout\",clearScroll);\r\n\t\t\treturn div;\r\n\t\t};\r\n\t\t\r\n\t\tvar btnMouseDownHandler = function(event)\r\n\t\t{\r\n\t\t\t//console.log(\"btnMouseDownHandler \" + event.type);\r\n\t\t\tbtnControlClickHandler(event);\r\n\t\t\tclearTimeout(interval);\r\n\t\t\tinterval = setTimeout(function(){btnMouseDownHandler(event);}, 200);\r\n\t\t};\r\n\t\t\r\n\t\tvar clearScroll = function(event)\r\n\t\t{\r\n\t\t\t//console.log(\"clearScroll \" + event.type);\r\n\t\t\tclearTimeout(interval);\r\n\t\t\tinterval = null;\r\n\t\t\tlastScrollPos = -1;\r\n\t\t};\r\n\t\t\r\n\t\tvar btnControlClickHandler = function(event)\r\n\t\t{\r\n\t\t\tevent = util.getEvent(event);\r\n\t\t\tvar target = event.target;\r\n\t\t\tvar parent = util.findParent(target,null,\".nsScrollerContainer\");\r\n\t\t\tvar scroller = parent.querySelector(\".nsScrollerBar\");\r\n\t\t\tsetSelectedItem(event,scroller,true);\r\n\t\t\tif(selectedItem)\r\n\t\t\t{\r\n\t\t\t\tvar btnParent = util.findParent(target,null,\".nsScrollerControl\");\r\n\t\t\t\tvar isAdd = true;\r\n\t\t\t\tif(util.hasStyleClass(btnParent,selectedItem.beforeButtonCSS))\r\n\t\t\t\t{\r\n\t\t\t\t\tisAdd = false;\r\n\t\t\t\t}\r\n\t\t\t\tvar oldPos = scrollableElementPosition(selectedItem);\r\n\t\t\t\tvar newPos = isAdd ? (oldPos + 30) : (oldPos - 30);\r\n\t\t\t\tutil.addEvent(selectedItem.element,\"scroll\",scrollableElementScrollHandler);\r\n\t\t\t\tscrollableElementPosition(selectedItem,newPos);\r\n\t\t\t\t//selectedItem = null;\r\n\t\t\t\tevent.preventDefault();\r\n\t\t\t\tevent.stopPropagation();\r\n\t\t\t}\r\n\t\t};\r\n\t\t\r\n\t\tvar mouseWheelHandler = function(event)\r\n\t\t{\r\n\t\t\tevent = util.getEvent(event);\r\n\t\t\tvar element = props.vertical.targetParent;\r\n\t\t\tvar verticalScroller = element.querySelector(\".nsScrollerVerticalBar\");\r\n\t\t\tsetSelectedItem(event,verticalScroller,true);\r\n\t\t\tif(selectedItem)\r\n\t\t\t{\r\n\t\t\t\tutil.addEvent(selectedItem.element,\"scroll\",scrollableElementScrollHandler);//selectedItem.objDrag.setElementPos(null,100);\r\n\t\t\t\tvar oldPos = selectedItem.element[selectedItem.scroll];\r\n\t\t\t\tvar newPos = oldPos + event[\"delta\" + selectedItem.x];\r\n\t\t\t\tselectedItem.element[selectedItem.scroll] = newPos;\r\n\t\t\t\tif(config.enableCustomHandler)\r\n\t\t\t\t{\r\n\t\t\t\t\tevent.preventDefault();\r\n\t\t\t\t\tevent.stopPropagation();\r\n\t\t\t\t}\r\n\t\t\t\tdispatchScrollingEvent(selectedItem,newPos,oldPos,event);\r\n\t\t\t\tmouseWheelEndEvent(selectedItem,event);\r\n\t\t\t}\r\n\t\t};\r\n\t\t\r\n\t\tvar mouseWheelEndEvent = function(item,event)\r\n\t\t{\r\n\t\t\tif(mouseWheelEndInterval)\r\n\t\t\t{\r\n\t\t\t\tclearInterval(mouseWheelEndInterval);\r\n\t\t\t\tmouseWheelEndInterval = null;\r\n\t\t\t\tmouseWheelEndInterval = setInterval(function() {\r\n\t\t\t\t\tdispatchScrollEndEvent(item,event);\r\n\t\t }, 300); \r\n\t\t\t}\r\n\t\t};\r\n\t\t\r\n\t\tvar scrollableElementScrollHandler = function(event)\r\n\t\t{\r\n\t\t\tevent = util.getEvent(event);\r\n\t\t\tif(selectedItem)\r\n\t\t\t{\r\n\t\t\t\telementScrollHandler(selectedItem.element,selectedItem,event);\r\n\t\t\t\tsetIsInternalWithOutDelay = false;\r\n\t\t\t\tisInternalScroll = true;\r\n\t\t\t\tutil.removeEvent(selectedItem.element,\"scroll\",scrollableElementScrollHandler);\r\n\t\t\t}\r\n\t\t};\r\n\t\t\r\n\t\tvar bodyScrollHandler = function(event)\r\n\t\t{\r\n\t\t\tif(!isInternalScroll)\r\n\t\t\t{\r\n\t\t\t\tconsole.log(\"In Element Scroll\");\r\n\t\t\t\tevent = util.getEvent(event);\r\n\t\t\t\tfor(var key in props)\r\n\t\t\t\t{\r\n\t\t\t\t\tvar item = props[key];\r\n\t\t\t\t\tvar scroller = item.scroller;\r\n\t\t\t\t\tsetSelectedItem(event,scroller,true);\r\n\t\t\t\t\tif(selectedItem)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tselectedItem.element[selectedItem.scroll] = selectedItem.target[selectedItem.scroll];\r\n\t\t\t\t\t\telementScrollHandler(selectedItem.target,selectedItem,event);\r\n\t\t\t\t\t\tisInternalScroll = true;\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\tif(setIsInternalWithOutDelay)\r\n\t\t\t{\r\n\t\t\t\tisInternalScroll = false;\r\n\t\t\t}\r\n\t\t\telse\r\n\t\t\t{\r\n\t\t\t\tif (itemElementScrollInterval != -1)\r\n\t\t\t\t{\r\n\t\t\t\t\tclearTimeout(itemElementScrollInterval);\r\n\t\t\t\t\titemElementScrollInterval = -1;\r\n\t\t\t\t\tsetIsInternalWithOutDelay = false;\r\n\t\t\t\t\tisInternalScroll = true;\r\n\t\t\t\t}\r\n\t\t\t\titemElementScrollInterval = setTimeout(\r\n\t\t\t\t\t\tfunction()\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tsetIsInternalWithOutDelay = true;\r\n\t\t\t\t\t\t\tisInternalScroll = false;\r\n\t\t\t\t\t\t},1000);\r\n\t\t\t}\r\n\t\t};\r\n\t\t\r\n\t\tvar docMouseMoveHandler = function(event,scroller)\r\n\t\t{\r\n\t\t\tevent = util.getEvent(event);\r\n\t\t\tif(!selectedItem)\r\n\t\t\t{\r\n\t\t\t\tsetSelectedItem(event,scroller,true);\r\n\t\t\t}\r\n\t if(selectedItem)\r\n\t {\r\n\t \tdragHandler(selectedItem,event);\r\n\t \tscrollBody(selectedItem,event);\r\n\t }\r\n\t\t};\r\n\t\t\r\n\t\tvar docMouseUpHandler = function(event)\r\n\t\t{\r\n\t\t\tevent = util.getEvent(event);\r\n\t\t if(selectedItem.activeCSS)\r\n\t\t {\r\n\t\t \tutil.removeStyleClass(selectedItem.scroller,selectedItem.activeCSS);\r\n\t\t }\r\n\t\t updateScrollBars();\r\n\t\t var item = selectedItem;\r\n\t\t selectedItem = null;\r\n\t\t clearScroll();\r\n\t\t dispatchScrollEndEvent(item,event);\r\n\t\t};\r\n\t\t\r\n\t\tvar scrollerClickHandler = function(event,target,oldBarBound,newBarBound,oldTrackBound,newTrackBound)\r\n\t\t{\r\n\t\t\tevent = util.getEvent(event);\r\n\t\t\t//if(!selectedItem)\r\n\t\t\t//{\r\n\t\t\t\tsetSelectedItem(event,target,false);\r\n\t\t\t//}\r\n\t if(selectedItem)\r\n\t {\r\n\t \tvar item = selectedItem;\r\n\t \tvar perc = (event[item.eventProp] - oldTrackBound[item.pos]) / (oldTrackBound[item.size] - oldTrackBound[item.paddingStart] - oldTrackBound[item.paddingEnd]);\r\n\t \tvar scrollSize = item.scrollableElementCause[item.scrollSize];\r\n\t \tvar clientSize = item.targetParent[item.client];\r\n var newScrollPos = perc * (scrollSize - clientSize);\r\n if(config.enableAnimation)\r\n {\r\n \tvar isSmoothScrollSupported = 'scrollBehavior' in document.documentElement.style;\r\n \tif(isSmoothScrollSupported)\r\n \t{\r\n \t\titem.target.style.scrollBehavior = 'smooth';\r\n setTimeout(function(){item.target.style.scrollBehavior = null;}, 500);\r\n setScrollPos(item,newScrollPos);\r\n \t}\r\n \telse \r\n \t{\r\n \t\tvar scrollAnimateSetting = {element: item.target,direction:item.displayDirection,callback:function(){\r\n \t\t\tsetScrollPos(item,newScrollPos);\r\n \t\t}};\r\n \t\tvar scrollerAnimate = new NSScrollAnimator(scrollAnimateSetting);\r\n \t\tscrollerAnimate.scrollTo(newScrollPos);\r\n \t}\r\n }\r\n else\r\n {\r\n \tsetScrollPos(item,newScrollPos);\r\n }\r\n\t }\r\n\t\t};\r\n\t\t\r\n\t\tvar scrollBody = function(item,event)\r\n\t\t{\r\n\t\t\tupdateScrollPositions(item,false);\r\n\t\t};\r\n\t\t\r\n\t\tvar dragHandler = function(item,event)\r\n\t\t{\r\n\t\t\tif(!item.scrollerPos)\r\n\t\t\t{\r\n\t\t\t\titem.scrollerPos = 0;\r\n\t\t\t}\r\n\t\t\tvar relPos = barPositionToRelative(item,getCursorPosition(item,event) - item.scrollerPos);\r\n\t\t\tvar subPos = item.element[item.scrollSize] - item.element[item.client];\r\n\t\t\tvar scrollPos = relPos * subPos;\r\n\t\t\t//console.log(relPos + \" * \" + subPos + \" = \" + scrollPos);\r\n\t\t\tsetScrollableItems(item,scrollPos);\r\n\t\t};\r\n\t\t\r\n\t\tvar setScrollableItems = function(item,scrollPos)\r\n\t\t{\r\n\t\t\tscrollPos = Math.round(scrollPos);\r\n\t\t\tvar maxValue = item.element[item.scrollSize] - item.element[item.client];\r\n\t\t\t//console.log(scrollPos);\r\n\t\t\tif(scrollPos < 0)\r\n\t\t\t{\r\n\t\t\t\tscrollPos = 0;\r\n\t\t\t}\r\n\t\t\tif(scrollPos > maxValue)\r\n\t\t\t{\r\n\t\t\t\tscrollPos = maxValue;\r\n\t\t\t}\r\n\t\t\tvar lastScrollPos = item.element[item.scroll];\r\n\t\t\tif(lastScrollPos != scrollPos)\r\n\t\t\t{\r\n\t\t\t\t//console.log(scrollPos + \" == \" + item.element[item.scrollSize]);\r\n\t\t\t\tsetIsInternalWithOutDelay = true;\r\n\t\t\t\tisInternalScroll = true; \r\n\t\t\t\titem.element[item.scroll] = scrollPos;\r\n\t\t\t\tif(!config.enableCustomHandler)\r\n\t\t\t\t{\r\n\t\t\t\t\titem.target[item.scroll] = scrollPos;\r\n\t\t\t\t\tif(config.otherScrollableElement && config.otherScrollableElement.length > 0)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tfor(var count = 0;count < config.otherScrollableElement.length;count++)\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tvar element = config.otherScrollableElement[count];\r\n\t\t\t\t\t\t\telement[item.scroll] = scrollPos;\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t\tdispatchScrollingEvent(item,scrollPos,lastScrollPos);\r\n\t\t\t}\r\n\t\t\tlastScrollPos = scrollPos;\r\n\t\t};\r\n\t\t\r\n\t\tvar getCursorPosition = function(item,event)\r\n\t\t{\r\n\t \treturn event[\"client\" + item.x] || ((event.touches || {})[0] || {})[\"page\" + item.x];\r\n\t\t};\r\n\t\t\r\n\t\tvar updateScrollBars = function()\r\n\t\t{\r\n\t\t\tfor(var key in props)\r\n\t\t\t{\r\n\t\t\t\tvar item = props[key];\r\n\t\t\t\tapplyStyle(item,true);\r\n\t\t\t\tsetScrollElementSize(item);\r\n\t\t\t\tresizeHandler(item);\r\n\t\t\t\tupdateScrollPositions(item,true);\r\n\t\t\t}\r\n\t\t\tupdateScrollControls();\r\n\t\t};\r\n\t\t\r\n\t\tvar resizeHandler = function(item)\r\n\t\t{\r\n\t\t\tvar updatePos = function()\r\n\t\t\t{\r\n\t\t\t\t var offset = item.element[item.crossOffset];\r\n\t var client = item.element[item.crossClient];\r\n\t var padding = 0;\r\n\t var oldPos, newPos;\r\n\t if (isMacFF) \r\n\t {\r\n\t \tpadding = macScrollBarSize;\r\n\t }\r\n\t else if (client > 0 && offset === 0) \r\n\t {\r\n\t \toffset = client + operaMaxScrollBarSize;\r\n\t }\r\n\t if (offset) \r\n\t {\r\n\t \t var delta = offset - client + padding;\r\n\t \t if (item.elementPosition == 'static') \r\n\t \t {\r\n\t oldPos = util.css(item.element,item.crossSize);\r\n\t newPos = item.target.parentNode[item.crossClient] + delta + \"px\";\r\n\t if (oldPos != newPos) \r\n\t {\r\n\t setCrossSizes(item,item.element, newPos);\r\n\t }\r\n\t } \r\n\t \t else\r\n\t \t {\r\n\t \t\t var styles = {};\r\n\t var key = item.rtl ? 'Left' : 'Right';\r\n\t if (item.direction == 'h') \r\n\t {\r\n\t key = 'Bottom';\r\n\t }\r\n\t util.css(item.element, styles);\r\n\t \t }\r\n\t \t \r\n\t }\r\n\t item.resizeLastFire = getCurrentTime();\r\n\t\t\t};\r\n\t\t\tvar container = item[\"container\"];\r\n\t\t\tvar scroller = item[\"scroller\"];\r\n\t\t\tvar scrollerSize = item[\"scrollerSize\"];\r\n\t\t\tvar barPos = item[\"barPos\"];\r\n\t\t\tvar minPeriod = (item.resizeDebounce === undefined) ? 300 : item.resizeDebounce;\r\n\t\t \tvar delay = 0;\r\n\t\t \tif (getCurrentTime() - item.resizeLastFire < minPeriod) \r\n\t\t \t{\r\n\t clearTimeout(item.resizePauseTimer);\r\n\t delay = minPeriod;\r\n\t }\r\n\t\t \tif (delay) \r\n\t\t \t{\r\n\t\t \t\titem.resizePauseTimer = setTimeout(updatePos, delay);\r\n\t } \r\n\t\t \telse \r\n\t\t \t{\r\n\t\t \t\tupdatePos();\r\n\t }\r\n\t\t};\r\n\t\t\r\n\t\tvar elementScrollHandler = function(element,item,event)\r\n\t\t{\r\n\t\t\tif(element && item)\r\n\t\t\t{\r\n\t\t\t\tvar elementOffset = element[item.offset];\r\n\t\t\t\tif(item.buttonBefore)\r\n\t\t\t\t{\r\n\t\t\t\t\telementOffset = elementOffset - item.buttonBefore[item.offset];\r\n\t\t\t\t}\r\n\t\t\t\tif(item.buttonAfter)\r\n\t\t\t\t{\r\n\t\t\t\t\telementOffset = elementOffset - item.buttonAfter[item.offset];\r\n\t\t\t\t}\r\n\t\t\t\titem[\"barPos\"] = Math.round((elementOffset/element[item.scrollSize]) * element[item.scroll]);\r\n\t\t\t\tsetBarPosition(item, item[\"barPos\"]);\r\n\t\t\t}\r\n\t\t};\r\n\t\t\r\n\t\tvar setElementScrollPos = function(element,item,newScrollPos)\r\n\t\t{\r\n\t\t\tif(config.enableAnimation)\r\n {\r\n \t/*var isSmoothScrollSupported = 'scrollBehavior' in document.documentElement.style;\r\n \tif(isSmoothScrollSupported)\r\n \t{\r\n \t\telement.style.scrollBehavior = 'smooth';\r\n setTimeout(function(){element.style.scrollBehavior = null;}, 500);\r\n \t}\r\n \telse \r\n \t{*/\r\n \t\tvar scrollAnimateSetting = {element: element,direction:item.displayDirection,callback:function(){\r\n \t\t}};\r\n \t\tvar scrollerAnimate = new NSScrollAnimator(scrollAnimateSetting);\r\n \t\tscrollerAnimate.scrollTo(newScrollPos);\r\n \t//}\r\n }\r\n\t\t};\r\n\t\t\r\n\t\tvar addObserver = function()\r\n\t\t{\r\n\t\t\tvar mutationProp = { attributes: false, childList: true, subtree: true};\r\n\t\t\tvar callback = function(mutationsList, observer) \r\n\t\t\t{\r\n\t\t\t\tfor(var count = 0;count < mutationsList.length;count++)\r\n\t\t\t {\r\n\t\t\t \tvar mutation = mutationsList[count];\r\n\t\t\t if (mutation.type == 'childList') \r\n\t\t\t {\r\n\t\t\t \tupdateWithDelay();\r\n\t\t\t }\r\n\t\t\t }\r\n\t\t\t};\r\n\t\t\tvar mutationObserver = new MutationObserver(callback);\r\n\t\t\tif(isSameElement)\r\n\t\t\t{\r\n\t\t\t\tvar element = props[Object.keys(props)[0]].target;\r\n\t\t\t\tmutationObserver.observe(element,mutationProp);\r\n\t\t\t}\r\n\t\t\telse\r\n\t\t\t{\r\n\t\t\t\tfor(key in props)\r\n\t\t\t\t{\r\n\t\t\t\t\tvar item = props[key];\r\n\t\t\t\t\tmutationObserver.observe(item.target,mutationProp);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t};\r\n\t\t\r\n\t\tvar updateWithDelay = function()\r\n\t\t{\r\n\t\t\tstopDelayInterval();\r\n\t\t\tdelayInterval = setInterval(function() {\r\n\t\t\t\tupdateScrollBars();\r\n\t\t\t\tstopDelayInterval();\r\n\t }, 300); \r\n\t\t};\r\n\t\t\r\n\t\tvar stopDelayInterval = function()\r\n\t\t{\r\n\t\t\tif(delayInterval)\r\n\t\t\t{\r\n\t\t\t\tclearInterval(delayInterval);\r\n\t\t\t\tdelayInterval = null;\r\n\t\t\t}\r\n\t\t};\r\n\t\t\r\n\t\tvar setCrossSizes = function(item,element,size) \r\n\t\t{\r\n\t var styles = {};\r\n\t styles[item.crossSize] = size;\r\n\t styles[item.crossMinSize] = size;\r\n\t styles[item.crossMaxSize] = size;\r\n\t util.css(element, styles);\r\n\t };\r\n\t\t\r\n\t\tvar getCurrentTime = function()\r\n\t\t{\r\n\t\t\t return new Date().getTime();\r\n\t\t};\r\n\t\t\r\n\t\tvar updateScrollPositions = function(item,isReset,isSetBarPos)\r\n\t\t{\r\n\t\t\tcheckScroll(item);\r\n\t\t\tvar container = item[\"container\"];\r\n\t\t\tvar scroller = item[\"scroller\"];\r\n\t\t\tvar scrollerSize = item[\"scrollerSize\"];\r\n\t\t\tvar barPos = item[\"barPos\"];\r\n\t\t\tvar extraOffset = isBothScrollPresent() ? 16 : 0;\r\n\t\t\tvar newBarSize = (container[item.client] - item.barTopLimit) * (item.element[item.client] / item.element[item.scrollSize]);\r\n\t\t\t/*if(config[item.buttonProp][\"enable\"])\r\n\t\t\t{\r\n\t\t\t\t\r\n\t\t\t}*/\r\n\t\t\tif((newBarSize - extraOffset) > 0)\r\n\t\t\t{\r\n\t\t\t\tnewBarSize = newBarSize - extraOffset;\r\n\t\t\t}\r\n\t\t\t//console.log(item.displayDirection + \" , \" + container[item.client] + \" , \" + item.barTopLimit + \" , \" + item.element[item.client] + \" , \" + item.element[item.scrollSize]);\r\n\t // Positioning bar\r\n\t if (isReset || parseInt(scrollerSize, 10) != parseInt(newBarSize, 10)) \r\n\t {\r\n\t setScrollerSize(item,newBarSize);\r\n\t item[\"scrollerSize\"] = newBarSize;\r\n\t }\r\n\t item[\"barPos\"] = relativeToBarPosition(item,relativePosition(item));\r\n\t if(isSetBarPos)\r\n\t {\r\n\t \tsetBarPosition(item, item[\"barPos\"]);\r\n\t }\r\n\t\t};\r\n\t\t\r\n\t\tvar setBarPosition = function(item,position)\r\n\t\t{\r\n\t\t\tvar scroller = item[\"scroller\"];\r\n\t\t\tvar sendItem = {deltaX:null,deltaY:null};\r\n\t\t\tsendItem[\"delta\" + item.x] = position - parseInt(scroller.style[item.pos]);\r\n\t\t\titem.objDrag.setPosition(sendItem.deltaX,sendItem.deltaY);\r\n\t\t\tvar oldPos = scroller.style[item.pos];\r\n\t var newPos = position + \"px\";\r\n\t if (newPos && newPos != oldPos) \r\n\t {\r\n\t \tscroller.style[item.pos] = newPos;\r\n\t }\r\n\t\t};\r\n\t\t\r\n\t\tvar setScrollerSize = function(item,size) \r\n\t\t{\r\n\t\t\tvar scroller = item[\"scroller\"];\r\n\t \tvar barMinSize = item.barMinSize || 20;\r\n\t \tvar newSize = size;\r\n\t if (newSize > 0 && newSize < barMinSize) \r\n\t {\r\n\t \tnewSize = barMinSize;\r\n\t }\r\n\t if(scroller) \r\n\t {\r\n\t \tscroller.style[item.size] = parseInt(newSize, 10) + \"px\";\r\n\t }\r\n\t };\r\n\t \r\n\t var setScrollElementSize = function(item) \r\n\t\t{\r\n\t \tvar scrollCss = {};\r\n\t \t//console.log(item.displayDirection + \" , \" + config.element[item.offset] + \" , \" + config.element[item.scrollSize]);\r\n\t \tvar offset = 0;\r\n\t \tvar scrollBarSize = item.decreaseScrollSize ? getScrollBarSize(item) : 0;\r\n\t \tscrollCss[item.size] = item.target[item.client] - scrollBarSize + \"px\";\r\n\t \tutil.css(item.element,scrollCss);\r\n\t \tvar causeCss = {};\r\n\t \tif(util.isUndefinedOrNull(item.inputSize) || parseInt(item.inputSize) <= 0)\r\n\t \t{\r\n\t \t\tcauseCss[item.size] = (item.target[item.scrollSize]) + \"px\";\r\n\t \t}\r\n\t \telse\r\n\t \t{\r\n\t \t\tcauseCss[item.size] = parseInt(item.inputSize) + \"px\";\r\n\t \t}\r\n\t \tutil.css(item.scrollableElementCause,causeCss);\r\n\t\t};\r\n\t \r\n\t var relativePosition = function(item,position)\r\n\t {\r\n\t \tvar size = item.element[item.scrollSize] - item.element[item.client];\r\n\t var newPos;\r\n\t if(position) \r\n\t {\r\n\t \tnewPos = scrollableElementPosition(item,position * size);\r\n\t } \r\n\t else \r\n\t {\r\n\t \tnewPos = scrollableElementPosition(item);\r\n\t }\r\n\t return newPos / (size || 1);\r\n\t };\r\n\t \r\n\t var scrollableElementPosition = function(item,x) \r\n\t { \r\n\t var ie = \"page\" + item.x + \"Offset\";\r\n\t var key = (item.element[ie]) ? ie : item.scroll;\r\n\t if (!util.isUndefined(x)) \r\n\t {\r\n\t \tif(key === item.scroll)\r\n\t \t{\r\n\t \t\tsetScrollableItems(item,x);\r\n\t \t}\r\n\t \telse\r\n\t \t{\r\n\t \t\titem.element[key] = x;\r\n\t \t}\r\n\t }\r\n\t return item.element[key];\r\n\t };\r\n\t \r\n\t var relativeToBarPosition = function(item,pos) \r\n\t {\r\n\t return pos * getPos(item) + item.barTopLimit;\r\n\t };\r\n\t \r\n\t var barPositionToRelative = function(item,pos) \r\n\t {\r\n\t return (pos - item.barTopLimit) / getPos(item);\r\n\t };\r\n\t \r\n\t var getPos = function(item)\r\n\t {\r\n\t \treturn item.container[item.client] - item.barTopLimit - item.scroller[item.offset];\r\n\t };\r\n\t\t\r\n\t\tvar checkScroll = function(item)\r\n\t\t{\r\n\t\t\tvar scrollContainer = item[\"scrollContainer\"];\r\n\t\t\tvar scroller = item[\"scroller\"];\r\n\t\t\tvar isOverflowing = hasScroll(item);\r\n\t\t\tif(isOverflowing)\r\n\t\t\t{\r\n\t\t\t\tutil.addStyleClass(item.target,\"nsScrollerScrollable-\" + item.direction);\r\n\t\t\t\tutil.removeStyleClass(scrollContainer,\"nsScrollerHidden\");\r\n\t\t\t}\r\n\t\t\telse\r\n\t\t\t{\r\n\t\t\t\tutil.removeStyleClass(item.target,\"nsScrollerScrollable-\" + item.direction);\r\n\t\t\t\tutil.addStyleClass(scrollContainer,\"nsScrollerHidden\");\r\n\t\t\t}\r\n\t\t};\r\n\t\t\r\n\t\tvar hasScroll = function(item)\r\n\t\t{\r\n\t\t\tvar isOverflowing = item.element[item.client] < item.element[item.scrollSize];\r\n\t\t\treturn isOverflowing;\r\n\t\t};\r\n\t\t\r\n\t\tvar updateScrollControls = function()\r\n\t\t{\r\n\t\t\tvar scrollPresent = isBothScrollPresent();\r\n\t\t\tfor(var key in props)\r\n\t\t\t{\r\n\t\t\t\tvar item = props[key];\r\n\t\t\t\tvar scrollContainer = item[\"scrollContainer\"];\r\n\t\t\t\tvar container = item[\"container\"];\r\n\t\t\t\tvar scroller = item[\"scroller\"];\r\n\t\t\t\tif(scrollPresent && isSameElement)\r\n\t\t\t\t{\r\n\t\t\t\t\tutil.addStyleClass(scrollContainer,item.containerCSS + \"-both\");\r\n\t\t\t\t\tutil.addStyleClass(scrollContainer,\"nsScrollerBarParent\" + \"-\" + item.direction + \"-both\");\r\n\t\t\t\t\tif(item.buttonAfter)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tutil.addStyleClass(item.buttonAfter,item.afterButtonCSS + \"-both\");\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t\telse\r\n\t\t\t\t{\r\n\t\t\t\t\tutil.removeStyleClass(scrollContainer,item.containerCSS + \"-both\");\r\n\t\t\t\t\tutil.removeStyleClass(scrollContainer,\"nsScrollerBarParent\" + \"-\" + item.direction + \"-both\");\r\n\t\t\t\t\tif(item.buttonAfter)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tutil.removeStyleClass(item.buttonAfter,item.afterButtonCSS + \"-both\");\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\tif(scrollPresent)\r\n\t\t\t{\r\n\t\t\t\tutil.removeStyleClass(divScrollBarCorner,\"nsScrollerHidden\");\r\n\t\t\t}\r\n\t\t\telse\r\n\t\t\t{\r\n\t\t\t\tutil.addStyleClass(divScrollBarCorner,\"nsScrollerHidden\");\r\n\t\t\t}\r\n\t\t};\r\n\t\t\r\n\t\tvar isBothScrollPresent = function()\r\n\t\t{\r\n\t\t\tvar arrScrollContainer = [];\r\n\t\t\tfor(key in props)\r\n\t\t\t{\r\n\t\t\t\tvar item = props[key];\r\n\t\t\t\tif(item && item.targetParent && item.targetParent.querySelectorAll(\".nsScrollerContainer\"))\r\n\t\t\t\t{\r\n\t\t\t\t\tvar arrCon = item.targetParent.querySelectorAll(\".nsScrollerContainer\");\r\n\t\t\t\t\tfor(var index in arrCon)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tarrScrollContainer.push(arrCon[index]);\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\tvar retValue = true;\r\n\t\t\tfor(var count = 0;count < arrScrollContainer.length;count++)\r\n\t\t\t{\r\n\t\t\t\tvar scrollContainer = arrScrollContainer[count];\r\n\t\t\t\tif(util.hasStyleClass(scrollContainer,\"nsScrollerHidden\"))\r\n\t\t\t\t{\r\n\t\t\t\t\tretValue = false;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\treturn retValue;\r\n\t\t};\r\n\t\t\r\n\t\tvar getScrollBarSize = function(item,element)\r\n\t\t{\r\n\t\t\tif(!element)\r\n\t\t\t{\r\n\t\t\t\telement = item.target;\r\n\t\t\t}\r\n\t\t\tvar scrollContainer = item[\"scrollContainer\"];\r\n\t\t\tif(util.hasStyleClass(scrollContainer,\"nsScrollerHidden\"))\r\n\t\t\t{\r\n\t\t\t\treturn 0;\r\n\t\t\t}\r\n\t\t\t//if Chrome then scrollbar size is 0 so the below condition is 0 but we should return the scrollbar size\r\n\t\t\tif((element[item.offset] - element[item.client]) == 0)\r\n\t\t\t{\r\n\t\t\t\treturn util.getScrollBarWidth();\r\n\t\t\t}\r\n\t\t\treturn 0;\r\n\t\t};\r\n\t\t\r\n\t\tvar remove = function()\r\n\t\t{\r\n\t\t\tfor(var key in props)\r\n\t\t\t{\r\n\t\t\t\tvar item = props[key];\r\n\t\t\t\tif(item.objDrag)\r\n\t\t\t\t{\r\n\t\t\t\t\titem.objDrag.remove();\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\tutil.removeEvent(window,\"resize\",updateWithDelay);\r\n\t\t\tclearScroll();\r\n\t\t\tif(mutationObserver)\r\n\t\t\t{\r\n\t\t\t\tmutationObserver.disconnect();\r\n\t\t\t}\r\n\t\t};\r\n\t\t\r\n\t\tvar dispatchScrollStartEvent = function(item,event)\r\n\t\t{\r\n\t\t\tvar eventItem = getEventItem(item,event);\r\n\t\t\tdispatchEvent(NSScroller.SCROLL_START,eventItem,eventItem,item);\r\n\t\t};\r\n\t\t\r\n\t\tvar dispatchScrollingEvent = function(item,newScrollPos,oldScrollPos,event)\r\n\t\t{\r\n\t\t\tvar eventItem = getEventItem(item,event || window.event,{oldScrollPos:oldScrollPos,scrollPos:newScrollPos}); \r\n\t\t\tdispatchEvent(NSScroller.SCROLLING,eventItem,eventItem,item);\r\n\t\t};\r\n\t\t\r\n\t\tvar dispatchScrollEndEvent = function(item,event)\r\n\t\t{\r\n\t\t\tvar eventItem = getEventItem(item,event); \r\n\t\t dispatchEvent(NSScroller.SCROLL_END,eventItem,eventItem,item);\r\n\t\t};\r\n\t\t\r\n\t\tvar getEventItem = function(item,event,objExtraProp)\r\n\t\t{\r\n\t\t\tvar position = getAbsoluteElementPosition(item.scroller);\r\n\t\t\tvar eventItem = {scroller:item.container,scrollBar:item.scroller,direction:item.displayDirection,scrollPos:item.element[item.scroll],orignalEvent: event,absoluteScrollBarPos: position};\r\n\t\t\tif(objExtraProp)\r\n\t\t\t{\r\n\t\t\t\tfor(var key in objExtraProp)\r\n\t\t\t\t{\r\n\t\t\t\t\teventItem[key] = objExtraProp[key];\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\treturn eventItem;\r\n\t\t};\r\n\t\t\r\n\t\tvar dispatchEvent = function(eventType,data,param,item,bubbles,cancelable)\r\n\t\t{\r\n\t\t\tutil.dispatchEvent(item.target,eventType,data,param,bubbles,cancelable);\r\n\t\t};\r\n\t\t\r\n\t\tvar getAbsoluteElementPosition = function(element) \r\n\t\t{\r\n\t\t\tvar position = {x:0,y:0};\r\n\t\t\tvar rec = element.getBoundingClientRect();\r\n\t\t\tposition = {y: rec.top + window.scrollY, x: rec.left + window.scrollX};\r\n\t\t\treturn position;\r\n\t\t};\r\n\t\t\r\n\t\tvar nsScrollerDraggable = function(setting)\r\n\t\t{\r\n\t\t\tvar self = this;\r\n\t\t\tvar util = null;\r\n\t\t\tvar config = {};\r\n\t\t\tvar objVar = {};\r\n\t\t\tvar fromMouseUpHandler = false;\r\n\t\t\tvar documentMouseMoveRef = null;\r\n\t\t\tvar documentMouseUpRef = null;\r\n\t\t\tvar documentTouchMoveRef = null;\r\n\t\t\tvar documentTouchEndRef = null;\r\n\t\t\t\r\n\t\t\tvar initialize = function()\r\n\t\t\t{\r\n\t\t\t\tutil = new NSUtil();\r\n\t\t\t\t