PageSourceSearch

https://animalface.ru/js/frontend/lib/jquery.viewport.js?47

js animalface.ru collected 2026-10-08 09:22:23 UTC 7,741 bytes, 25 lines download raw bytes

1/**
2 * @Author Anton Zinovyev
3 * @Package: jquery.viewport
4 * @License: http://www.opensource.org/licenses/mit-license.php
5 */
6
7(function($){function hasScroll(element){return element?element.offsetHeight<element.scrollHeight||element.offsetWidth<element.scrollWidth:!1}
8function getScrollableParent(element){if(!element){return window.document.body}
9while(element.tagName!=='BODY'&&!hasScroll(element)){element=element.parentElement}
10return element}
11function getRelativePosition(element,viewport){let vpRect=viewport?(viewport.tagName==='BODY'?{top:0,left:0,width:window.innerWidth,right:window.innerWidth,height:window.innerHeight,bottom:window.innerHeight}:viewport.getBoundingClientRect()):{top:0,bottom:0,left:0,right:0,width:0,height:0},elRect=element?element.getBoundingClientRect():{top:0,bottom:0,left:0,right:0,width:0,height:0};return{viewport,viewportWidth:vpRect.width,viewportHeight:vpRect.height,element,elementWidth:elRect.width,elementHeight:elRect.height,top:elRect.top-vpRect.top,bottom:vpRect.bottom-elRect.bottom,left:elRect.left-vpRect.left,right:vpRect.right-elRect.right,}}
12function inViewport(element,threshold=0,viewport){let pos=getRelativePosition(element,viewport);return pos.top-threshold>=0&&pos.bottom-threshold>=0&&pos.left-threshold>=0&&pos.right-threshold>=0}
13function getState(element,threshold=0,allowPartly=!1,viewport){let pos=getRelativePosition(element,viewport);pos.inViewport=pos.top-threshold>=0&&pos.bottom-threshold>=0&&pos.left-threshold>=0&&pos.right-threshold>=0;if(pos.top-threshold>=0&&pos.bottom-threshold>=0){pos.vertical='inside'}
14else if(pos.top-threshold<=0&&pos.bottom-threshold<=0){pos.vertical='exceeds'}
15else if(allowPartly){pos.vertical=pos.top-threshold<=0?(pos.bottom-threshold-pos.viewportHeight)>pos.elementHeight?'above':'partly-above':(pos.top-threshold-pos.viewportHeight)>pos.elementHeight?'below':'partly-below'}
16else{pos.vertical=pos.top-threshold<=0?'above':'below'}
17if(pos.left-threshold>=0&&pos.right-threshold>=0){pos.horizontal='inside'}
18else if(pos.left-threshold<=0&&pos.right-threshold<=0){pos.horizontal='exceeds'}
19else if(allowPartly){pos.horizontal=pos.left-threshold<=0?(pos.right-threshold-pos.viewportWidth)>pos.elementWidth?'left':'partly-left':(pos.left-threshold-pos.viewportWidth)>pos.elementWidth?'right':'partly-right'}
20else{pos.horizontal=pos.top-threshold<=0?'left':'right'}
21return pos}
22let viewportFunctions={hasScroll(){if(!this.length){return!1}
23return hasScroll(this[0])},scrollableParent(){return getScrollableParent(this[0])},relativePosition(viewport=this.scrollableParent()){return getRelativePosition(this[0],viewport?(viewport instanceof $?viewport[0]:viewport):this.scrollableParent())},inViewport(threshold=0,viewport){if(!this.length){return!1}
24return inViewport(this[0],threshold,viewport||this.scrollableParent())},getState(threshold=0,allowPartly=!1,viewport){viewport=viewport||this.scrollableParent();if(!this.length){return{inViewport:!1,vertical:'inside',horizontal:'inside',top:0,bottom:0,left:0,right:0,width:0,height:0,viewportWidth:0,viewportHeight:0}}
25return getState(this[0],threshold,allowPartly,viewport)},};$.fn.viewport=function(){return{...this,...viewportFunctions}};$.extend($.expr[':'],{hasScroll(element){return hasScroll(element)},hasScrollVertical(element){return element.offsetHeight<element.scrollHeight},hasScrollHorizontal(element){return element.offsetWidth<element.scrollWidth},inViewport(element,i,meta){let param=(meta[3]||'').split(','),threshold=(param[0]&&(param[0]=param[0].trim()))?parseInt(param[0],10):0,viewport=(param[1]&&(param[1]=param[1].trim()))?($(param[1])[0]||undefined):undefined;return inViewport(element,threshold,viewport||getScrollableParent(element))},aboveTheViewport(element,i,meta){let param=(meta[3]||'').split(','),threshold=(param[0]&&(param[0]=param[0].trim()))?parseInt(param[0],10):0,viewport=(param[1]&&(param[1]=param[1].trim()))?($(param[1])[0]||undefined):undefined,pos=getRelativePosition(element,viewport||getScrollableParent(element));return pos.top-threshold<=0&&pos.bottom>=0},belowTheViewport(element,i,meta){let param=(meta[3]||'').split(','),threshold=(param[0]&&(param[0]=param[0].trim()))?parseInt(param[0],10):0,viewport=(param[1]&&(param[1]=param[1].trim()))?($(param[1])[0]||undefined):undefined,pos=getRelativePosition(element,viewport||getScrollableParent(element));return pos.bottom-threshold<=0&&pos.top>=0},leftOfViewport(element,i,meta){let param=(meta[3]||'').split(','),threshold=(param[0]&&(param[0]=param[0].trim()))?parseInt(param[0],10):0,viewport=(param[1]&&(param[1]=param[1].trim()))?($(param[1])[0]||undefined):undefined,pos=getRelativePosition(element,viewport||getScrollableParent(element));return pos.left-threshold<=0&&pos.right>=0}
25,rightOfViewport(element,i,meta){let param=(meta[3]||'').split(','),threshold=(param[0]&&(param[0]=param[0].trim()))?parseInt(param[0],10):0,viewport=(param[1]&&(param[1]=param[1].trim()))?($(param[1])[0]||undefined):undefined,pos=getRelativePosition(element,viewport||getScrollableParent(element));return pos.right-threshold<=0&&pos.left>=0},aboveTheViewportPartly(element,i,meta){let param=(meta[3]||'').split(','),threshold=(param[0]&&(param[0]=param[0].trim()))?parseInt(param[0],10):0,viewport=(param[1]&&(param[1]=param[1].trim()))?($(param[1])[0]||undefined):undefined,pos=getRelativePosition(element,viewport||getScrollableParent(element));return pos.top-threshold<=0&&pos.bottom>=0&&(pos.bottom-threshold-pos.viewportHeight)>pos.elementHeight},belowTheViewportPartly(element,i,meta){let param=(meta[3]||'').split(','),threshold=(param[0]&&(param[0]=param[0].trim()))?parseInt(param[0],10):0,viewport=(param[1]&&(param[1]=param[1].trim()))?($(param[1])[0]||undefined):undefined,pos=getRelativePosition(element,viewport||getScrollableParent(element));return pos.bottom-threshold<=0&&pos.top>=0&&(pos.top-threshold-pos.viewportHeight)>pos.elementHeight},leftOfViewportPartly(element,i,meta){let param=(meta[3]||'').split(','),threshold=(param[0]&&(param[0]=param[0].trim()))?parseInt(param[0],10):0,viewport=(param[1]&&(param[1]=param[1].trim()))?($(param[1])[0]||undefined):undefined,pos=getRelativePosition(element,viewport||getScrollableParent(element));return pos.left-threshold<=0&&pos.right>=0&&(pos.left-threshold-pos.viewportWidth)>pos.elementWidth},rightOfViewportPartly(element,i,meta){let param=(meta[3]||'').split(','),threshold=(param[0]&&(param[0]=param[0].trim()))?parseInt(param[0],10):0,viewport=(param[1]&&(param[1]=param[1].trim()))?($(param[1])[0]||undefined):undefined,pos=getRelativePosition(element,viewport||getScrollableParent(element));return pos.right-threshold<=0&&pos.left>=0&&(pos.right-threshold-pos.viewportWidth)>pos.elementWidth},exceedsViewport(element,i,meta){let param=(meta[3]||'').split(','),threshold=(param[0]&&(param[0]=param[0].trim()))?parseInt(param[0],10):0,viewport=(param[1]&&(param[1]=param[1].trim()))?($(param[1])[0]||undefined):undefined;return!inViewport(element,threshold,viewport||getScrollableParent(element))},exceedsViewportVertical(element,i,meta){let param=(meta[3]||'').split(','),threshold=(param[0]&&(param[0]=param[0].trim()))?parseInt(param[0],10):0,viewport=(param[1]&&(param[1]=param[1].trim()))?($(param[1])[0]||undefined):undefined,pos=getRelativePosition(element,viewport||getScrollableParent(element));return pos.top-threshold<0&&pos.bottom-threshold<0},exceedsViewportHorizontal(element,i,meta){let param=(meta[3]||'').split(','),threshold=(param[0]&&(param[0]=param[0].trim()))?parseInt(param[0],10):0,viewport=(param[1]&&(param[1]=param[1].trim()))?($(param[1])[0]||undefined):undefined,pos=getRelativePosition(element,viewport||getScrollableParent(element));return pos.left-threshold<0&&pos.right-threshold<0},})})(jQuery)

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.