tether
Version:
A client-side library to make absolutely positioned elements attach to elements in the page efficiently.
5 lines (3 loc) • 21.9 kB
JavaScript
/*! tether 2.0.0 */
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).Tether=e()}(this,(function(){"use strict";function t(e,o){return(t=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(e,o)}function e(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function o(t){return"string"==typeof t}function i(t){return void 0===t}function n(t,e){e.split(" ").forEach((function(e){e.trim()&&t.classList.add(e)}))}function s(t,e,o){return void 0===t&&(t=""),i(e)||i(e[t])?o?o+"-"+t:t:!1===e[t]?"":e[t]}function r(t,e){e.split(" ").forEach((function(e){e.trim()&&t.classList.remove(e)}))}function a(t,e,o){o.forEach((function(o){-1===e.indexOf(o)&&t.classList.contains(o)&&r(t,o)})),e.forEach((function(e){t.classList.contains(e)||n(t,e)}))}var h=[];function l(t){h.push(t)}function f(){for(var t;t=h.pop();)t()}var p=null;function d(t){void 0===t&&(t={});var e=[];return Array.prototype.push.apply(e,arguments),e.slice(1).forEach((function(e){if(e)for(var o in e)({}).hasOwnProperty.call(e,o)&&(t[o]=e[o])})),t}function c(){if(p)return p;var t=document.createElement("div");t.style.width="100%",t.style.height="200px";var e=document.createElement("div");d(e.style,{position:"absolute",top:0,left:0,pointerEvents:"none",visibility:"hidden",width:"200px",height:"150px",overflow:"hidden"}),e.appendChild(t),document.body.appendChild(e);var o=t.offsetWidth;e.style.overflow="scroll";var i=t.offsetWidth;o===i&&(i=e.clientWidth),document.body.removeChild(e);var n=o-i;return p={width:n,height:n}}var u,m=(u=0,function(){return++u}),g={},v=null;function b(t,e){var o;e===document?(o=document,e=document.documentElement):o=e.ownerDocument;var n=o.documentElement,s=w(e),r=function(t){var e=v;e&&t.contains(e)||((e=document.createElement("div")).setAttribute("data-tether-id",m()),d(e.style,{top:0,left:0,position:"absolute"}),t.appendChild(e),v=e);var o=e.getAttribute("data-tether-id");i(g[o])&&(g[o]=w(e),l((function(){delete g[o]})));return g[o]}(t);return s.top-=r.top,s.left-=r.left,i(s.width)&&(s.width=document.body.scrollWidth-s.left-s.right),i(s.height)&&(s.height=document.body.scrollHeight-s.top-s.bottom),s.top=s.top-n.clientTop,s.left=s.left-n.clientLeft,s.right=o.body.clientWidth-s.width-s.left,s.bottom=o.body.clientHeight-s.height-s.top,s}function w(t){var e=t.getBoundingClientRect(),o={};for(var i in e)o[i]=e[i];try{if(t.ownerDocument!==document){var n=t.ownerDocument.defaultView.frameElement;if(n){var s=w(n);o.top+=s.top,o.bottom+=s.top,o.left+=s.left,o.right+=s.left}}}catch(t){}return o}var y={position:function(t){var e=this,o=t.top,i=t.left,n=this.cache("element-bounds",(function(){return b(e.element)})),r=n.height,h=n.width,f=this.getTargetBounds(),p=o+r,d=i+h,c=[];o<=f.bottom&&p>=f.top&&["left","right"].forEach((function(t){var e=f[t];e!==i&&e!==d||c.push(t)})),i<=f.right&&d>=f.left&&["top","bottom"].forEach((function(t){var e=f[t];e!==o&&e!==p||c.push(t)}));var u=this.options,m=u.classes,g=u.classPrefix;return this.all.push(s("abutted",m,g)),["left","top","right","bottom"].forEach((function(t){e.all.push(s("abutted",m,g)+"-"+t)})),c.length&&this.add.push(s("abutted",m,g)),c.forEach((function(t){e.add.push(s("abutted",m,g)+"-"+t)})),l((function(){!1!==e.options.addTargetClasses&&a(e.target,e.add,e.all),a(e.element,e.add,e.all)})),!0}},E=["left","top","right","bottom"];var O={position:function(t){var e=this,n=t.top,r=t.left,h=t.targetAttachment;if(!this.options.constraints)return!0;var f=this.cache("element-bounds",(function(){return b(e.bodyElement,e.element)})),p=f.height,c=f.width;if(0===c&&0===p&&!i(this.lastSize)){var u=this.lastSize;c=u.width,p=u.height}var m=this.cache("target-bounds",(function(){return e.getTargetBounds()})),g=m.height,v=m.width,w=this.options,y=w.classes,O=w.classPrefix,x=function(t,e,o){var i=[s("pinned",t,e),s("out-of-bounds",t,e)];return o.forEach((function(t){var e=t.outOfBoundsClass,o=t.pinnedClass;e&&i.push(e),o&&i.push(o)})),i.forEach((function(t){["left","top","right","bottom"].forEach((function(e){i.push(t+"-"+e)}))})),i}(y,O,this.options.constraints),C=[],T=d({},h),P=d({},this.attachment);return this.options.constraints.forEach((function(t){var a,l,f=t.to,d=t.attachment,u=t.pin;if(i(d)&&(d=""),d.indexOf(" ")>=0){var m=d.split(" ");l=m[0],a=m[1]}else a=l=d;var w=function(t,e,o){if(!o)return null;if("scrollParent"===o?o=e.scrollParents[0]:"window"===o&&(o=[pageXOffset,pageYOffset,innerWidth+pageXOffset,innerHeight+pageYOffset]),o===document&&(o=o.documentElement),!i(o.nodeType)){var n=o,s=b(t,o),r=s,a=getComputedStyle(o);if(o=[r.left,r.top,s.width+r.left,s.height+r.top],n.ownerDocument!==document){var h=n.ownerDocument.defaultView;o[0]+=h.pageXOffset,o[1]+=h.pageYOffset,o[2]+=h.pageXOffset,o[3]+=h.pageYOffset}E.forEach((function(t,e){"Top"===(t=t[0].toUpperCase()+t.substr(1))||"Left"===t?o[e]+=parseFloat(a["border"+t+"Width"]):o[e]-=parseFloat(a["border"+t+"Width"])}))}return o}(e.bodyElement,e,f);"target"!==l&&"both"!==l||(n<w[1]&&"top"===T.top&&(n+=g,T.top="bottom"),n+p>w[3]&&"bottom"===T.top&&(n-=g,T.top="top")),"together"===l&&(n=function(t,e,o,i,n,s){return"top"===t.top&&("bottom"===e.top&&s<o[1]?(s+=n,t.top="bottom",s+=i,e.top="top"):"top"===e.top&&s+i>o[3]&&s-(i-n)>=o[1]&&(s-=i-n,t.top="bottom",e.top="bottom")),"bottom"===t.top&&("top"===e.top&&s+i>o[3]?(s-=n,t.top="top",s-=i,e.top="bottom"):"bottom"===e.top&&s<o[1]&&s+(2*i-n)<=o[3]&&(s+=i-n,t.top="top",e.top="top")),"middle"===t.top&&(s+i>o[3]&&"top"===e.top?(s-=i,e.top="bottom"):s<o[1]&&"bottom"===e.top&&(s+=i,e.top="top")),s}(T,P,w,p,g,n)),"target"!==a&&"both"!==a||(r<w[0]&&"left"===T.left&&(r+=v,T.left="right"),r+c>w[2]&&"right"===T.left&&(r-=v,T.left="left")),"together"===a&&(r=function(t,e,o,i,n,s){return s<o[0]&&"left"===t.left?"right"===e.left?(s+=n,t.left="right",s+=i,e.left="left"):"left"===e.left&&(s+=n,t.left="right",s-=i,e.left="right"):s+i>o[2]&&"right"===t.left?"left"===e.left?(s-=n,t.left="left",s-=i,e.left="right"):"right"===e.left&&(s-=n,t.left="left",s+=i,e.left="left"):"center"===t.left&&(s+i>o[2]&&"left"===e.left?(s-=i,e.left="right"):s<o[0]&&"right"===e.left&&(s+=i,e.left="left")),s}(T,P,w,c,v,r)),"element"!==l&&"both"!==l||(n<w[1]&&"bottom"===P.top&&(n+=p,P.top="top"),n+p>w[3]&&"top"===P.top&&(n-=p,P.top="bottom")),"element"!==a&&"both"!==a||(r<w[0]&&("right"===P.left?(r+=c,P.left="left"):"center"===P.left&&(r+=c/2,P.left="left")),r+c>w[2]&&("left"===P.left?(r-=c,P.left="right"):"center"===P.left&&(r-=c/2,P.left="right"))),o(u)?u=u.split(",").map((function(t){return t.trim()})):!0===u&&(u=["top","left","right","bottom"]);var x,A=[],W=[];(r=function(t,e,o,i,n,s){return t<e[0]&&(i.indexOf("left")>=0?(t=e[0],n.push("left")):s.push("left")),t+o>e[2]&&(i.indexOf("right")>=0?(t=e[2]-o,n.push("right")):s.push("right")),t}(r,w,c,u=u||[],A,W),n=function(t,e,o,i,n,s){return t<e[1]&&(i.indexOf("top")>=0?(t=e[1],n.push("top")):s.push("top")),t+o>e[3]&&(i.indexOf("bottom")>=0?(t=e[3]-o,n.push("bottom")):s.push("bottom")),t}(n,w,p,u,A,W),A.length)&&(x=i(e.options.pinnedClass)?s("pinned",y,O):e.options.pinnedClass,C.push(x),A.forEach((function(t){C.push(x+"-"+t)})));!function(t,e,o,n,r){var a;t.length&&(a=i(r)?s("out-of-bounds",o,n):r,e.push(a),t.forEach((function(t){e.push(a+"-"+t)})))}(W,C,y,O,e.options.outOfBoundsClass),(A.indexOf("left")>=0||A.indexOf("right")>=0)&&(P.left=T.left=!1),(A.indexOf("top")>=0||A.indexOf("bottom")>=0)&&(P.top=T.top=!1),T.top===h.top&&T.left===h.left&&P.top===e.attachment.top&&P.left===e.attachment.left||(e.updateAttachClasses(P,T),e.trigger("update",{attachment:P,targetAttachment:T}))})),l((function(){!1!==e.options.addTargetClasses&&a(e.target,C,x),a(e.element,C,x)})),{top:n,left:r}}},x={position:function(t){var e=t.top,i=t.left;if(this.options.shift){var n,s,r=this.options.shift;if("function"==typeof r&&(r=r.call(this,{top:e,left:i})),o(r)){(r=r.split(" "))[1]=r[1]||r[0];var a=r;n=a[0],s=a[1],n=parseFloat(n,10),s=parseFloat(s,10)}else{var h=[r.top,r.left];n=h[0],s=h[1]}return{top:e+=n,left:i+=s}}}},C=function(){function t(){}var e=t.prototype;return e.on=function(t,e,o,n){return void 0===n&&(n=!1),i(this.bindings)&&(this.bindings={}),i(this.bindings[t])&&(this.bindings[t]=[]),this.bindings[t].push({handler:e,ctx:o,once:n}),this},e.once=function(t,e,o){return this.on(t,e,o,!0)},e.off=function(t,e){var o=this;return i(this.bindings)||i(this.bindings[t])||(i(e)?delete this.bindings[t]:this.bindings[t].forEach((function(i,n){i.handler===e&&o.bindings[t].splice(n,1)}))),this},e.trigger=function(t){for(var e=this,o=arguments.length,n=new Array(o>1?o-1:0),s=1;s<o;s++)n[s-1]=arguments[s];return!i(this.bindings)&&this.bindings[t]&&this.bindings[t].forEach((function(o,i){var s=o.ctx,r=o.handler,a=o.once,h=s||e;r.apply(h,n),a&&e.bindings[t].splice(i,1)})),this},t}(),T={center:"center",left:"right",right:"left"},P={middle:"middle",top:"bottom",bottom:"top"},A={top:0,left:0,middle:"50%",center:"50%",bottom:"100%",right:"100%"};function W(){for(var t={top:0,left:0},e=arguments.length,i=new Array(e),n=0;n<e;n++)i[n]=arguments[n];return i.forEach((function(e){var i=e.top,n=e.left;o(i)&&(i=parseFloat(i)),o(n)&&(n=parseFloat(n)),t.top+=i,t.left+=n})),t}function _(t){var e=t.left,o=t.top;return i(A[t.left])||(e=A[t.left]),i(A[t.top])||(o=A[t.top]),{left:e,top:o}}function M(t,e){return o(t.left)&&-1!==t.left.indexOf("%")&&(t.left=parseFloat(t.left)/100*e.width),o(t.top)&&-1!==t.top.indexOf("%")&&(t.top=parseFloat(t.top)/100*e.height),t}function z(t){var e=t.split(" ");return{top:e[0],left:e[1]}}function F(t){return t.offsetParent||document.documentElement}var L={modules:[O,y,x]};var Y,S,X,H,D=function(){if(i(document))return"";for(var t=document.createElement("div"),e=["transform","WebkitTransform","OTransform","MozTransform","msTransform"],o=0;o<e.length;++o){var n=e[o];if(void 0!==t.style[n])return n}}(),k=[],B=function(){k.forEach((function(t){t.position(!1)})),f()};function N(){return performance.now()}Y=null,S=null,X=null,H=function t(){if(!i(S)&&S>16)return S=Math.min(S-16,250),void(X=setTimeout(t,250));!i(Y)&&N()-Y<10||(null!=X&&(clearTimeout(X),X=null),Y=N(),B(),S=N()-Y)},i(window)||i(window.addEventListener)||["resize","scroll","touchmove"].forEach((function(t){window.addEventListener(t,H)}));var R=function(h){var p,u;function m(t){var o;return(o=h.call(this)||this).position=o.position.bind(e(o)),k.push(e(o)),o.history=[],o.setOptions(t,!1),L.modules.forEach((function(t){i(t.initialize)||t.initialize.call(e(o))})),o.position(),o}u=h,(p=m).prototype=Object.create(u.prototype),p.prototype.constructor=p,t(p,u);var g=m.prototype;return g.setOptions=function(t,e){var n=this;void 0===e&&(e=!0);var s={offset:"0 0",targetOffset:"0 0",targetAttachment:"auto auto",classPrefix:"tether",bodyElement:document.body};this.options=d(s,t);var r=this.options,a=r.element,h=r.target,l=r.targetModifier,f=r.bodyElement;if(this.element=a,this.target=h,this.targetModifier=l,"string"==typeof f&&(f=document.querySelector(f)),this.bodyElement=f,"viewport"===this.target?(this.target=document.body,this.targetModifier="visible"):"scroll-handle"===this.target&&(this.target=document.body,this.targetModifier="scroll-handle"),["element","target"].forEach((function(t){if(i(n[t]))throw new Error("Tether Error: Both element and target must be defined");i(n[t].jquery)?o(n[t])&&(n[t]=document.querySelector(n[t])):n[t]=n[t][0]})),this._addClasses(),!this.options.attachment)throw new Error("Tether Error: You must provide an attachment");this.targetAttachment=z(this.options.targetAttachment),this.attachment=z(this.options.attachment),this.offset=z(this.options.offset),this.targetOffset=z(this.options.targetOffset),i(this.scrollParents)||this.disable(),"scroll-handle"===this.targetModifier?this.scrollParents=[this.target]:this.scrollParents=function(t){var e=(getComputedStyle(t)||{}).position,o=[];if("fixed"===e)return[t];for(var n=t;(n=n.parentNode)&&n&&1===n.nodeType;){var s=void 0;try{s=getComputedStyle(n)}catch(t){}if(i(s)||null===s)return o.push(n),o;var r=s,a=r.overflow,h=r.overflowX,l=r.overflowY;/(auto|scroll|overlay)/.test(a+l+h)&&("absolute"!==e||["relative","absolute","fixed"].indexOf(s.position)>=0)&&o.push(n)}return o.push(t.ownerDocument.body),t.ownerDocument!==document&&o.push(t.ownerDocument.defaultView),o}(this.target),!1!==this.options.enabled&&this.enable(e)},g.getTargetBounds=function(){return i(this.targetModifier)?b(this.bodyElement,this.target):"visible"===this.targetModifier?function(t,e){if(e===document.body)return{top:pageYOffset,left:pageXOffset,height:innerHeight,width:innerWidth};var o=b(t,e),i={height:o.height,width:o.width,top:o.top,left:o.left};return i.height=Math.min(i.height,o.height-(pageYOffset-o.top)),i.height=Math.min(i.height,o.height-(o.top+o.height-(pageYOffset+innerHeight))),i.height=Math.min(innerHeight,i.height),i.height-=2,i.width=Math.min(i.width,o.width-(pageXOffset-o.left)),i.width=Math.min(i.width,o.width-(o.left+o.width-(pageXOffset+innerWidth))),i.width=Math.min(innerWidth,i.width),i.width-=2,i.top<pageYOffset&&(i.top=pageYOffset),i.left<pageXOffset&&(i.left=pageXOffset),i}(this.bodyElement,this.target):"scroll-handle"===this.targetModifier?function(t,e){var o,i=e.scrollTop,n=e===document.body;n?(e=document.documentElement,o={left:pageXOffset,top:pageYOffset,height:innerHeight,width:innerWidth}):o=b(t,e);var s=getComputedStyle(e),r=0;(e.scrollWidth>e.clientWidth||[s.overflow,s.overflowX].indexOf("scroll")>=0||!n)&&(r=15);var a=o.height-parseFloat(s.borderTopWidth)-parseFloat(s.borderBottomWidth)-r,h={width:15,height:.975*a*(a/e.scrollHeight),left:o.left+o.width-parseFloat(s.borderLeftWidth)-15},l=0;a<408&&n&&(l=-11e-5*Math.pow(a,2)-.00727*a+22.58),n||(h.height=Math.max(h.height,24));var f=i/(e.scrollHeight-a);return h.top=f*(a-h.height-l)+o.top+parseFloat(s.borderTopWidth),n&&(h.height=Math.max(h.height,24)),h}(this.bodyElement,this.target):void 0},g.clearCache=function(){this._cache={}},g.cache=function(t,e){return i(this._cache)&&(this._cache={}),i(this._cache[t])&&(this._cache[t]=e.call(this)),this._cache[t]},g.enable=function(t){var e=this;void 0===t&&(t=!0);var o=this.options,i=o.classes,r=o.classPrefix;!1!==this.options.addTargetClasses&&n(this.target,s("enabled",i,r)),n(this.element,s("enabled",i,r)),this.enabled=!0,this.scrollParents.forEach((function(t){t!==e.target.ownerDocument&&t.addEventListener("scroll",e.position)})),t&&this.position()},g.disable=function(){var t=this,e=this.options,o=e.classes,n=e.classPrefix;r(this.target,s("enabled",o,n)),r(this.element,s("enabled",o,n)),this.enabled=!1,i(this.scrollParents)||this.scrollParents.forEach((function(e){e&&e.removeEventListener&&e.removeEventListener("scroll",t.position)}))},g.destroy=function(){var t,e=this;this.disable(),this._removeClasses(),k.forEach((function(t,o){t===e&&k.splice(o,1)})),0===k.length&&(t=this.bodyElement,v&&t.removeChild(v),v=null)},g.updateAttachClasses=function(t,e){var o=this;t=t||this.attachment,e=e||this.targetAttachment;var n=this.options,r=n.classes,h=n.classPrefix;!i(this._addAttachClasses)&&this._addAttachClasses.length&&this._addAttachClasses.splice(0,this._addAttachClasses.length),i(this._addAttachClasses)&&(this._addAttachClasses=[]),this.add=this._addAttachClasses,t.top&&this.add.push(s("element-attached",r,h)+"-"+t.top),t.left&&this.add.push(s("element-attached",r,h)+"-"+t.left),e.top&&this.add.push(s("target-attached",r,h)+"-"+e.top),e.left&&this.add.push(s("target-attached",r,h)+"-"+e.left),this.all=[],["left","top","bottom","right","middle","center"].forEach((function(t){o.all.push(s("element-attached",r,h)+"-"+t),o.all.push(s("target-attached",r,h)+"-"+t)})),l((function(){i(o._addAttachClasses)||(a(o.element,o._addAttachClasses,o.all),!1!==o.options.addTargetClasses&&a(o.target,o._addAttachClasses,o.all),delete o._addAttachClasses)}))},g.position=function(t){var e=this;if(void 0===t&&(t=!0),this.enabled){this.clearCache();var o=function(t,e){var o=t.left,i=t.top;return"auto"===o&&(o=T[e.left]),"auto"===i&&(i=P[e.top]),{left:o,top:i}}(this.targetAttachment,this.attachment);this.updateAttachClasses(this.attachment,o);var n=this.cache("element-bounds",(function(){return b(e.bodyElement,e.element)})),s=n.width,r=n.height;if(0!==s||0!==r||i(this.lastSize))this.lastSize={width:s,height:r};else{var a=this.lastSize;s=a.width,r=a.height}var h=this.cache("target-bounds",(function(){return e.getTargetBounds()})),l=h,p=M(_(this.attachment),{width:s,height:r}),d=M(_(o),l),u=M(this.offset,{width:s,height:r}),m=M(this.targetOffset,l);p=W(p,u),d=W(d,m);for(var g=h.left+d.left-p.left,v=h.top+d.top-p.top,w=0;w<L.modules.length;++w){var y=L.modules[w].position.call(this,{left:g,top:v,targetAttachment:o,targetPos:h,elementPos:n,offset:p,targetOffset:d,manualOffset:u,manualTargetOffset:m,scrollbarSize:E,attachment:this.attachment});if(!1===y)return!1;i(y)||"object"!=typeof y||(v=y.top,g=y.left)}var E,O={page:{top:v,left:g},viewport:{top:v-pageYOffset,bottom:pageYOffset-v-r+innerHeight,left:g-pageXOffset,right:pageXOffset-g-s+innerWidth}},x=this.target.ownerDocument,C=x.defaultView;if(C.innerHeight>x.documentElement.clientHeight&&(E=this.cache("scrollbar-size",c),O.viewport.bottom-=E.height),C.innerWidth>x.documentElement.clientWidth&&(E=this.cache("scrollbar-size",c),O.viewport.right-=E.width),-1!==["","static"].indexOf(x.body.style.position)&&-1!==["","static"].indexOf(x.body.parentElement.style.position)||(O.page.bottom=x.body.scrollHeight-v-r,O.page.right=x.body.scrollWidth-g-s),!i(this.options.optimizations)&&!1!==this.options.optimizations.moveElement&&i(this.targetModifier)){var A=this.cache("target-offsetparent",(function(){return F(e.target)})),z=this.cache("target-offsetparent-bounds",(function(){return b(e.bodyElement,A)})),Y=getComputedStyle(A),S=z,X={};if(["Top","Left","Bottom","Right"].forEach((function(t){X[t.toLowerCase()]=parseFloat(Y["border"+t+"Width"])})),z.right=x.body.scrollWidth-z.left-S.width+X.right,z.bottom=x.body.scrollHeight-z.top-S.height+X.bottom,O.page.top>=z.top+X.top&&O.page.bottom>=z.bottom&&O.page.left>=z.left+X.left&&O.page.right>=z.right){var H=A.scrollLeft,D=A.scrollTop;O.offset={top:O.page.top-z.top+D-X.top,left:O.page.left-z.left+H-X.left}}}return this.move(O),this.history.unshift(O),this.history.length>3&&this.history.pop(),t&&f(),!0}},g.move=function(t){var e=this;if(!i(this.element.parentNode)){var o,n,s,r={};for(var a in t)for(var h in r[a]={},t[a]){for(var f=!1,p=0;p<this.history.length;++p){var c=this.history[p];if(!(i(c[a])||(o=c[a][h],n=t[a][h],s=void 0,void 0===s&&(s=1),o+s>=n&&n>=o-s))){f=!0;break}}f||(r[a][h]=!0)}var u={top:"",left:"",right:"",bottom:""},m=function(t,o){var n,s;!1!==(!i(e.options.optimizations)?e.options.optimizations.gpu:null)?(t.top?(u.top=0,n=o.top):(u.bottom=0,n=-o.bottom),t.left?(u.left=0,s=o.left):(u.right=0,s=-o.right),"number"==typeof window.devicePixelRatio&&devicePixelRatio%1==0&&(s=Math.round(s*devicePixelRatio)/devicePixelRatio,n=Math.round(n*devicePixelRatio)/devicePixelRatio),u[D]="translateX("+s+"px) translateY("+n+"px)","msTransform"!==D&&(u[D]+=" translateZ(0)")):(t.top?u.top=o.top+"px":u.bottom=o.bottom+"px",t.left?u.left=o.left+"px":u.right=o.right+"px")},g=!0;!i(this.options.optimizations)&&!1===this.options.optimizations.allowPositionFixed&&(g=!1);var v,b,w=!1;if((r.page.top||r.page.bottom)&&(r.page.left||r.page.right))u.position="absolute",m(r.page,t.page);else if(g&&(r.viewport.top||r.viewport.bottom)&&(r.viewport.left||r.viewport.right))u.position="fixed",m(r.viewport,t.viewport);else if(!i(r.offset)&&r.offset.top&&r.offset.left){u.position="absolute";var y=this.cache("target-offsetparent",(function(){return F(e.target)}));F(this.element)!==y&&l((function(){e.element.parentNode.removeChild(e.element),y.appendChild(e.element)})),m(r.offset,t.offset),w=!0}else u.position="absolute",m({top:!0,left:!0},t.page);if(!w)if(this.options.bodyElement)this.element.parentNode!==this.options.bodyElement&&this.options.bodyElement.appendChild(this.element);else{for(var E=!0,O=this.element.parentNode;O&&1===O.nodeType&&"BODY"!==O.tagName&&(b=void 0,((b=(v=O).ownerDocument).fullscreenElement||b.webkitFullscreenElement||b.mozFullScreenElement||b.msFullscreenElement)!==v);){if("static"!==getComputedStyle(O).position){E=!1;break}O=O.parentNode}E||(this.element.parentNode.removeChild(this.element),this.element.ownerDocument.body.appendChild(this.element))}var x={},C=!1;for(var T in u){var P=u[T];this.element.style[T]!==P&&(C=!0,x[T]=P)}C&&l((function(){d(e.element.style,x),e.trigger("repositioned")}))}},g._addClasses=function(){var t=this.options,e=t.classes,o=t.classPrefix;n(this.element,s("element",e,o)),!1!==this.options.addTargetClasses&&n(this.target,s("target",e,o))},g._removeClasses=function(){var t=this,e=this.options,o=e.classes,i=e.classPrefix;r(this.element,s("element",o,i)),!1!==this.options.addTargetClasses&&r(this.target,s("target",o,i)),this.all.forEach((function(e){t.element.classList.remove(e),t.target.classList.remove(e)}))},m}(C);R.modules=[],L.position=B;var j=d(R,L);return j.modules.push({initialize:function(){var t=this,e=this.options,o=e.classes,i=e.classPrefix;this.markers={},["target","element"].forEach((function(e){var n=document.createElement("div");n.className=s(e+"-marker",o,i);var r=document.createElement("div");r.className=s("marker-dot",o,i),n.appendChild(r),t[e].appendChild(n),t.markers[e]={dot:r,el:n}}))},position:function(t){var e={element:t.manualOffset,target:t.manualTargetOffset};for(var i in e){var n=e[i];for(var s in n){var r,a=n[s];(!o(a)||-1===a.indexOf("%")&&-1===a.indexOf("px"))&&(a+="px"),this.markers[i]&&(null==(r=this.markers[i].dot)?void 0:r.style[s])!==a&&(this.markers[i].dot.style[s]=a)}}return!0}}),j}));
//# sourceMappingURL=tether.min.js.map