element-plus/docs/examples/tooltip/virtual-trigger.vue
jeremywu dd19cae2bc
refactor(components): popper composables (#5035)
* refactor(components): popper composables

- Refactor popper composables

* updates

* updates for tooltip

* Updates for popper. TODO: fix controlled tooltip animation

* Fix controlled mode popper animation issue

* Add new feature for customizing tooltip theme

* Fix popover and popconfirm error

* - Add Collection component for wrapping a collection of component
- Add FocusTrap component for trap focus for popups
- Add RovingFocus component for roving focus component type
- Adjust dropdown component based on these newly added components
- Add popper-trigger component for placing the trigger
- TODO: Finish current dropdown component, and all component's tests plus documents

* Refactor popper

* Complete organizing popper

* Almost finish dropdown

* Update popper tests

* update only-child test

* Finish focus trap component test

* Finish tooltip content test

* Finish tooltip trigger tests

* Finish tooltip tests

* finish tests for Collection and RovingFocusGroup

* Fix test cases for timeselect & select & popover

* Fix popover, popconfirm, menu bug and test cases

* Fix select-v2 test error caused by updating popper

* Fix date-picker test issue for updating popper

* fix test cases

* Fix eslint

* Rebase dev & fix tests

* Remove unused code
2022-01-04 09:15:15 +08:00

42 lines
731 B
Vue

<template>
<el-tooltip
v-model:visible="visible"
content="Bottom center"
placement="bottom"
effect="light"
trigger="click"
virtual-triggering
:virtual-ref="triggerRef"
/>
<el-button @click="visible = !visible">test</el-button>
</template>
<script setup lang="ts">
import { ref, onMounted } from 'vue'
const visible = ref(false)
const triggerRef = ref({
getBoundingClientRect() {
return position.value
},
})
const position = ref({
top: 0,
left: 0,
bottom: 0,
right: 0,
})
onMounted(() => {
document.addEventListener('mousemove', (e) => {
position.value = DOMRect.fromRect({
width: 0,
height: 0,
x: e.clientX,
y: e.clientY,
})
})
})
</script>