Every line of 'offset .top' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.
19 function getOffsetTop(rect, vertical) { 20 let offset = 0; 21 22 if (typeof vertical === 'number') { 23 offset = vertical; 24 } else if (vertical === 'center') { 25 offset = rect.height / 2; 26 } else if (vertical === 'bottom') { 27 offset = rect.height; 28 } 29 30 return offset; 31 }
169 getTopPositonY() { 170 const item = this.getTopItem(); 171 172 return item ? item.position.y : 0; 173 }
14 function getOffsetTop(element: HTMLElement, container: AnchorContainer): number { 15 if (!element) { 16 return 0; 17 } 18 19 if (!element.getClientRects().length) { 20 return 0; 21 } 22 23 const rect = element.getBoundingClientRect(); 24 25 if (rect.width || rect.height) { 26 if (container === window) { 27 container = element.ownerDocument.documentElement; 28 return rect.top - container.clientTop; 29 } 30 return rect.top - (container as HTMLElement).getBoundingClientRect().top; 31 } 32 33 return rect.top; 34 }
207 function getElementTop(element){ 208 var actualTop = element.offsetTop; 209 var current = element.offsetParent; 210 while (current !== null){ 211 actualTop += current.offsetTop; 212 current = current.offsetParent; 213 } 214 return actualTop; 215 }
31 function bottomPos(element) { 32 return element.offset().top + element.outerHeight(); 33 }