@cmstops/pro-compo
Version:
[物料平台文档中心](https://arco.design/docs/material/guide)
51 lines (50 loc) • 1.05 kB
JavaScript
;
var core = require("@popperjs/core");
var vue = require("vue");
function usePopper(pannel, triggerEl) {
const visible = vue.ref(false);
const hide = () => {
visible.value = false;
window.onclick = null;
};
const show = () => {
visible.value = true;
window.onclick = () => {
hide();
visible.value = false;
window.onclick = null;
};
};
const initPopper = (placement = "bottom-start", of) => {
if (!pannel.value || !triggerEl.value)
return;
const offset = of != null ? of : [0, 10];
if (window.__POWERED_BY_WUJIE__) {
offset[1] = -54;
}
core.createPopper(triggerEl.value, pannel.value, {
placement,
modifiers: [
{
name: "computeStyles",
options: {
gpuAcceleration: false
}
},
{
name: "offset",
options: {
offset
}
}
]
});
};
return {
initPopper,
show,
hide,
visible
};
}
module.exports = usePopper;