From b0a61d018c307d48d4e4566e4717889c090697e3 Mon Sep 17 00:00:00 2001 From: PMKuipers Date: Tue, 20 Aug 2024 17:58:57 +0200 Subject: [PATCH] Fixed minor issue with sidebar not always loading --- amd/build/util/psidebar-vue.min.js | 2 +- amd/build/util/psidebar-vue.min.js.map | 2 +- amd/src/util/psidebar-vue.js | 29 ++++++++++++++------------ 3 files changed, 18 insertions(+), 15 deletions(-) diff --git a/amd/build/util/psidebar-vue.min.js b/amd/build/util/psidebar-vue.min.js index 44ea6c8..de68231 100644 --- a/amd/build/util/psidebar-vue.min.js +++ b/amd/build/util/psidebar-vue.min.js @@ -1,3 +1,3 @@ -define("local_treestudyplan/util/psidebar-vue",["exports","../portal-vue/portal-vue.esm","./debugger"],(function(_exports,_portalVue,_debugger){function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.default=void 0,_portalVue=_interopRequireDefault(_portalVue);let wrapper,contentwrapper,resizeObserver,debug=new((_debugger=_interopRequireDefault(_debugger)).default)("p-sidebar");function rePosition(right){let el=document.querySelector("#p-sidebar-mount");el||(el=document.createElement("div"),el.setAttribute("id","p-sidebar-mount"),resizeObserver=new ResizeObserver((()=>{let wx=0-el.getBoundingClientRect().width;wx+=0!=wx?"px":"",el.style.setProperty("--p-sidebar-hideoffset",wx)})),resizeObserver.observe(el)),right?wrapper.insertBefore(el,contentwrapper.nextSibling):wrapper.insertBefore(el,contentwrapper)}function setOffset(reference){const ref=reference?document.querySelector(reference):null;if(ref){let offsetTop=ref?ref.offsetTop:0;offsetTop+=0!=offsetTop?"px":"";const el=document.querySelector("#p-sidebar-mount");el&&(el.style.height=`calc( 100vh - ${offsetTop})`,el.style.marginTop=offsetTop)}}var _default={install(Vue){Vue.use(_portalVue.default),window.addEventListener("load",(()=>{!function(target,offsetref){let initializeWrapperContent=!1;if(wrapper=document.querySelector("#p-sidebar-wrapper"),wrapper||(initializeWrapperContent=!0,wrapper=document.createElement("div"),wrapper.setAttribute("id","p-sidebar-wrapper")),contentwrapper=document.querySelector("#p-sidebar-contentwrapper"),contentwrapper||(initializeWrapperContent=!0,contentwrapper=document.createElement("div"),contentwrapper.setAttribute("id","p-sidebar-contentwrapper"),wrapper.appendChild(contentwrapper)),initializeWrapperContent){let targetEl=document.querySelector(target);for(console.info(`Targeting '${target}' to `,targetEl),targetEl&&"HTML"!=targetEl.nodeType||(targetEl=document.querySelector("body"));targetEl.childNodes.length>0;)contentwrapper.appendChild(targetEl.childNodes[0]);targetEl.appendChild(wrapper)}rePosition(!1),setOffset(offsetref)}()})),Vue.component("p-easeinout",{template:'\n \n '}),Vue.component("p-sidebar",{props:{value:{type:Boolean,default:!0},right:{type:Boolean,default:!1},shadow:{type:Boolean,default:!1},target:{type:String,default:"body"},offsetRef:{type:String,default:""}},data:()=>({wrapper:null,contentwrapper:null,resizeobserver:null}),computed:{},methods:{},watch:{right(newVal){rePosition(newVal)},offsetRef(reference){setOffset(reference,this.$refs.portal)}},mounted(){debug.info("OffsetRef",this.offsetRef),setOffset(this.offsetRef),debug.info("Right",this.right),rePosition(this.right)},unmounted(){},template:"\n
\n
\n "})}};return _exports.default=_default,_exports.default})); +define("local_treestudyplan/util/psidebar-vue",["exports","../portal-vue/portal-vue.esm","./debugger"],(function(_exports,_portalVue,_debugger){function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.default=void 0,_portalVue=_interopRequireDefault(_portalVue);let wrapper,contentwrapper,resizeObserver,debug=new((_debugger=_interopRequireDefault(_debugger)).default)("p-sidebar");function createPortalTarget(target,offsetref){let initializeWrapperContent=!1;if(debug.info("Creating portal target"),wrapper=document.querySelector("#p-sidebar-wrapper"),wrapper||(initializeWrapperContent=!0,wrapper=document.createElement("div"),wrapper.setAttribute("id","p-sidebar-wrapper")),contentwrapper=document.querySelector("#p-sidebar-contentwrapper"),contentwrapper||(initializeWrapperContent=!0,contentwrapper=document.createElement("div"),contentwrapper.setAttribute("id","p-sidebar-contentwrapper"),wrapper.appendChild(contentwrapper)),initializeWrapperContent){let targetEl=document.querySelector(target);for(targetEl&&"HTML"!=targetEl.nodeType||(targetEl=document.querySelector("body")),console.info(`Targeting '${target}' to `,targetEl);targetEl.childNodes.length>0;)contentwrapper.appendChild(targetEl.childNodes[0]);targetEl.appendChild(wrapper)}rePosition(!1),setOffset(offsetref)}function rePosition(right){let el=document.querySelector("#p-sidebar-mount");el||(el=document.createElement("div"),el.setAttribute("id","p-sidebar-mount"),resizeObserver=new ResizeObserver((()=>{let wx=0-el.getBoundingClientRect().width;wx+=0!=wx?"px":"",el.style.setProperty("--p-sidebar-hideoffset",wx)})),resizeObserver.observe(el)),right?wrapper.insertBefore(el,contentwrapper.nextSibling):wrapper.insertBefore(el,contentwrapper)}function setOffset(reference){const ref=reference?document.querySelector(reference):null;if(ref){let offsetTop=ref?ref.offsetTop:0;offsetTop+=0!=offsetTop?"px":"";const el=document.querySelector("#p-sidebar-mount");el&&(el.style.height=`calc( 100vh - ${offsetTop})`,el.style.marginTop=offsetTop)}}var _default={install(Vue){Vue.use(_portalVue.default),"ready"===document.readyState||"complete"===document.readyState?(debug.info("Page already loaded"),createPortalTarget()):window.addEventListener("load",(()=>{debug.info("Page not yet loaded"),createPortalTarget()})),Vue.component("p-easeinout",{template:'\n \n '}),Vue.component("p-sidebar",{props:{value:{type:Boolean,default:!0},right:{type:Boolean,default:!1},shadow:{type:Boolean,default:!1},target:{type:String,default:"body"},offsetRef:{type:String,default:""}},data:()=>({wrapper:null,contentwrapper:null,resizeobserver:null}),computed:{},methods:{},watch:{right(newVal){rePosition(newVal)},offsetRef(reference){setOffset(reference,this.$refs.portal)}},mounted(){debug.info("OffsetRef",this.offsetRef),setOffset(this.offsetRef),debug.info("Right",this.right),rePosition(this.right)},template:"\n
\n
\n "})}};return _exports.default=_default,_exports.default})); //# sourceMappingURL=psidebar-vue.min.js.map \ No newline at end of file diff --git a/amd/build/util/psidebar-vue.min.js.map b/amd/build/util/psidebar-vue.min.js.map index 6dc5b53..400dc3e 100644 --- a/amd/build/util/psidebar-vue.min.js.map +++ b/amd/build/util/psidebar-vue.min.js.map @@ -1 +1 @@ -{"version":3,"file":"psidebar-vue.min.js","sources":["../../src/util/psidebar-vue.js"],"sourcesContent":["/* eslint no-unused-vars: warn */\n/* eslint max-len: [\"error\", { \"code\": 160 }] */\n/* eslint-disable no-trailing-spaces */\n/* eslint-disable no-console */\n/* eslint-env es6*/\nimport PortalVue from '../portal-vue/portal-vue.esm';\nimport Debugger from './debugger';\nlet debug = new Debugger(\"p-sidebar\");\n\n\nlet wrapper;\nlet contentwrapper;\nlet resizeObserver;\n/**\n * Create a new wrapper Around the \n * @param {String} target Query string to select root element next to which the sidebar will be placed. \n * Defaults to body\n * @param {String} offsetref Query string to select element that should appear above the sidebar. \n * Defaults to none\n */\nfunction createPortalTarget(target,offsetref) {\n let initializeWrapperContent = false;\n // First check if the sidebar wrapper already exists. \n // Creating the wrappers over and over again is a recipe for disaster.\n wrapper = document.querySelector(\"#p-sidebar-wrapper\");\n if (!wrapper) {\n initializeWrapperContent = true;\n // Otherwise, create it.\n wrapper = document.createElement(\"div\");\n wrapper.setAttribute(\"id\", \"p-sidebar-wrapper\");\n }\n // First check if the contentwrapper already exists\n contentwrapper = document.querySelector(\"#p-sidebar-contentwrapper\");\n if (!contentwrapper) {\n initializeWrapperContent = true;\n // Otherwise, create it.\n contentwrapper = document.createElement(\"div\");\n contentwrapper.setAttribute(\"id\", \"p-sidebar-contentwrapper\");\n wrapper.appendChild(contentwrapper);\n }\n\n if (initializeWrapperContent) {\n // Find containing target (otherwise use body)\n let targetEl = document.querySelector(target);\n console.info(`Targeting '${target}' to `, targetEl);\n if (!targetEl || targetEl.nodeType == \"HTML\") {\n targetEl = document.querySelector(\"body\");\n }\n \n // Move all target content parts to content wrapper....\n while (targetEl.childNodes.length > 0) {\n contentwrapper.appendChild(targetEl.childNodes[0]);\n }\n // Add sidebar wrapper to target Element\n targetEl.appendChild(wrapper);\n }\n // The actual target is created in a reposition call\n rePosition(false);\n // The \n setOffset(offsetref);\n}\n\n/**\n * Position a (new) sidebar element on the left or right \n * @param {Boolean} right Set to true to put the sidebar on the right\n */\nfunction rePosition(right) {\n // Place the portal target on the right place in the DOM.\n // Find or create the portal target.\n let el = document.querySelector(`#p-sidebar-mount`);\n if (!el) {\n el = document.createElement(\"div\");\n el.setAttribute(\"id\", `p-sidebar-mount`);\n\n // Initialize a resizeObser\n resizeObserver = new ResizeObserver(() => {\n let wx = 0 - el.getBoundingClientRect().width;\n wx += (wx != 0) ? \"px\" : \"\";\n el.style.setProperty(\"--p-sidebar-hideoffset\", wx);\n });\n resizeObserver.observe(el);\n\n }\n if (right) {\n wrapper.insertBefore(el, contentwrapper.nextSibling);\n } else {\n wrapper.insertBefore(el, contentwrapper);\n }\n}\n\n/**\n * Set the proper offset from the top on the sidebar related to the reference element \n * @param {String} reference Reference target for setting view height\n */\nfunction setOffset(reference) {\n const ref = reference ? document.querySelector(reference) : null;\n if (ref) {\n let offsetTop = (ref ? ref.offsetTop : 0);\n offsetTop += (offsetTop != 0) ? \"px\" : \"\";\n const el = document.querySelector(`#p-sidebar-mount`);\n if (el) {\n el.style.height = `calc( 100vh - ${offsetTop})`;\n el.style.marginTop = offsetTop;\n }\n }\n}\n\nexport default {\n install(Vue /* ,options */) {\n Vue.use(PortalVue);\n /* Create the portal target on initialization.\n Defaults to body. Offset and final position set through sidebar parameter.\n */\n window.addEventListener(\"load\", () => {\n createPortalTarget();\n });\n\n Vue.component('p-easeinout',{\n template: `\n \n `\n });\n\n Vue.component('p-sidebar', {\n props: {\n value: {\n type: Boolean,\n 'default': true,\n },\n right: {\n type: Boolean,\n 'default': false,\n },\n shadow: {\n type: Boolean,\n 'default': false,\n },\n target: {\n type: String,\n 'default': 'body',\n },\n offsetRef: {\n type: String,\n 'default': '',\n }\n },\n data() {\n return {\n wrapper: null,\n contentwrapper: null,\n resizeobserver: null,\n };\n },\n computed: {\n },\n methods: {\n\n },\n watch: {\n right(newVal) {\n rePosition(newVal);\n },\n offsetRef(reference) {\n setOffset(reference,this.$refs.portal);\n }\n },\n mounted() {\n debug.info(\"OffsetRef\",this.offsetRef);\n setOffset(this.offsetRef);\n debug.info(\"Right\",this.right);\n rePosition(this.right);\n },\n unmounted() {\n\n },\n template: `\n
\n
\n `,\n });\n },\n};"],"names":["wrapper","contentwrapper","resizeObserver","debug","rePosition","right","el","document","querySelector","createElement","setAttribute","ResizeObserver","wx","getBoundingClientRect","width","style","setProperty","observe","insertBefore","nextSibling","setOffset","reference","ref","offsetTop","height","marginTop","install","Vue","use","PortalVue","window","addEventListener","target","offsetref","initializeWrapperContent","appendChild","targetEl","console","info","nodeType","childNodes","length","createPortalTarget","component","template","props","value","type","Boolean","shadow","String","offsetRef","data","resizeobserver","computed","methods","watch","newVal","this","$refs","portal","mounted","unmounted"],"mappings":"oWAUIA,QACAC,eACAC,eALAC,MAAQ,2DAAa,sBA2DhBC,WAAWC,WAGZC,GAAKC,SAASC,cAAe,oBAC5BF,KACDA,GAAMC,SAASE,cAAc,OAC7BH,GAAGI,aAAa,KAAO,mBAGvBR,eAAiB,IAAIS,gBAAe,SAC5BC,GAAK,EAAIN,GAAGO,wBAAwBC,MACxCF,IAAa,GAANA,GAAW,KAAO,GACzBN,GAAGS,MAAMC,YAAY,yBAA0BJ,OAEnDV,eAAee,QAAQX,KAGvBD,MACAL,QAAQkB,aAAaZ,GAAIL,eAAekB,aAExCnB,QAAQkB,aAAaZ,GAAIL,yBAQxBmB,UAAUC,iBACTC,IAAMD,UAAYd,SAASC,cAAca,WAAa,QACxDC,IAAK,KACDC,UAAaD,IAAMA,IAAIC,UAAY,EACvCA,WAA2B,GAAbA,UAAkB,KAAO,SACjCjB,GAAKC,SAASC,cAAe,oBAC/BF,KACAA,GAAGS,MAAMS,OAAU,iBAAgBD,aACnCjB,GAAGS,MAAMU,UAAYF,yBAKlB,CACXG,QAAQC,KACJA,I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util/psidebar-vue.js"],"sourcesContent":["/* eslint no-unused-vars: warn */\n/* eslint max-len: [\"error\", { \"code\": 160 }] */\n/* eslint-disable no-trailing-spaces */\n/* eslint-disable no-console */\n/* eslint-env es6*/\nimport PortalVue from '../portal-vue/portal-vue.esm';\nimport Debugger from './debugger';\nlet debug = new Debugger(\"p-sidebar\");\n\n\nlet wrapper;\nlet contentwrapper;\nlet resizeObserver;\n/**\n * Create a new wrapper Around the \n * @param {String} target Query string to select root element next to which the sidebar will be placed. \n * Defaults to body\n * @param {String} offsetref Query string to select element that should appear above the sidebar. \n * Defaults to none\n */\nfunction createPortalTarget(target, offsetref) {\n let initializeWrapperContent = false;\n debug.info(\"Creating portal target\");\n // First check if the sidebar wrapper already exists. \n // Creating the wrappers over and over again is a recipe for disaster.\n wrapper = document.querySelector(\"#p-sidebar-wrapper\");\n if (!wrapper) {\n initializeWrapperContent = true;\n // Otherwise, create it.\n wrapper = document.createElement(\"div\");\n wrapper.setAttribute(\"id\", \"p-sidebar-wrapper\");\n }\n // First check if the contentwrapper already exists\n contentwrapper = document.querySelector(\"#p-sidebar-contentwrapper\");\n if (!contentwrapper) {\n initializeWrapperContent = true;\n // Otherwise, create it.\n contentwrapper = document.createElement(\"div\");\n contentwrapper.setAttribute(\"id\", \"p-sidebar-contentwrapper\");\n wrapper.appendChild(contentwrapper);\n }\n\n if (initializeWrapperContent) {\n // Find containing target (otherwise use body)\n let targetEl = document.querySelector(target);\n if (!targetEl || targetEl.nodeType == \"HTML\") {\n targetEl = document.querySelector(\"body\");\n }\n console.info(`Targeting '${target}' to `, targetEl);\n \n // Move all target content parts to content wrapper....\n while (targetEl.childNodes.length > 0) {\n contentwrapper.appendChild(targetEl.childNodes[0]);\n }\n // Add sidebar wrapper to target Element\n targetEl.appendChild(wrapper);\n }\n // The actual target is created in a reposition call\n rePosition(false);\n // The \n setOffset(offsetref);\n}\n\n/**\n * Position a (new) sidebar element on the left or right \n * @param {Boolean} right Set to true to put the sidebar on the right\n */\nfunction rePosition(right) {\n // Place the portal target on the right place in the DOM.\n // Find or create the portal target.\n let el = document.querySelector(`#p-sidebar-mount`);\n if (!el) {\n el = document.createElement(\"div\");\n el.setAttribute(\"id\", `p-sidebar-mount`);\n\n // Initialize a resizeObser\n resizeObserver = new ResizeObserver(() => {\n let wx = 0 - el.getBoundingClientRect().width;\n wx += (wx != 0) ? \"px\" : \"\";\n el.style.setProperty(\"--p-sidebar-hideoffset\", wx);\n });\n resizeObserver.observe(el);\n\n }\n if (right) {\n wrapper.insertBefore(el, contentwrapper.nextSibling);\n } else {\n wrapper.insertBefore(el, contentwrapper);\n }\n}\n\n/**\n * Set the proper offset from the top on the sidebar related to the reference element \n * @param {String} reference Reference target for setting view height\n */\nfunction setOffset(reference) {\n const ref = reference ? document.querySelector(reference) : null;\n if (ref) {\n let offsetTop = (ref ? ref.offsetTop : 0);\n offsetTop += (offsetTop != 0) ? \"px\" : \"\";\n const el = document.querySelector(`#p-sidebar-mount`);\n if (el) {\n el.style.height = `calc( 100vh - ${offsetTop})`;\n el.style.marginTop = offsetTop;\n }\n }\n}\n\nexport default {\n install(Vue /* ,options */) {\n Vue.use(PortalVue);\n /* Create the portal target on initialization.\n Defaults to body. Offset and final position set through sidebar parameter.\n */\n if (document.readyState === 'ready' || document.readyState === 'complete') {\n debug.info(\"Page already loaded\");\n createPortalTarget();\n } else {\n window.addEventListener(\"load\", () => {\n debug.info(\"Page not yet loaded\");\n createPortalTarget();\n });\n }\n\n Vue.component('p-easeinout', {\n template: `\n \n `\n });\n\n Vue.component('p-sidebar', {\n props: {\n value: {\n type: Boolean,\n 'default': true,\n },\n right: {\n type: Boolean,\n 'default': false,\n },\n shadow: {\n type: Boolean,\n 'default': false,\n },\n target: {\n type: String,\n 'default': 'body',\n },\n offsetRef: {\n type: String,\n 'default': '',\n }\n },\n data() {\n return {\n wrapper: null,\n contentwrapper: null,\n resizeobserver: null,\n };\n },\n computed: {\n },\n methods: {\n },\n watch: {\n right(newVal) {\n rePosition(newVal);\n },\n offsetRef(reference) {\n setOffset(reference, this.$refs.portal);\n }\n },\n mounted() {\n debug.info(\"OffsetRef\", this.offsetRef);\n setOffset(this.offsetRef);\n debug.info(\"Right\", this.right);\n rePosition(this.right);\n },\n template: `\n
\n
\n `,\n });\n },\n};"],"names":["wrapper","contentwrapper","resizeObserver","debug","createPortalTarget","target","offsetref","initializeWrapperContent","info","document","querySelector","createElement","setAttribute","appendChild","targetEl","nodeType","console","childNodes","length","rePosition","setOffset","right","el","ResizeObserver","wx","getBoundingClientRect","width","style","setProperty","observe","insertBefore","nextSibling","reference","ref","offsetTop","height","marginTop","install","Vue","use","PortalVue","readyState","window","addEventListener","component","template","props","value","type","Boolean","shadow","String","offsetRef","data","resizeobserver","computed","methods","watch","newVal","this","$refs","portal","mounted"],"mappings":"oWAUIA,QACAC,eACAC,eALAC,MAAQ,2DAAa,sBAahBC,mBAAmBC,OAAQC,eAC5BC,0BAA2B,KAC/BJ,MAAMK,KAAK,0BAGXR,QAAUS,SAASC,cAAc,sBAC5BV,UACDO,0BAA2B,EAE3BP,QAAUS,SAASE,cAAc,OACjCX,QAAQY,aAAa,KAAM,sBAG/BX,eAAiBQ,SAASC,cAAc,6BACnCT,iBACDM,0BAA2B,EAE3BN,eAAiBQ,SAASE,cAAc,OACxCV,eAAeW,aAAa,KAAM,4BAClCZ,QAAQa,YAAYZ,iBAGpBM,yBAA0B,KAEtBO,SAAWL,SAASC,cAAcL,YACjCS,UAAiC,QAArBA,SAASC,WACtBD,SAAWL,SAASC,cAAc,SAEtCM,QAAQR,KAAM,cAAaH,cAAeS,UAGnCA,SAASG,WAAWC,OAAS,GAChCjB,eAAeY,YAAYC,SAASG,WAAW,IAGnDH,SAASD,YAAYb,SAGzBmB,YAAW,GAEXC,UAAUd,oBAOLa,WAAWE,WAGZC,GAAKb,SAASC,cAAe,oBAC5BY,KACDA,GAAKb,SAASE,cAAc,OAC5BW,GAAGV,aAAa,KAAO,mBAGvBV,eAAiB,IAAIqB,g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SAAW"} \ No newline at end of file diff --git a/amd/src/util/psidebar-vue.js b/amd/src/util/psidebar-vue.js index e7b1496..dcf488c 100644 --- a/amd/src/util/psidebar-vue.js +++ b/amd/src/util/psidebar-vue.js @@ -18,8 +18,9 @@ let resizeObserver; * @param {String} offsetref Query string to select element that should appear above the sidebar. * Defaults to none */ -function createPortalTarget(target,offsetref) { +function createPortalTarget(target, offsetref) { let initializeWrapperContent = false; + debug.info("Creating portal target"); // First check if the sidebar wrapper already exists. // Creating the wrappers over and over again is a recipe for disaster. wrapper = document.querySelector("#p-sidebar-wrapper"); @@ -42,10 +43,10 @@ function createPortalTarget(target,offsetref) { if (initializeWrapperContent) { // Find containing target (otherwise use body) let targetEl = document.querySelector(target); - console.info(`Targeting '${target}' to `, targetEl); if (!targetEl || targetEl.nodeType == "HTML") { targetEl = document.querySelector("body"); } + console.info(`Targeting '${target}' to `, targetEl); // Move all target content parts to content wrapper.... while (targetEl.childNodes.length > 0) { @@ -69,7 +70,7 @@ function rePosition(right) { // Find or create the portal target. let el = document.querySelector(`#p-sidebar-mount`); if (!el) { - el = document.createElement("div"); + el = document.createElement("div"); el.setAttribute("id", `p-sidebar-mount`); // Initialize a resizeObser @@ -111,11 +112,17 @@ export default { /* Create the portal target on initialization. Defaults to body. Offset and final position set through sidebar parameter. */ - window.addEventListener("load", () => { + if (document.readyState === 'ready' || document.readyState === 'complete') { + debug.info("Page already loaded"); createPortalTarget(); - }); + } else { + window.addEventListener("load", () => { + debug.info("Page not yet loaded"); + createPortalTarget(); + }); + } - Vue.component('p-easeinout',{ + Vue.component('p-easeinout', { template: ` @@ -155,24 +162,20 @@ export default { computed: { }, methods: { - }, watch: { right(newVal) { rePosition(newVal); }, offsetRef(reference) { - setOffset(reference,this.$refs.portal); + setOffset(reference, this.$refs.portal); } }, mounted() { - debug.info("OffsetRef",this.offsetRef); + debug.info("OffsetRef", this.offsetRef); setOffset(this.offsetRef); - debug.info("Right",this.right); + debug.info("Right", this.right); rePosition(this.right); - }, - unmounted() { - }, template: `