Skip to content

Commit 1e93b70

Browse files
author
luchunyu
committed
fix(cascader): fix cascader menu popupstyle
1 parent 4dec9ee commit 1e93b70

File tree

1 file changed

+2
-26
lines changed

1 file changed

+2
-26
lines changed

src/components/cascader/index.vue

Lines changed: 2 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131

3232
<script>
3333
import './index.css'
34-
import zIndexManager from '@util/zIndexManager.js'
34+
import { getPopupStyle } from '@util'
3535
3636
import Menu from './menu.vue'
3737
import Icon from '../icon/index.vue'
@@ -172,31 +172,7 @@ export default {
172172
}
173173
},
174174
getStyle () {
175-
const clientRect = this.$el.getBoundingClientRect()
176-
const windowH = window.innerHeight
177-
const marginTop = 2
178-
const scrollBarWidth = 20
179-
const scrollHeight =
180-
document.body.scrollWidth > window.innerWidth ? scrollBarWidth : 0
181-
const droplistHeight = this.cascaderMenu.clientHeight
182-
const defaultTop =
183-
clientRect.top + clientRect.height + marginTop + window.pageYOffset
184-
const clientHeight = clientRect.height + marginTop
185-
186-
const clientY = clientRect.y
187-
const compTop = windowH - droplistHeight - scrollHeight
188-
const left = clientRect.left + window.pageXOffset
189-
const top =
190-
droplistHeight + clientHeight + clientY + scrollHeight > windowH
191-
? compTop
192-
: defaultTop
193-
const zIndex = zIndexManager.next()
194-
return `
195-
position: absolute;
196-
top: ${top}px;
197-
left: ${left}px;
198-
z-index: ${zIndex};
199-
`
175+
return getPopupStyle(this.$el, this.cascaderMenu)
200176
},
201177
resize () {
202178
this.$nextTick(() => {

0 commit comments

Comments
 (0)