You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ant-design-vue/components/vc-dialog/Dialog.jsx

433 lines
12 KiB

import { getComponentFromProp } from '../_util/props-util'
7 years ago
import KeyCode from '../_util/KeyCode'
update to antd3.8.3 (#159) * refactor: align * feat: update align to 2.4.3 * feat: update trigger 2.5.4 * feat: update tooltip 3.7.2 * fix: align * feat: update vc-calendar to 9.6.2 * feat: update vc-checkbox to 2.1.5 * feat: update vc-dialog to 7.1.8 * feat: update vc-from to 2.2.1 * feat: update vc-notification to 3.1.1 * test: update snapshots * feat: update vc-tree to 1.12.6 * feat: update vc-table to 6.2.8 * feat: update vc-upload to 2.5.1 * feat: update vc-input-number to 4.0.12 * feat: update vc-tabs to 9.2.6 * refactor: vc-menu * refactor: update vc-menu to 7.0.5 * style: remove unused * feat: update pagination to 1.16.5 * feat: add vc-progress 2.2.5 tag * feat: add vc-rate 2.4.0 tag * feat: update vc-slider to 8.6.1 * fix: tooltip error * style: delete conosle * feat: update vc-steps to 3.1.1 * add vc-switch tag 1.6.0 * feat: update upload to 2.5.1 * fix: update vc-menu * fix: update store * fix: add ref dir * fix: trigger mock shouldComponentUpdate * fix: update vc-select * revert: trigger lazyrenderbox * fix: update vc-select * fix: update vc-select * fix: update vc-select * fix: update vc-menu * fix: update vc-slick ref * update style to 3.8.2 * test: update snapshots * update vc-select * update util & affix * feat: add drawer * fix: support title add slot mode * test: update affix test * update alert * update anchor * update snapshots * fix: doc and vc-drawer * update select & auto-complete * update back-top & grid * feractor: avatar * test: add drawer test * update badge * update button * update card * update divider * feat: update vc-tabs to 9.3.6 and tabs * add afterEnter callback * update form * fix: update drawer * test: update snapshots * update modal & notification * test: update snapshots * update message * update locale-provider * update dropdown * update layout popconfirm popover * update time-picker * update menu * update date-picker * docs: update input docs * update input * update snapshots * update table * update test snapshots * feat: update progress * update checkbox * feat: update spin * update radio * docs: slider steps timeline * update list * update transfer * update collapse * update cascader * update upload
6 years ago
import contains from '../_util/Dom/contains'
7 years ago
import LazyRenderBox from './LazyRenderBox'
import BaseMixin from '../_util/BaseMixin'
import getTransitionProps from '../_util/getTransitionProps'
7 years ago
import getScrollBarSize from '../_util/getScrollBarSize'
7 years ago
import getDialogPropTypes from './IDialogPropTypes'
const IDialogPropTypes = getDialogPropTypes()
let uuid = 0
let openCount = 0
/* eslint react/no-is-mounted:0 */
function noop () {}
7 years ago
function getScroll (w, top) {
let ret = w[`page${top ? 'Y' : 'X'}Offset`]
const method = `scroll${top ? 'Top' : 'Left'}`
if (typeof ret !== 'number') {
const d = w.document
ret = d.documentElement[method]
if (typeof ret !== 'number') {
ret = d.body[method]
}
}
return ret
}
function setTransformOrigin (node, value) {
const style = node.style;
['Webkit', 'Moz', 'Ms', 'ms'].forEach((prefix) => {
style[`${prefix}TransformOrigin`] = value
})
style[`transformOrigin`] = value
}
function offset (el) {
const rect = el.getBoundingClientRect()
const pos = {
left: rect.left,
top: rect.top,
}
const doc = el.ownerDocument
const w = doc.defaultView || doc.parentWindow
pos.left += getScroll(w)
pos.top += getScroll(w, true)
return pos
}
const initDefaultProps = (propTypes, defaultProps) => {
return Object.keys(defaultProps).map(k => propTypes[k].def(defaultProps[k]))
}
export default {
mixins: [BaseMixin],
props: {
...IDialogPropTypes,
...initDefaultProps(IDialogPropTypes, {
mask: true,
visible: false,
keyboard: true,
closable: true,
maskClosable: true,
destroyOnClose: false,
prefixCls: 'rc-dialog',
}),
},
7 years ago
data () {
return {
destroyPopup: false,
}
},
7 years ago
// private inTransition: boolean;
// private titleId: string;
// private openTime: number;
// private lastOutSideFocusNode: HTMLElement | null;
// private wrap: HTMLElement;
// private dialog: any;
// private sentinel: HTMLElement;
// private bodyIsOverflowing: boolean;
// private scrollbarWidth: number;
beforeMount () {
this.inTransition = false
this.titleId = `rcDialogTitle${uuid++}`
},
mounted () {
this.$nextTick(() => {
this.updatedCallback(false)
})
},
watch: {
visible (val) {
7 years ago
if (val) {
this.destroyPopup = false
}
this.$nextTick(() => {
this.updatedCallback(!val)
})
7 years ago
},
},
beforeDestroy () {
7 years ago
if (this.visible || this.inTransition) {
7 years ago
this.removeScrollingEffect()
}
},
methods: {
updatedCallback (visible) {
const mousePosition = this.mousePosition
if (this.visible) {
// first show
if (!visible) {
this.openTime = Date.now()
update to antd3.8.3 (#159) * refactor: align * feat: update align to 2.4.3 * feat: update trigger 2.5.4 * feat: update tooltip 3.7.2 * fix: align * feat: update vc-calendar to 9.6.2 * feat: update vc-checkbox to 2.1.5 * feat: update vc-dialog to 7.1.8 * feat: update vc-from to 2.2.1 * feat: update vc-notification to 3.1.1 * test: update snapshots * feat: update vc-tree to 1.12.6 * feat: update vc-table to 6.2.8 * feat: update vc-upload to 2.5.1 * feat: update vc-input-number to 4.0.12 * feat: update vc-tabs to 9.2.6 * refactor: vc-menu * refactor: update vc-menu to 7.0.5 * style: remove unused * feat: update pagination to 1.16.5 * feat: add vc-progress 2.2.5 tag * feat: add vc-rate 2.4.0 tag * feat: update vc-slider to 8.6.1 * fix: tooltip error * style: delete conosle * feat: update vc-steps to 3.1.1 * add vc-switch tag 1.6.0 * feat: update upload to 2.5.1 * fix: update vc-menu * fix: update store * fix: add ref dir * fix: trigger mock shouldComponentUpdate * fix: update vc-select * revert: trigger lazyrenderbox * fix: update vc-select * fix: update vc-select * fix: update vc-select * fix: update vc-menu * fix: update vc-slick ref * update style to 3.8.2 * test: update snapshots * update vc-select * update util & affix * feat: add drawer * fix: support title add slot mode * test: update affix test * update alert * update anchor * update snapshots * fix: doc and vc-drawer * update select & auto-complete * update back-top & grid * feractor: avatar * test: add drawer test * update badge * update button * update card * update divider * feat: update vc-tabs to 9.3.6 and tabs * add afterEnter callback * update form * fix: update drawer * test: update snapshots * update modal & notification * test: update snapshots * update message * update locale-provider * update dropdown * update layout popconfirm popover * update time-picker * update menu * update date-picker * docs: update input docs * update input * update snapshots * update table * update test snapshots * feat: update progress * update checkbox * feat: update spin * update radio * docs: slider steps timeline * update list * update transfer * update collapse * update cascader * update upload
6 years ago
// this.lastOutSideFocusNode = document.activeElement
7 years ago
this.addScrollingEffect()
update to antd3.8.3 (#159) * refactor: align * feat: update align to 2.4.3 * feat: update trigger 2.5.4 * feat: update tooltip 3.7.2 * fix: align * feat: update vc-calendar to 9.6.2 * feat: update vc-checkbox to 2.1.5 * feat: update vc-dialog to 7.1.8 * feat: update vc-from to 2.2.1 * feat: update vc-notification to 3.1.1 * test: update snapshots * feat: update vc-tree to 1.12.6 * feat: update vc-table to 6.2.8 * feat: update vc-upload to 2.5.1 * feat: update vc-input-number to 4.0.12 * feat: update vc-tabs to 9.2.6 * refactor: vc-menu * refactor: update vc-menu to 7.0.5 * style: remove unused * feat: update pagination to 1.16.5 * feat: add vc-progress 2.2.5 tag * feat: add vc-rate 2.4.0 tag * feat: update vc-slider to 8.6.1 * fix: tooltip error * style: delete conosle * feat: update vc-steps to 3.1.1 * add vc-switch tag 1.6.0 * feat: update upload to 2.5.1 * fix: update vc-menu * fix: update store * fix: add ref dir * fix: trigger mock shouldComponentUpdate * fix: update vc-select * revert: trigger lazyrenderbox * fix: update vc-select * fix: update vc-select * fix: update vc-select * fix: update vc-menu * fix: update vc-slick ref * update style to 3.8.2 * test: update snapshots * update vc-select * update util & affix * feat: add drawer * fix: support title add slot mode * test: update affix test * update alert * update anchor * update snapshots * fix: doc and vc-drawer * update select & auto-complete * update back-top & grid * feractor: avatar * test: add drawer test * update badge * update button * update card * update divider * feat: update vc-tabs to 9.3.6 and tabs * add afterEnter callback * update form * fix: update drawer * test: update snapshots * update modal & notification * test: update snapshots * update message * update locale-provider * update dropdown * update layout popconfirm popover * update time-picker * update menu * update date-picker * docs: update input docs * update input * update snapshots * update table * update test snapshots * feat: update progress * update checkbox * feat: update spin * update radio * docs: slider steps timeline * update list * update transfer * update collapse * update cascader * update upload
6 years ago
// this.$refs.wrap.focus()
this.tryFocus()
7 years ago
const dialogNode = this.$refs.dialog.$el
7 years ago
if (mousePosition) {
const elOffset = offset(dialogNode)
setTransformOrigin(dialogNode,
`${mousePosition.x - elOffset.left}px ${mousePosition.y - elOffset.top}px`)
} else {
setTransformOrigin(dialogNode, '')
}
}
} else if (visible) {
this.inTransition = true
if (this.mask && this.lastOutSideFocusNode) {
try {
this.lastOutSideFocusNode.focus()
} catch (e) {
this.lastOutSideFocusNode = null
}
this.lastOutSideFocusNode = null
}
}
},
update to antd3.8.3 (#159) * refactor: align * feat: update align to 2.4.3 * feat: update trigger 2.5.4 * feat: update tooltip 3.7.2 * fix: align * feat: update vc-calendar to 9.6.2 * feat: update vc-checkbox to 2.1.5 * feat: update vc-dialog to 7.1.8 * feat: update vc-from to 2.2.1 * feat: update vc-notification to 3.1.1 * test: update snapshots * feat: update vc-tree to 1.12.6 * feat: update vc-table to 6.2.8 * feat: update vc-upload to 2.5.1 * feat: update vc-input-number to 4.0.12 * feat: update vc-tabs to 9.2.6 * refactor: vc-menu * refactor: update vc-menu to 7.0.5 * style: remove unused * feat: update pagination to 1.16.5 * feat: add vc-progress 2.2.5 tag * feat: add vc-rate 2.4.0 tag * feat: update vc-slider to 8.6.1 * fix: tooltip error * style: delete conosle * feat: update vc-steps to 3.1.1 * add vc-switch tag 1.6.0 * feat: update upload to 2.5.1 * fix: update vc-menu * fix: update store * fix: add ref dir * fix: trigger mock shouldComponentUpdate * fix: update vc-select * revert: trigger lazyrenderbox * fix: update vc-select * fix: update vc-select * fix: update vc-select * fix: update vc-menu * fix: update vc-slick ref * update style to 3.8.2 * test: update snapshots * update vc-select * update util & affix * feat: add drawer * fix: support title add slot mode * test: update affix test * update alert * update anchor * update snapshots * fix: doc and vc-drawer * update select & auto-complete * update back-top & grid * feractor: avatar * test: add drawer test * update badge * update button * update card * update divider * feat: update vc-tabs to 9.3.6 and tabs * add afterEnter callback * update form * fix: update drawer * test: update snapshots * update modal & notification * test: update snapshots * update message * update locale-provider * update dropdown * update layout popconfirm popover * update time-picker * update menu * update date-picker * docs: update input docs * update input * update snapshots * update table * update test snapshots * feat: update progress * update checkbox * feat: update spin * update radio * docs: slider steps timeline * update list * update transfer * update collapse * update cascader * update upload
6 years ago
tryFocus () {
if (!contains(this.$refs.wrap, document.activeElement)) {
this.lastOutSideFocusNode = document.activeElement
this.$refs.sentinelStart.focus()
update to antd3.8.3 (#159) * refactor: align * feat: update align to 2.4.3 * feat: update trigger 2.5.4 * feat: update tooltip 3.7.2 * fix: align * feat: update vc-calendar to 9.6.2 * feat: update vc-checkbox to 2.1.5 * feat: update vc-dialog to 7.1.8 * feat: update vc-from to 2.2.1 * feat: update vc-notification to 3.1.1 * test: update snapshots * feat: update vc-tree to 1.12.6 * feat: update vc-table to 6.2.8 * feat: update vc-upload to 2.5.1 * feat: update vc-input-number to 4.0.12 * feat: update vc-tabs to 9.2.6 * refactor: vc-menu * refactor: update vc-menu to 7.0.5 * style: remove unused * feat: update pagination to 1.16.5 * feat: add vc-progress 2.2.5 tag * feat: add vc-rate 2.4.0 tag * feat: update vc-slider to 8.6.1 * fix: tooltip error * style: delete conosle * feat: update vc-steps to 3.1.1 * add vc-switch tag 1.6.0 * feat: update upload to 2.5.1 * fix: update vc-menu * fix: update store * fix: add ref dir * fix: trigger mock shouldComponentUpdate * fix: update vc-select * revert: trigger lazyrenderbox * fix: update vc-select * fix: update vc-select * fix: update vc-select * fix: update vc-menu * fix: update vc-slick ref * update style to 3.8.2 * test: update snapshots * update vc-select * update util & affix * feat: add drawer * fix: support title add slot mode * test: update affix test * update alert * update anchor * update snapshots * fix: doc and vc-drawer * update select & auto-complete * update back-top & grid * feractor: avatar * test: add drawer test * update badge * update button * update card * update divider * feat: update vc-tabs to 9.3.6 and tabs * add afterEnter callback * update form * fix: update drawer * test: update snapshots * update modal & notification * test: update snapshots * update message * update locale-provider * update dropdown * update layout popconfirm popover * update time-picker * update menu * update date-picker * docs: update input docs * update input * update snapshots * update table * update test snapshots * feat: update progress * update checkbox * feat: update spin * update radio * docs: slider steps timeline * update list * update transfer * update collapse * update cascader * update upload
6 years ago
}
},
7 years ago
onAnimateLeave () {
7 years ago
const { afterClose, destroyOnClose } = this
7 years ago
// need demo?
// https://github.com/react-component/dialog/pull/28
if (this.$refs.wrap) {
this.$refs.wrap.style.display = 'none'
}
7 years ago
if (destroyOnClose) {
this.destroyPopup = true
}
7 years ago
this.inTransition = false
this.removeScrollingEffect()
if (afterClose) {
afterClose()
}
},
onMaskClick (e) {
// android trigger click on open (fastclick??)
if (Date.now() - this.openTime < 300) {
return
}
if (e.target === e.currentTarget) {
this.close(e)
}
},
onKeydown (e) {
const props = this.$props
if (props.keyboard && e.keyCode === KeyCode.ESC) {
update to antd3.8.3 (#159) * refactor: align * feat: update align to 2.4.3 * feat: update trigger 2.5.4 * feat: update tooltip 3.7.2 * fix: align * feat: update vc-calendar to 9.6.2 * feat: update vc-checkbox to 2.1.5 * feat: update vc-dialog to 7.1.8 * feat: update vc-from to 2.2.1 * feat: update vc-notification to 3.1.1 * test: update snapshots * feat: update vc-tree to 1.12.6 * feat: update vc-table to 6.2.8 * feat: update vc-upload to 2.5.1 * feat: update vc-input-number to 4.0.12 * feat: update vc-tabs to 9.2.6 * refactor: vc-menu * refactor: update vc-menu to 7.0.5 * style: remove unused * feat: update pagination to 1.16.5 * feat: add vc-progress 2.2.5 tag * feat: add vc-rate 2.4.0 tag * feat: update vc-slider to 8.6.1 * fix: tooltip error * style: delete conosle * feat: update vc-steps to 3.1.1 * add vc-switch tag 1.6.0 * feat: update upload to 2.5.1 * fix: update vc-menu * fix: update store * fix: add ref dir * fix: trigger mock shouldComponentUpdate * fix: update vc-select * revert: trigger lazyrenderbox * fix: update vc-select * fix: update vc-select * fix: update vc-select * fix: update vc-menu * fix: update vc-slick ref * update style to 3.8.2 * test: update snapshots * update vc-select * update util & affix * feat: add drawer * fix: support title add slot mode * test: update affix test * update alert * update anchor * update snapshots * fix: doc and vc-drawer * update select & auto-complete * update back-top & grid * feractor: avatar * test: add drawer test * update badge * update button * update card * update divider * feat: update vc-tabs to 9.3.6 and tabs * add afterEnter callback * update form * fix: update drawer * test: update snapshots * update modal & notification * test: update snapshots * update message * update locale-provider * update dropdown * update layout popconfirm popover * update time-picker * update menu * update date-picker * docs: update input docs * update input * update snapshots * update table * update test snapshots * feat: update progress * update checkbox * feat: update spin * update radio * docs: slider steps timeline * update list * update transfer * update collapse * update cascader * update upload
6 years ago
e.stopPropagation()
7 years ago
this.close(e)
update to antd3.8.3 (#159) * refactor: align * feat: update align to 2.4.3 * feat: update trigger 2.5.4 * feat: update tooltip 3.7.2 * fix: align * feat: update vc-calendar to 9.6.2 * feat: update vc-checkbox to 2.1.5 * feat: update vc-dialog to 7.1.8 * feat: update vc-from to 2.2.1 * feat: update vc-notification to 3.1.1 * test: update snapshots * feat: update vc-tree to 1.12.6 * feat: update vc-table to 6.2.8 * feat: update vc-upload to 2.5.1 * feat: update vc-input-number to 4.0.12 * feat: update vc-tabs to 9.2.6 * refactor: vc-menu * refactor: update vc-menu to 7.0.5 * style: remove unused * feat: update pagination to 1.16.5 * feat: add vc-progress 2.2.5 tag * feat: add vc-rate 2.4.0 tag * feat: update vc-slider to 8.6.1 * fix: tooltip error * style: delete conosle * feat: update vc-steps to 3.1.1 * add vc-switch tag 1.6.0 * feat: update upload to 2.5.1 * fix: update vc-menu * fix: update store * fix: add ref dir * fix: trigger mock shouldComponentUpdate * fix: update vc-select * revert: trigger lazyrenderbox * fix: update vc-select * fix: update vc-select * fix: update vc-select * fix: update vc-menu * fix: update vc-slick ref * update style to 3.8.2 * test: update snapshots * update vc-select * update util & affix * feat: add drawer * fix: support title add slot mode * test: update affix test * update alert * update anchor * update snapshots * fix: doc and vc-drawer * update select & auto-complete * update back-top & grid * feractor: avatar * test: add drawer test * update badge * update button * update card * update divider * feat: update vc-tabs to 9.3.6 and tabs * add afterEnter callback * update form * fix: update drawer * test: update snapshots * update modal & notification * test: update snapshots * update message * update locale-provider * update dropdown * update layout popconfirm popover * update time-picker * update menu * update date-picker * docs: update input docs * update input * update snapshots * update table * update test snapshots * feat: update progress * update checkbox * feat: update spin * update radio * docs: slider steps timeline * update list * update transfer * update collapse * update cascader * update upload
6 years ago
return
7 years ago
}
// keep focus inside dialog
if (props.visible) {
if (e.keyCode === KeyCode.TAB) {
const activeElement = document.activeElement
const sentinelStart = this.$refs.sentinelStart
7 years ago
if (e.shiftKey) {
if (activeElement === sentinelStart) {
this.$refs.sentinelEnd.focus()
7 years ago
}
} else if (activeElement === this.$refs.sentinelEnd) {
sentinelStart.focus()
7 years ago
}
}
}
},
getDialogElement () {
7 years ago
const { closable, prefixCls, width, height,
6 years ago
title, footer: tempFooter, bodyStyle, visible, bodyProps } = this
7 years ago
const dest = {}
7 years ago
if (width !== undefined) {
dest.width = typeof width === 'number' ? `${width}px` : width
7 years ago
}
7 years ago
if (height !== undefined) {
dest.height = typeof height === 'number' ? `${height}px` : height
7 years ago
}
let footer
7 years ago
if (tempFooter) {
7 years ago
footer = (
<div key='footer' class={`${prefixCls}-footer`} ref='footer'>
7 years ago
{tempFooter}
7 years ago
</div>
)
}
let header
7 years ago
if (title) {
7 years ago
header = (
<div key='header' class={`${prefixCls}-header`} ref='header'>
7 years ago
<div class={`${prefixCls}-title`} id={this.titleId}>
7 years ago
{title}
7 years ago
</div>
</div>
)
}
let closer
if (closable) {
const closeIcon = getComponentFromProp(this, 'closeIcon')
7 years ago
closer = (
<button
key='close'
onClick={this.close || noop}
7 years ago
aria-label='Close'
class={`${prefixCls}-close`}
>
{closeIcon || <span class={`${prefixCls}-close-x`} />}
7 years ago
</button>)
}
7 years ago
const style = { ...this.dialogStyle, ...dest }
const sentinelStyle = { width: 0, height: 0, overflow: 'hidden' }
7 years ago
const cls = {
[prefixCls]: true,
...this.dialogClass,
}
7 years ago
const transitionName = this.getTransitionName()
const dialogElement = (
<LazyRenderBox
7 years ago
v-show={visible}
7 years ago
key='dialog-element'
role='document'
ref='dialog'
style={style}
7 years ago
class={cls}
7 years ago
>
<div tabIndex={0} ref='sentinelStart' style={sentinelStyle}>
sentinelStart
</div>
7 years ago
<div class={`${prefixCls}-content`}>
{closer}
{header}
<div
key='body'
7 years ago
class={`${prefixCls}-body`}
7 years ago
style={bodyStyle}
7 years ago
ref='body'
7 years ago
{...bodyProps}
7 years ago
>
{this.$slots.default}
</div>
{footer}
</div>
<div tabIndex={0} ref='sentinelEnd' style={sentinelStyle}>
sentinelEnd
7 years ago
</div>
</LazyRenderBox>
)
const dialogTransitionProps = getTransitionProps(transitionName, {
afterLeave: this.onAnimateLeave,
})
return (
<transition
key='dialog'
{...dialogTransitionProps}
>
7 years ago
{(visible || !this.destroyPopup) ? dialogElement : null}
7 years ago
</transition>
)
},
getZIndexStyle () {
const style = {}
const props = this.$props
if (props.zIndex !== undefined) {
style.zIndex = props.zIndex
}
return style
},
getWrapStyle () {
return { ...this.getZIndexStyle(), ...this.wrapStyle }
},
getMaskStyle () {
return { ...this.getZIndexStyle(), ...this.maskStyle }
},
getMaskElement () {
const props = this.$props
let maskElement
if (props.mask) {
const maskTransition = this.getMaskTransitionName()
maskElement = (
<LazyRenderBox
v-show={props.visible}
style={this.getMaskStyle()}
key='mask'
class={`${props.prefixCls}-mask`}
{...props.maskProps}
/>
)
if (maskTransition) {
const maskTransitionProps = getTransitionProps(maskTransition)
maskElement = (
<transition
key='mask'
{...maskTransitionProps}
>
{maskElement}
</transition>
)
}
}
return maskElement
},
getMaskTransitionName () {
const props = this.$props
let transitionName = props.maskTransitionName
const animation = props.maskAnimation
if (!transitionName && animation) {
transitionName = `${props.prefixCls}-${animation}`
}
return transitionName
},
getTransitionName () {
const props = this.$props
let transitionName = props.transitionName
const animation = props.animation
if (!transitionName && animation) {
transitionName = `${props.prefixCls}-${animation}`
}
return transitionName
},
setScrollbar () {
if (this.bodyIsOverflowing && this.scrollbarWidth !== undefined) {
document.body.style.paddingRight = `${this.scrollbarWidth}px`
}
},
addScrollingEffect () {
openCount++
if (openCount !== 1) {
return
}
this.checkScrollbar()
this.setScrollbar()
document.body.style.overflow = 'hidden'
// this.adjustDialog();
},
removeScrollingEffect () {
openCount--
if (openCount !== 0) {
return
}
document.body.style.overflow = ''
this.resetScrollbar()
// this.resetAdjustments();
},
close (e) {
this.__emit('close', e)
},
checkScrollbar () {
let fullWindowWidth = window.innerWidth
if (!fullWindowWidth) { // workaround for missing window.innerWidth in IE8
const documentElementRect = document.documentElement.getBoundingClientRect()
fullWindowWidth = documentElementRect.right - Math.abs(documentElementRect.left)
}
this.bodyIsOverflowing = document.body.clientWidth < fullWindowWidth
if (this.bodyIsOverflowing) {
this.scrollbarWidth = getScrollBarSize()
}
},
resetScrollbar () {
document.body.style.paddingRight = ''
},
adjustDialog () {
if (this.$refs.wrap && this.scrollbarWidth !== undefined) {
const modalIsOverflowing =
this.$refs.wrap.scrollHeight > document.documentElement.clientHeight
this.$refs.wrap.style.paddingLeft =
`${!this.bodyIsOverflowing && modalIsOverflowing ? this.scrollbarWidth : ''}px`
this.$refs.wrap.style.paddingRight =
`${this.bodyIsOverflowing && !modalIsOverflowing ? this.scrollbarWidth : ''}px`
}
},
resetAdjustments () {
if (this.$refs.wrap) {
this.$refs.wrap.style.paddingLeft = this.$refs.wrap.style.paddingLeft = ''
}
},
},
render () {
const { prefixCls, maskClosable, visible, wrapClassName, title, wrapProps } = this
const style = this.getWrapStyle()
// clear hide display
// and only set display after async anim, not here for hide
if (visible) {
style.display = null
}
return (
<div>
{this.getMaskElement()}
<div
tabIndex={-1}
onKeydown={this.onKeydown}
class={`${prefixCls}-wrap ${wrapClassName || ''}`}
7 years ago
ref='wrap'
onClick={maskClosable ? this.onMaskClick : noop}
7 years ago
role='dialog'
aria-labelledby={title ? this.titleId : null}
style={style}
{...wrapProps}
>
{this.getDialogElement()}
</div>
</div>
)
},
}