Skip to content

new event after wrapper transitionend #17

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: v3.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,3 +93,7 @@ export default defineComponent({
| boxStyle | Modify the container style, such as the side background color when displaying in the center, conforming to the Vue two-way binding style standard format | Object | null |
| wrapperStyle | Modify the adaptive area style to conform to the Vue two-way binding style standard format | Object | null |
| bodyOverflowHidden | After enabling, the body style will be automatically set to `overflow: hidden` | Boolean | true |

| Event | Desctiption | Params |
| ------------- | ----------------------------| ------- |
| transitionend | after wrapper transitionend | Element |
4 changes: 4 additions & 0 deletions README.zh_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,3 +97,7 @@ export default defineComponent({
| boxStyle | 修改容器样式,如居中展示时侧边背景色,符合 Vue 双向绑定 style 标准格式 | Object | null |
| wrapperStyle | 修改自适应区域样式,符合 Vue 双向绑定 style 标准格式 | Object | null |
| bodyOverflowHidden | 启用后body的样式会自动设置为 `overflow: hidden` | Boolean | true |

| Event | Desctiption | Params |
| ------------- | ----------------------------| ------- |
| transitionend | 自适应区域结束 transition 时 | Element |
7 changes: 6 additions & 1 deletion package/component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ export default defineComponent({
default: true
}
},
setup(props, { slots }) {
emits: ['transitionend'],
setup(props, { slots, emit }) {
let bodyOverflowHidden: string
const state = reactive<IState>({
width: 0,
Expand Down Expand Up @@ -210,6 +211,10 @@ export default defineComponent({
initBodyStyle()
nextTick(async () => {
await initSize()
el.value.addEventListener("transitionend", (e) => {
if (e.currentTarget !== e.target) return
emit('transitionend', e)
})
updateSize()
updateScale()
window.addEventListener('resize', onResize)
Expand Down