53 lines
1.3 KiB
JavaScript
53 lines
1.3 KiB
JavaScript
import _mergeJSXProps from "@vue/babel-helper-vue-jsx-merge-props";
|
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
// Utils
|
|
import { createNamespace, isDef, noop } from '../utils';
|
|
import { inherit } from '../utils/functional';
|
|
import { preventDefault } from '../utils/dom/event'; // Types
|
|
|
|
var _createNamespace = createNamespace('overlay'),
|
|
createComponent = _createNamespace[0],
|
|
bem = _createNamespace[1];
|
|
|
|
function preventTouchMove(event) {
|
|
preventDefault(event, true);
|
|
}
|
|
|
|
function Overlay(h, props, slots, ctx) {
|
|
var style = _extends({
|
|
zIndex: props.zIndex
|
|
}, props.customStyle);
|
|
|
|
if (isDef(props.duration)) {
|
|
style.animationDuration = props.duration + "s";
|
|
}
|
|
|
|
return h("transition", {
|
|
"attrs": {
|
|
"name": "van-fade"
|
|
}
|
|
}, [h("div", _mergeJSXProps([{
|
|
"directives": [{
|
|
name: "show",
|
|
value: props.show
|
|
}],
|
|
"style": style,
|
|
"class": [bem(), props.className],
|
|
"on": {
|
|
"touchmove": props.lockScroll ? preventTouchMove : noop
|
|
}
|
|
}, inherit(ctx, true)]), [slots.default == null ? void 0 : slots.default()])]);
|
|
}
|
|
|
|
Overlay.props = {
|
|
show: Boolean,
|
|
zIndex: [Number, String],
|
|
duration: [Number, String],
|
|
className: null,
|
|
customStyle: Object,
|
|
lockScroll: {
|
|
type: Boolean,
|
|
default: true
|
|
}
|
|
};
|
|
export default createComponent(Overlay); |