UNPKG

@redocly/graphql-docs

Version:

Redocly GraphQL docs

2 lines (1 loc) 802 B
typeof Element<"u"&&!Element.prototype.scrollIntoViewIfNeeded&&(Element.prototype.scrollIntoViewIfNeeded=function(e){e=arguments.length===0?!0:!!e;const t=this.parentNode,s=window.getComputedStyle(t,void 0),f=parseInt(s.getPropertyValue("border-top-width"),10),l=parseInt(s.getPropertyValue("border-left-width"),10);if(t){const o=this.offsetTop-t.offsetTop<t.scrollTop,i=this.offsetTop-t.offsetTop+this.clientHeight-f>t.scrollTop+t.clientHeight,n=this.offsetLeft-t.offsetLeft<t.scrollLeft,r=this.offsetLeft-t.offsetLeft+this.clientWidth-l>t.scrollLeft+t.clientWidth,p=o&&!i;(o||i)&&e&&(t.scrollTop=this.offsetTop-t.offsetTop-t.clientHeight/2-f+this.clientHeight/2),(n||r)&&e&&(t.scrollLeft=this.offsetLeft-t.offsetLeft-t.clientWidth/2-l+this.clientWidth/2),(o||i||n||r)&&!e&&this.scrollIntoView(p)}});