index.js 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. import _mergeJSXProps from "@vue/babel-helper-vue-jsx-merge-props";
  2. import _extends from "@babel/runtime/helpers/esm/extends";
  3. // Utils
  4. import { createNamespace, isDef, noop } from '../utils';
  5. import { inherit } from '../utils/functional';
  6. import { preventDefault } from '../utils/dom/event'; // Types
  7. var _createNamespace = createNamespace('overlay'),
  8. createComponent = _createNamespace[0],
  9. bem = _createNamespace[1];
  10. function preventTouchMove(event) {
  11. preventDefault(event, true);
  12. }
  13. function Overlay(h, props, slots, ctx) {
  14. var style = _extends({
  15. zIndex: props.zIndex
  16. }, props.customStyle);
  17. if (isDef(props.duration)) {
  18. style.animationDuration = props.duration + "s";
  19. }
  20. return h("transition", {
  21. "attrs": {
  22. "name": "van-fade"
  23. }
  24. }, [h("div", _mergeJSXProps([{
  25. "directives": [{
  26. name: "show",
  27. value: props.show
  28. }],
  29. "style": style,
  30. "class": [bem(), props.className],
  31. "on": {
  32. "touchmove": props.lockScroll ? preventTouchMove : noop
  33. }
  34. }, inherit(ctx, true)]), [slots.default == null ? void 0 : slots.default()])]);
  35. }
  36. Overlay.props = {
  37. show: Boolean,
  38. zIndex: [Number, String],
  39. duration: [Number, String],
  40. className: null,
  41. customStyle: Object,
  42. lockScroll: {
  43. type: Boolean,
  44. default: true
  45. }
  46. };
  47. export default createComponent(Overlay);