diff --git a/jquery-ui-scrollable.min.js b/jquery-ui-scrollable.min.js index f77c383..0e8f607 100644 --- a/jquery-ui-scrollable.min.js +++ b/jquery-ui-scrollable.min.js @@ -27,4 +27,4 @@ * jquery.ui.core.js * jquery.ui.widget.js */ -!function($){"use strict";var rootex=/^(?:html)$/i,max=Math.max,abs=Math.abs,round=Math.round,rhorizontal=/left|center|right/,rvertical=/top|center|bottom/,roffset=/[\+\-]\d+(\.[\d]+)?%?/,rposition=/^\w+/,rpercent=/%$/;function getOffsets(offsets,width,height){return[parseFloat(offsets[0])*(rpercent.test(offsets[0])?width/100:1),parseFloat(offsets[1])*(rpercent.test(offsets[1])?height/100:1)]}function parseCss(element,property){return parseInt($.css(element,property),10)||0}function trackScrolling(scroller){var _waiter=null;scroller.onscroll=function(e){if(!_waiter&&!scroller.ignoreScrolling){_waiter=setTimeout(function(){$.each(scroller.watch,function(){this._checkPositioning(e)});_waiter=null},$.osb.scrollable.CONFIG.throttler)}};scroller.element.on("scroll.scrollable",scroller.onscroll)}var monitor={scrollers:[],getScroller:function(obj){var scroller;for(var i=0;idoc.right,top:elem.bottomdoc.bottom};ret.inside=!ret.left&&!ret.right&&!ret.top&&!ret.bottom;ret.outside=!ret.inside;return ret},"goto":function(options){var self=this,options=options||{},offsets={},position=this.position(),targetWidth=this.container.width(),targetHeight=this.container.height(),elemWidth=this.element.outerWidth(true),elemHeight=this.element.outerHeight(true),dir=this.options.direction,target=this.container[0]===window?$("html"):this.container,scroll,atOffset,myOffset;if(!options.onlyOutside||options.onlyOutside&&!this.inView){$.each(["my","at"],function(){var pos=(options[this]||"").split(" "),horizontalOffset,verticalOffset;if(pos.length===1){pos=rhorizontal.test(pos[0])?pos.concat(["center"]):rvertical.test(pos[0])?["center"].concat(pos):["center","center"]}pos[0]=rhorizontal.test(pos[0])?pos[0]:"center";pos[1]=rvertical.test(pos[1])?pos[1]:"center";horizontalOffset=roffset.exec(pos[0]);verticalOffset=roffset.exec(pos[1]);offsets[this]=[horizontalOffset?horizontalOffset[0]:0,verticalOffset?verticalOffset[0]:0];options[this]=[rposition.exec(pos[0])[0],rposition.exec(pos[1])[0]]});if(options.at[0]==="right"){position.element.left-=targetWidth}else if(options.at[0]==="center"){position.element.left-=targetWidth/2}if(options.at[1]==="bottom"){position.element.top-=targetHeight}else if(options.at[1]==="center"){position.element.top-=targetHeight/2}atOffset=getOffsets(offsets.at,targetWidth,targetHeight);position.element.left-=atOffset[0];position.element.top-=atOffset[1];myOffset=getOffsets(offsets.my,elemWidth,elemHeight);if(options.my[0]==="right"){position.element.left+=elemWidth}else if(options.my[0]==="center"){position.element.left+=elemWidth/2}if(options.my[1]==="bottom"){position.element.top+=elemHeight}else if(options.my[1]==="center"){position.element.top+=elemHeight/2}position.element.left-=myOffset[0];position.element.top-=myOffset[1];scroll={};if(dir=="both"||dir=="horizontal")scroll.scrollLeft=round(position.element.left)+"px";if(dir=="both"||dir=="vertical")scroll.scrollTop=round(position.element.top)+"px";monitor.scrollInProgress(this,true);target.animate(scroll,{duration:options.duration||"slow",easing:options.easing||"swing",complete:function(){monitor.scrollInProgress(self,false);self._checkPositioning();if($.isFunction(options.complete))options.complete.call()}})}else{if($.isFunction(options.complete))options.complete.call(this.element)}}});$.expr[":"].scrollable=$.expr.createPseudo(function(dir){var dir=!dir||dir=="undefined"?"both":dir;return function(elem){var $el=$(elem),isRoot=rootex.test(elem.nodeName),styles=$el.css(["overflow-x","overflow-y"]),overflow={x:styles["overflow-x"]=="auto"||styles["overflow-x"]=="scroll",y:styles["overflow-y"]=="auto"||styles["overflow-y"]=="scroll"},test=false;if(!isRoot&&!overflow.x&&!overflow.y){return false}if(dir=="both"||dir=="vertical")test=test||(overflow.x||isRoot)&&elem.scrollWidth>elem.clientWidth;if(dir=="both"||dir=="horizontal")test=test||(overflow.y||isRoot)&&elem.scrollHeight>elem.clientHeight;return test}});$.propHooks.scrollTop=$.propHooks.scrollLeft={get:function(elem,prop){var result=null;if(elem.tagName==="HTML"||elem.tagName==="BODY"){if(prop==="scrollLeft"){result=window.scrollX}else if(prop==="scrollTop"){result=window.scrollY}}if(result==null){result=elem[prop]}return result}};$.Tween.propHooks.scrollTop=$.Tween.propHooks.scrollLeft={get:function(tween){return $.propHooks.scrollTop.get(tween.elem,tween.prop)},set:function(tween){if(tween.elem.tagName==="HTML"||tween.elem.tagName==="BODY"){tween.options.bodyScrollLeft=tween.options.bodyScrollLeft||window.scrollX;tween.options.bodyScrollTop=tween.options.bodyScrollTop||window.scrollY;if(tween.prop==="scrollLeft"){tween.options.bodyScrollLeft=Math.round(tween.now)}else if(tween.prop==="scrollTop"){tween.options.bodyScrollTop=Math.round(tween.now)}window.scrollTo(tween.options.bodyScrollLeft,tween.options.bodyScrollTop)}else if(tween.elem.nodeType&&tween.elem.parentNode){tween.elem[tween.prop]=tween.now}}};$.osb.scrollable.CONFIG={throttler:300}}(jQuery); \ No newline at end of file +!function($){"use strict";var rootex=/^(?:html)$/i,max=Math.max,abs=Math.abs,round=Math.round,rhorizontal=/left|center|right/,rvertical=/top|center|bottom/,roffset=/[\+\-]\d+(\.[\d]+)?%?/,rposition=/^\w+/,rpercent=/%$/;function getOffsets(offsets,width,height){return[parseFloat(offsets[0])*(rpercent.test(offsets[0])?width/100:1),parseFloat(offsets[1])*(rpercent.test(offsets[1])?height/100:1)]}function parseCss(element,property){return parseInt($.css(element,property),10)||0}function throttle(fn,threshhold,scope){threshhold||(threshhold=250);var last,deferTimer;return function(){var context=scope||this;var now=+new Date,args=arguments;if(last&&nowdoc.right,top:elem.bottomdoc.bottom};ret.inside=!ret.left&&!ret.right&&!ret.top&&!ret.bottom;ret.outside=!ret.inside;return ret},"goto":function(options){var self=this,options=options||{},offsets={},position=this.position(),targetWidth=this.container.width(),targetHeight=this.container.height(),elemWidth=this.element.outerWidth(true),elemHeight=this.element.outerHeight(true),dir=this.options.direction,target=this.container[0]===window?$("html"):this.container,scroll,atOffset,myOffset;if(!options.onlyOutside||options.onlyOutside&&!this.inView){$.each(["my","at"],function(){var pos=(options[this]||"").split(" "),horizontalOffset,verticalOffset;if(pos.length===1){pos=rhorizontal.test(pos[0])?pos.concat(["center"]):rvertical.test(pos[0])?["center"].concat(pos):["center","center"]}pos[0]=rhorizontal.test(pos[0])?pos[0]:"center";pos[1]=rvertical.test(pos[1])?pos[1]:"center";horizontalOffset=roffset.exec(pos[0]);verticalOffset=roffset.exec(pos[1]);offsets[this]=[horizontalOffset?horizontalOffset[0]:0,verticalOffset?verticalOffset[0]:0];options[this]=[rposition.exec(pos[0])[0],rposition.exec(pos[1])[0]]});if(options.at[0]==="right"){position.element.left-=targetWidth}else if(options.at[0]==="center"){position.element.left-=targetWidth/2}if(options.at[1]==="bottom"){position.element.top-=targetHeight}else if(options.at[1]==="center"){position.element.top-=targetHeight/2}atOffset=getOffsets(offsets.at,targetWidth,targetHeight);position.element.left-=atOffset[0];position.element.top-=atOffset[1];myOffset=getOffsets(offsets.my,elemWidth,elemHeight);if(options.my[0]==="right"){position.element.left+=elemWidth}else if(options.my[0]==="center"){position.element.left+=elemWidth/2}if(options.my[1]==="bottom"){position.element.top+=elemHeight}else if(options.my[1]==="center"){position.element.top+=elemHeight/2}position.element.left-=myOffset[0];position.element.top-=myOffset[1];scroll={};if(dir=="both"||dir=="horizontal")scroll.scrollLeft=round(position.element.left)+"px";if(dir=="both"||dir=="vertical")scroll.scrollTop=round(position.element.top)+"px";monitor.scrollInProgress(this,true);target.animate(scroll,{duration:options.duration||"slow",easing:options.easing||"swing",complete:function(){monitor.scrollInProgress(self,false);self._checkPositioning();if($.isFunction(options.complete))options.complete.call()}})}else{if($.isFunction(options.complete))options.complete.call(this.element)}}});$.expr[":"].scrollable=$.expr.createPseudo(function(dir){var dir=!dir||dir=="undefined"?"both":dir;return function(elem){var $el=$(elem),isRoot=rootex.test(elem.nodeName),styles=$el.css(["overflow-x","overflow-y"]),overflow={x:styles["overflow-x"]=="auto"||styles["overflow-x"]=="scroll",y:styles["overflow-y"]=="auto"||styles["overflow-y"]=="scroll"},test=false;if(!isRoot&&!overflow.x&&!overflow.y){return false}if(dir=="both"||dir=="vertical")test=test||(overflow.x||isRoot)&&elem.scrollWidth>elem.clientWidth;if(dir=="both"||dir=="horizontal")test=test||(overflow.y||isRoot)&&elem.scrollHeight>elem.clientHeight;return test}});$.propHooks.scrollTop=$.propHooks.scrollLeft={get:function(elem,prop){var result=null;if(elem.tagName==="HTML"||elem.tagName==="BODY"){if(prop==="scrollLeft"){result=window.scrollX}else if(prop==="scrollTop"){result=window.scrollY}}if(result==null){result=elem[prop]}return result}};$.Tween.propHooks.scrollTop=$.Tween.propHooks.scrollLeft={get:function(tween){return $.propHooks.scrollTop.get(tween.elem,tween.prop)},set:function(tween){if(tween.elem.tagName==="HTML"||tween.elem.tagName==="BODY"){tween.options.bodyScrollLeft=tween.options.bodyScrollLeft||window.scrollX;tween.options.bodyScrollTop=tween.options.bodyScrollTop||window.scrollY;if(tween.prop==="scrollLeft"){tween.options.bodyScrollLeft=Math.round(tween.now)}else if(tween.prop==="scrollTop"){tween.options.bodyScrollTop=Math.round(tween.now)}window.scrollTo(tween.options.bodyScrollLeft,tween.options.bodyScrollTop)}else if(tween.elem.nodeType&&tween.elem.parentNode){tween.elem[tween.prop]=tween.now}}};$.osb.scrollable.CONFIG={throttler:300}}(jQuery); \ No newline at end of file