@element-plus/nightly 0.0.20220729 → 0.0.20220801
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.full.js +2 -2
- package/dist/index.full.min.js +2 -2
- package/dist/index.full.min.js.map +1 -1
- package/dist/index.full.min.mjs +2 -2
- package/dist/index.full.min.mjs.map +1 -1
- package/dist/index.full.mjs +2 -2
- package/dist/locale/af.js +1 -1
- package/dist/locale/af.min.js +1 -1
- package/dist/locale/af.min.mjs +1 -1
- package/dist/locale/af.mjs +1 -1
- package/dist/locale/ar.js +1 -1
- package/dist/locale/ar.min.js +1 -1
- package/dist/locale/ar.min.mjs +1 -1
- package/dist/locale/ar.mjs +1 -1
- package/dist/locale/az.js +1 -1
- package/dist/locale/az.min.js +1 -1
- package/dist/locale/az.min.mjs +1 -1
- package/dist/locale/az.mjs +1 -1
- package/dist/locale/bg.js +1 -1
- package/dist/locale/bg.min.js +1 -1
- package/dist/locale/bg.min.mjs +1 -1
- package/dist/locale/bg.mjs +1 -1
- package/dist/locale/bn.js +1 -1
- package/dist/locale/bn.min.js +1 -1
- package/dist/locale/bn.min.mjs +1 -1
- package/dist/locale/bn.mjs +1 -1
- package/dist/locale/ca.js +1 -1
- package/dist/locale/ca.min.js +1 -1
- package/dist/locale/ca.min.mjs +1 -1
- package/dist/locale/ca.mjs +1 -1
- package/dist/locale/cs.js +1 -1
- package/dist/locale/cs.min.js +1 -1
- package/dist/locale/cs.min.mjs +1 -1
- package/dist/locale/cs.mjs +1 -1
- package/dist/locale/da.js +1 -1
- package/dist/locale/da.min.js +1 -1
- package/dist/locale/da.min.mjs +1 -1
- package/dist/locale/da.mjs +1 -1
- package/dist/locale/de.js +1 -1
- package/dist/locale/de.min.js +1 -1
- package/dist/locale/de.min.mjs +1 -1
- package/dist/locale/de.mjs +1 -1
- package/dist/locale/el.js +1 -1
- package/dist/locale/el.min.js +1 -1
- package/dist/locale/el.min.mjs +1 -1
- package/dist/locale/el.mjs +1 -1
- package/dist/locale/en.js +1 -1
- package/dist/locale/en.min.js +1 -1
- package/dist/locale/en.min.mjs +1 -1
- package/dist/locale/en.mjs +1 -1
- package/dist/locale/eo.js +1 -1
- package/dist/locale/eo.min.js +1 -1
- package/dist/locale/eo.min.mjs +1 -1
- package/dist/locale/eo.mjs +1 -1
- package/dist/locale/es.js +1 -1
- package/dist/locale/es.min.js +1 -1
- package/dist/locale/es.min.mjs +1 -1
- package/dist/locale/es.mjs +1 -1
- package/dist/locale/et.js +1 -1
- package/dist/locale/et.min.js +1 -1
- package/dist/locale/et.min.mjs +1 -1
- package/dist/locale/et.mjs +1 -1
- package/dist/locale/eu.js +1 -1
- package/dist/locale/eu.min.js +1 -1
- package/dist/locale/eu.min.mjs +1 -1
- package/dist/locale/eu.mjs +1 -1
- package/dist/locale/fa.js +1 -1
- package/dist/locale/fa.min.js +1 -1
- package/dist/locale/fa.min.mjs +1 -1
- package/dist/locale/fa.mjs +1 -1
- package/dist/locale/fi.js +1 -1
- package/dist/locale/fi.min.js +1 -1
- package/dist/locale/fi.min.mjs +1 -1
- package/dist/locale/fi.mjs +1 -1
- package/dist/locale/fr.js +1 -1
- package/dist/locale/fr.min.js +1 -1
- package/dist/locale/fr.min.mjs +1 -1
- package/dist/locale/fr.mjs +1 -1
- package/dist/locale/he.js +1 -1
- package/dist/locale/he.min.js +1 -1
- package/dist/locale/he.min.mjs +1 -1
- package/dist/locale/he.mjs +1 -1
- package/dist/locale/hr.js +1 -1
- package/dist/locale/hr.min.js +1 -1
- package/dist/locale/hr.min.mjs +1 -1
- package/dist/locale/hr.mjs +1 -1
- package/dist/locale/hu.js +1 -1
- package/dist/locale/hu.min.js +1 -1
- package/dist/locale/hu.min.mjs +1 -1
- package/dist/locale/hu.mjs +1 -1
- package/dist/locale/hy-am.js +1 -1
- package/dist/locale/hy-am.min.js +1 -1
- package/dist/locale/hy-am.min.mjs +1 -1
- package/dist/locale/hy-am.mjs +1 -1
- package/dist/locale/id.js +1 -1
- package/dist/locale/id.min.js +1 -1
- package/dist/locale/id.min.mjs +1 -1
- package/dist/locale/id.mjs +1 -1
- package/dist/locale/it.js +1 -1
- package/dist/locale/it.min.js +1 -1
- package/dist/locale/it.min.mjs +1 -1
- package/dist/locale/it.mjs +1 -1
- package/dist/locale/ja.js +1 -1
- package/dist/locale/ja.min.js +1 -1
- package/dist/locale/ja.min.mjs +1 -1
- package/dist/locale/ja.mjs +1 -1
- package/dist/locale/kk.js +1 -1
- package/dist/locale/kk.min.js +1 -1
- package/dist/locale/kk.min.mjs +1 -1
- package/dist/locale/kk.mjs +1 -1
- package/dist/locale/km.js +1 -1
- package/dist/locale/km.min.js +1 -1
- package/dist/locale/km.min.mjs +1 -1
- package/dist/locale/km.mjs +1 -1
- package/dist/locale/ko.js +1 -1
- package/dist/locale/ko.min.js +1 -1
- package/dist/locale/ko.min.mjs +1 -1
- package/dist/locale/ko.mjs +1 -1
- package/dist/locale/ku.js +1 -1
- package/dist/locale/ku.min.js +1 -1
- package/dist/locale/ku.min.mjs +1 -1
- package/dist/locale/ku.mjs +1 -1
- package/dist/locale/ky.js +1 -1
- package/dist/locale/ky.min.js +1 -1
- package/dist/locale/ky.min.mjs +1 -1
- package/dist/locale/ky.mjs +1 -1
- package/dist/locale/lt.js +1 -1
- package/dist/locale/lt.min.js +1 -1
- package/dist/locale/lt.min.mjs +1 -1
- package/dist/locale/lt.mjs +1 -1
- package/dist/locale/lv.js +1 -1
- package/dist/locale/lv.min.js +1 -1
- package/dist/locale/lv.min.mjs +1 -1
- package/dist/locale/lv.mjs +1 -1
- package/dist/locale/mg.js +1 -1
- package/dist/locale/mg.min.js +1 -1
- package/dist/locale/mg.min.mjs +1 -1
- package/dist/locale/mg.mjs +1 -1
- package/dist/locale/mn.js +1 -1
- package/dist/locale/mn.min.js +1 -1
- package/dist/locale/mn.min.mjs +1 -1
- package/dist/locale/mn.mjs +1 -1
- package/dist/locale/nb-no.js +1 -1
- package/dist/locale/nb-no.min.js +1 -1
- package/dist/locale/nb-no.min.mjs +1 -1
- package/dist/locale/nb-no.mjs +1 -1
- package/dist/locale/nl.js +1 -1
- package/dist/locale/nl.min.js +1 -1
- package/dist/locale/nl.min.mjs +1 -1
- package/dist/locale/nl.mjs +1 -1
- package/dist/locale/pa.js +1 -1
- package/dist/locale/pa.min.js +1 -1
- package/dist/locale/pa.min.mjs +1 -1
- package/dist/locale/pa.mjs +1 -1
- package/dist/locale/pl.js +1 -1
- package/dist/locale/pl.min.js +1 -1
- package/dist/locale/pl.min.mjs +1 -1
- package/dist/locale/pl.mjs +1 -1
- package/dist/locale/pt-br.js +1 -1
- package/dist/locale/pt-br.min.js +1 -1
- package/dist/locale/pt-br.min.mjs +1 -1
- package/dist/locale/pt-br.mjs +1 -1
- package/dist/locale/pt.js +1 -1
- package/dist/locale/pt.min.js +1 -1
- package/dist/locale/pt.min.mjs +1 -1
- package/dist/locale/pt.mjs +1 -1
- package/dist/locale/ro.js +1 -1
- package/dist/locale/ro.min.js +1 -1
- package/dist/locale/ro.min.mjs +1 -1
- package/dist/locale/ro.mjs +1 -1
- package/dist/locale/ru.js +1 -1
- package/dist/locale/ru.min.js +1 -1
- package/dist/locale/ru.min.mjs +1 -1
- package/dist/locale/ru.mjs +1 -1
- package/dist/locale/sk.js +1 -1
- package/dist/locale/sk.min.js +1 -1
- package/dist/locale/sk.min.mjs +1 -1
- package/dist/locale/sk.mjs +1 -1
- package/dist/locale/sl.js +1 -1
- package/dist/locale/sl.min.js +1 -1
- package/dist/locale/sl.min.mjs +1 -1
- package/dist/locale/sl.mjs +1 -1
- package/dist/locale/sr.js +1 -1
- package/dist/locale/sr.min.js +1 -1
- package/dist/locale/sr.min.mjs +1 -1
- package/dist/locale/sr.mjs +1 -1
- package/dist/locale/sv.js +1 -1
- package/dist/locale/sv.min.js +1 -1
- package/dist/locale/sv.min.mjs +1 -1
- package/dist/locale/sv.mjs +1 -1
- package/dist/locale/ta.js +1 -1
- package/dist/locale/ta.min.js +1 -1
- package/dist/locale/ta.min.mjs +1 -1
- package/dist/locale/ta.mjs +1 -1
- package/dist/locale/th.js +1 -1
- package/dist/locale/th.min.js +1 -1
- package/dist/locale/th.min.mjs +1 -1
- package/dist/locale/th.mjs +1 -1
- package/dist/locale/tk.js +1 -1
- package/dist/locale/tk.min.js +1 -1
- package/dist/locale/tk.min.mjs +1 -1
- package/dist/locale/tk.mjs +1 -1
- package/dist/locale/tr.js +1 -1
- package/dist/locale/tr.min.js +1 -1
- package/dist/locale/tr.min.mjs +1 -1
- package/dist/locale/tr.mjs +1 -1
- package/dist/locale/ug-cn.js +1 -1
- package/dist/locale/ug-cn.min.js +1 -1
- package/dist/locale/ug-cn.min.mjs +1 -1
- package/dist/locale/ug-cn.mjs +1 -1
- package/dist/locale/uk.js +1 -1
- package/dist/locale/uk.min.js +1 -1
- package/dist/locale/uk.min.mjs +1 -1
- package/dist/locale/uk.mjs +1 -1
- package/dist/locale/uz-uz.js +1 -1
- package/dist/locale/uz-uz.min.js +1 -1
- package/dist/locale/uz-uz.min.mjs +1 -1
- package/dist/locale/uz-uz.mjs +1 -1
- package/dist/locale/vi.js +1 -1
- package/dist/locale/vi.min.js +1 -1
- package/dist/locale/vi.min.mjs +1 -1
- package/dist/locale/vi.mjs +1 -1
- package/dist/locale/zh-cn.js +1 -1
- package/dist/locale/zh-cn.min.js +1 -1
- package/dist/locale/zh-cn.min.mjs +1 -1
- package/dist/locale/zh-cn.mjs +1 -1
- package/dist/locale/zh-tw.js +1 -1
- package/dist/locale/zh-tw.min.js +1 -1
- package/dist/locale/zh-tw.min.mjs +1 -1
- package/dist/locale/zh-tw.mjs +1 -1
- package/es/components/affix/index.mjs +2 -2
- package/es/components/affix/src/affix.mjs +114 -26
- package/es/components/affix/src/affix.mjs.map +1 -1
- package/es/components/affix/src/affix2.mjs +26 -114
- package/es/components/affix/src/affix2.mjs.map +1 -1
- package/es/components/index.mjs +1 -1
- package/es/index.mjs +1 -1
- package/es/version.d.ts +1 -1
- package/es/version.mjs +1 -1
- package/es/version.mjs.map +1 -1
- package/lib/components/affix/index.js +2 -2
- package/lib/components/affix/src/affix.js +114 -27
- package/lib/components/affix/src/affix.js.map +1 -1
- package/lib/components/affix/src/affix2.js +27 -114
- package/lib/components/affix/src/affix2.js.map +1 -1
- package/lib/components/index.js +1 -1
- package/lib/index.js +1 -1
- package/lib/version.d.ts +1 -1
- package/lib/version.js +1 -1
- package/lib/version.js.map +1 -1
- package/package.json +2 -2
- package/web-types.json +1 -1
|
@@ -1,32 +1,120 @@
|
|
|
1
|
+
import { defineComponent, shallowRef, ref, computed, watch, onMounted, watchEffect, openBlock, createElementBlock, normalizeClass, unref, normalizeStyle, createElementVNode, renderSlot } from 'vue';
|
|
2
|
+
import { useWindowSize, useElementBounding, useEventListener } from '@vueuse/core';
|
|
1
3
|
import '../../../utils/index.mjs';
|
|
2
|
-
import '../../../
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
4
|
+
import '../../../hooks/index.mjs';
|
|
5
|
+
import { affixProps, affixEmits } from './affix2.mjs';
|
|
6
|
+
import _export_sfc from '../../../_virtual/plugin-vue_export-helper.mjs';
|
|
7
|
+
import { useNamespace } from '../../../hooks/use-namespace/index.mjs';
|
|
8
|
+
import { throwError } from '../../../utils/error.mjs';
|
|
9
|
+
import { getScrollContainer } from '../../../utils/dom/scroll.mjs';
|
|
6
10
|
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
11
|
+
const __default__ = {
|
|
12
|
+
name: "ElAffix"
|
|
13
|
+
};
|
|
14
|
+
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
15
|
+
...__default__,
|
|
16
|
+
props: affixProps,
|
|
17
|
+
emits: affixEmits,
|
|
18
|
+
setup(__props, { expose, emit }) {
|
|
19
|
+
const props = __props;
|
|
20
|
+
const COMPONENT_NAME = "ElAffix";
|
|
21
|
+
const ns = useNamespace("affix");
|
|
22
|
+
const target = shallowRef();
|
|
23
|
+
const root = shallowRef();
|
|
24
|
+
const scrollContainer = shallowRef();
|
|
25
|
+
const { height: windowHeight } = useWindowSize();
|
|
26
|
+
const {
|
|
27
|
+
height: rootHeight,
|
|
28
|
+
width: rootWidth,
|
|
29
|
+
top: rootTop,
|
|
30
|
+
bottom: rootBottom,
|
|
31
|
+
update: updateRoot
|
|
32
|
+
} = useElementBounding(root);
|
|
33
|
+
const targetRect = useElementBounding(target);
|
|
34
|
+
const fixed = ref(false);
|
|
35
|
+
const scrollTop = ref(0);
|
|
36
|
+
const transform = ref(0);
|
|
37
|
+
const rootStyle = computed(() => {
|
|
38
|
+
return {
|
|
39
|
+
height: fixed.value ? `${rootHeight.value}px` : "",
|
|
40
|
+
width: fixed.value ? `${rootWidth.value}px` : ""
|
|
41
|
+
};
|
|
42
|
+
});
|
|
43
|
+
const affixStyle = computed(() => {
|
|
44
|
+
if (!fixed.value)
|
|
45
|
+
return {};
|
|
46
|
+
const offset = props.offset ? `${props.offset}px` : 0;
|
|
47
|
+
return {
|
|
48
|
+
height: `${rootHeight.value}px`,
|
|
49
|
+
width: `${rootWidth.value}px`,
|
|
50
|
+
top: props.position === "top" ? offset : "",
|
|
51
|
+
bottom: props.position === "bottom" ? offset : "",
|
|
52
|
+
transform: transform.value ? `translateY(${transform.value}px)` : "",
|
|
53
|
+
zIndex: props.zIndex
|
|
54
|
+
};
|
|
55
|
+
});
|
|
56
|
+
const update = () => {
|
|
57
|
+
if (!scrollContainer.value)
|
|
58
|
+
return;
|
|
59
|
+
scrollTop.value = scrollContainer.value instanceof Window ? document.documentElement.scrollTop : scrollContainer.value.scrollTop || 0;
|
|
60
|
+
if (props.position === "top") {
|
|
61
|
+
if (props.target) {
|
|
62
|
+
const difference = targetRect.bottom.value - props.offset - rootHeight.value;
|
|
63
|
+
fixed.value = props.offset > rootTop.value && targetRect.bottom.value > 0;
|
|
64
|
+
transform.value = difference < 0 ? difference : 0;
|
|
65
|
+
} else {
|
|
66
|
+
fixed.value = props.offset > rootTop.value;
|
|
67
|
+
}
|
|
68
|
+
} else if (props.target) {
|
|
69
|
+
const difference = windowHeight.value - targetRect.top.value - props.offset - rootHeight.value;
|
|
70
|
+
fixed.value = windowHeight.value - props.offset < rootBottom.value && windowHeight.value > targetRect.top.value;
|
|
71
|
+
transform.value = difference < 0 ? -difference : 0;
|
|
72
|
+
} else {
|
|
73
|
+
fixed.value = windowHeight.value - props.offset < rootBottom.value;
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
const handleScroll = () => {
|
|
77
|
+
emit("scroll", {
|
|
78
|
+
scrollTop: scrollTop.value,
|
|
79
|
+
fixed: fixed.value
|
|
80
|
+
});
|
|
81
|
+
};
|
|
82
|
+
watch(fixed, (val) => emit("change", val));
|
|
83
|
+
onMounted(() => {
|
|
84
|
+
var _a;
|
|
85
|
+
if (props.target) {
|
|
86
|
+
target.value = (_a = document.querySelector(props.target)) != null ? _a : void 0;
|
|
87
|
+
if (!target.value)
|
|
88
|
+
throwError(COMPONENT_NAME, `Target is not existed: ${props.target}`);
|
|
89
|
+
} else {
|
|
90
|
+
target.value = document.documentElement;
|
|
91
|
+
}
|
|
92
|
+
scrollContainer.value = getScrollContainer(root.value, true);
|
|
93
|
+
updateRoot();
|
|
94
|
+
});
|
|
95
|
+
useEventListener(scrollContainer, "scroll", handleScroll);
|
|
96
|
+
watchEffect(update);
|
|
97
|
+
expose({
|
|
98
|
+
update
|
|
99
|
+
});
|
|
100
|
+
return (_ctx, _cache) => {
|
|
101
|
+
return openBlock(), createElementBlock("div", {
|
|
102
|
+
ref_key: "root",
|
|
103
|
+
ref: root,
|
|
104
|
+
class: normalizeClass(unref(ns).b()),
|
|
105
|
+
style: normalizeStyle(unref(rootStyle))
|
|
106
|
+
}, [
|
|
107
|
+
createElementVNode("div", {
|
|
108
|
+
class: normalizeClass({ [unref(ns).m("fixed")]: fixed.value }),
|
|
109
|
+
style: normalizeStyle(unref(affixStyle))
|
|
110
|
+
}, [
|
|
111
|
+
renderSlot(_ctx.$slots, "default")
|
|
112
|
+
], 6)
|
|
113
|
+
], 6);
|
|
114
|
+
};
|
|
24
115
|
}
|
|
25
116
|
});
|
|
26
|
-
|
|
27
|
-
scroll: ({ scrollTop, fixed }) => isNumber(scrollTop) && isBoolean(fixed),
|
|
28
|
-
[CHANGE_EVENT]: (fixed) => isBoolean(fixed)
|
|
29
|
-
};
|
|
117
|
+
var Affix = /* @__PURE__ */ _export_sfc(_sfc_main, [["__file", "/home/runner/work/element-plus/element-plus/packages/components/affix/src/affix.vue"]]);
|
|
30
118
|
|
|
31
|
-
export {
|
|
119
|
+
export { Affix as default };
|
|
32
120
|
//# sourceMappingURL=affix.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"affix.mjs","sources":["../../../../../../packages/components/affix/src/affix.
|
|
1
|
+
{"version":3,"file":"affix.mjs","sources":["../../../../../../packages/components/affix/src/affix.vue"],"sourcesContent":["<template>\n <div ref=\"root\" :class=\"ns.b()\" :style=\"rootStyle\">\n <div :class=\"{ [ns.m('fixed')]: fixed }\" :style=\"affixStyle\">\n <slot />\n </div>\n </div>\n</template>\n\n<script lang=\"ts\" setup>\nimport { computed, onMounted, ref, shallowRef, watch, watchEffect } from 'vue'\nimport {\n useElementBounding,\n useEventListener,\n useWindowSize,\n} from '@vueuse/core'\nimport { getScrollContainer, throwError } from '@element-plus/utils'\nimport { useNamespace } from '@element-plus/hooks'\nimport { affixEmits, affixProps } from './affix'\nimport type { CSSProperties } from 'vue'\n\nconst COMPONENT_NAME = 'ElAffix'\ndefineOptions({\n name: 'ElAffix',\n})\n\nconst props = defineProps(affixProps)\nconst emit = defineEmits(affixEmits)\n\nconst ns = useNamespace('affix')\n\nconst target = shallowRef<HTMLElement>()\nconst root = shallowRef<HTMLDivElement>()\nconst scrollContainer = shallowRef<HTMLElement | Window>()\nconst { height: windowHeight } = useWindowSize()\nconst {\n height: rootHeight,\n width: rootWidth,\n top: rootTop,\n bottom: rootBottom,\n update: updateRoot,\n} = useElementBounding(root)\nconst targetRect = useElementBounding(target)\n\nconst fixed = ref(false)\nconst scrollTop = ref(0)\nconst transform = ref(0)\n\nconst rootStyle = computed<CSSProperties>(() => {\n return {\n height: fixed.value ? `${rootHeight.value}px` : '',\n width: fixed.value ? `${rootWidth.value}px` : '',\n }\n})\n\nconst affixStyle = computed<CSSProperties>(() => {\n if (!fixed.value) return {}\n\n const offset = props.offset ? `${props.offset}px` : 0\n return {\n height: `${rootHeight.value}px`,\n width: `${rootWidth.value}px`,\n top: props.position === 'top' ? offset : '',\n bottom: props.position === 'bottom' ? offset : '',\n transform: transform.value ? `translateY(${transform.value}px)` : '',\n zIndex: props.zIndex,\n }\n})\n\nconst update = () => {\n if (!scrollContainer.value) return\n\n scrollTop.value =\n scrollContainer.value instanceof Window\n ? document.documentElement.scrollTop\n : scrollContainer.value.scrollTop || 0\n\n if (props.position === 'top') {\n if (props.target) {\n const difference =\n targetRect.bottom.value - props.offset - rootHeight.value\n fixed.value = props.offset > rootTop.value && targetRect.bottom.value > 0\n transform.value = difference < 0 ? difference : 0\n } else {\n fixed.value = props.offset > rootTop.value\n }\n } else if (props.target) {\n const difference =\n windowHeight.value -\n targetRect.top.value -\n props.offset -\n rootHeight.value\n fixed.value =\n windowHeight.value - props.offset < rootBottom.value &&\n windowHeight.value > targetRect.top.value\n transform.value = difference < 0 ? -difference : 0\n } else {\n fixed.value = windowHeight.value - props.offset < rootBottom.value\n }\n}\n\nconst handleScroll = () => {\n emit('scroll', {\n scrollTop: scrollTop.value,\n fixed: fixed.value,\n })\n}\n\nwatch(fixed, (val) => emit('change', val))\n\nonMounted(() => {\n if (props.target) {\n target.value =\n document.querySelector<HTMLElement>(props.target) ?? undefined\n if (!target.value)\n throwError(COMPONENT_NAME, `Target is not existed: ${props.target}`)\n } else {\n target.value = document.documentElement\n }\n scrollContainer.value = getScrollContainer(root.value!, true)\n updateRoot()\n})\n\nuseEventListener(scrollContainer, 'scroll', handleScroll)\nwatchEffect(update)\n\ndefineExpose({\n /** @description update affix status */\n update,\n})\n</script>\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;AAoBA,IAAA,MAAA,cAAA,GAAA,SAAA,CAAA;AAQA,IAAA,MAAA,EAAA,GAAA,aAAA,OAAA,CAAA,CAAA;AAEA,IAAA,MAAA,SAAA,UAAA,EAAA,CAAA;AACA,IAAA,MAAA,OAAA,UAAA,EAAA,CAAA;AACA,IAAA,MAAA,kBAAA,UAAA,EAAA,CAAA;AACA,IAAA,MAAA,EAAA,MAAA,EAAA,YAAA,EAAA,GAAA,aAAA,EAAA,CAAA;AACA,IAAA,MAAA;AAAA,MACA,MAAA,EAAA,UAAA;AAAA,MACA,KAAA,EAAA,SAAA;AAAA,MACA,GAAA,EAAA,OAAA;AAAA,MACA,MAAA,EAAA,UAAA;AAAA,MACA,MAAA,EAAA,UAAA;AAAA,KAAA,GACA,mBAAA,IAAA,CAAA,CAAA;AACA,IAAA,MAAA,UAAA,GAAA,mBAAA,MAAA,CAAA,CAAA;AAEA,IAAA,MAAA,KAAA,GAAA,IAAA,KAAA,CAAA,CAAA;AACA,IAAA,MAAA,SAAA,GAAA,IAAA,CAAA,CAAA,CAAA;AACA,IAAA,MAAA,SAAA,GAAA,IAAA,CAAA,CAAA,CAAA;AAEA,IAAA,MAAA,SAAA,GAAA,SAAA,MAAA;AACA,MAAA,OAAA;AAAA,QACA,MAAA,EAAA,KAAA,CAAA,KAAA,GAAA,CAAA,EAAA,WAAA,KAAA,CAAA,EAAA,CAAA,GAAA,EAAA;AAAA,QACA,KAAA,EAAA,KAAA,CAAA,KAAA,GAAA,CAAA,EAAA,UAAA,KAAA,CAAA,EAAA,CAAA,GAAA,EAAA;AAAA,OACA,CAAA;AAAA,KACA,CA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,EAAA,GAAA,KAAA,CAAA,CAAA;AACA,QAAA,IAAA,CAAA,MAAA,CAAA,KAAA;AAAA,UACA,UAAA,CAAA,cAAA,EAAA,CAAA,uBAAA,EAAA,KAAA,CAAA,MAAA,CAAA,CAAA,CAAA,CAAA;AACA,OAAA,MAAA;AAAA,QACA,MAAA,CAAA,KAAA,GAAA,QAAA,CAAA,eAAA,CAAA;AACA,OAAA;AACA,MAAA,eAAA,CAAA,KAAA,GAAA,kBAAA,CAAA,IAAA,CAAA,KAAA,EAAA,IAAA,CAAA,CAAA;AAAA,MACA,UAAA,EAAA,CAAA;AAEA,KAAA,CAAA,CAAA;AACA,IAAA,gBAAA,CAAA,eAAA,EAAA,QAAA,EAAA,YAAA,CAAA,CAAA;AAEA,IAAA,WAAA,CAAA,MAAA,CAAA,CAAA;AAAA,IAEA,MAAA,CAAA;AAAA,MACA,MAAA;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1,120 +1,32 @@
|
|
|
1
|
-
import { defineComponent, shallowRef, ref, computed, watch, onMounted, watchEffect, openBlock, createElementBlock, normalizeClass, unref, normalizeStyle, createElementVNode, renderSlot } from 'vue';
|
|
2
|
-
import { useWindowSize, useElementBounding, useEventListener } from '@vueuse/core';
|
|
3
1
|
import '../../../utils/index.mjs';
|
|
4
|
-
import '../../../
|
|
5
|
-
import {
|
|
6
|
-
import
|
|
7
|
-
import {
|
|
8
|
-
import { throwError } from '../../../utils/error.mjs';
|
|
9
|
-
import { getScrollContainer } from '../../../utils/dom/scroll.mjs';
|
|
2
|
+
import '../../../constants/index.mjs';
|
|
3
|
+
import { buildProps, definePropType } from '../../../utils/vue/props/runtime.mjs';
|
|
4
|
+
import { isNumber, isBoolean } from '@vueuse/core';
|
|
5
|
+
import { CHANGE_EVENT } from '../../../constants/event.mjs';
|
|
10
6
|
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
width: rootWidth,
|
|
29
|
-
top: rootTop,
|
|
30
|
-
bottom: rootBottom,
|
|
31
|
-
update: updateRoot
|
|
32
|
-
} = useElementBounding(root);
|
|
33
|
-
const targetRect = useElementBounding(target);
|
|
34
|
-
const fixed = ref(false);
|
|
35
|
-
const scrollTop = ref(0);
|
|
36
|
-
const transform = ref(0);
|
|
37
|
-
const rootStyle = computed(() => {
|
|
38
|
-
return {
|
|
39
|
-
height: fixed.value ? `${rootHeight.value}px` : "",
|
|
40
|
-
width: fixed.value ? `${rootWidth.value}px` : ""
|
|
41
|
-
};
|
|
42
|
-
});
|
|
43
|
-
const affixStyle = computed(() => {
|
|
44
|
-
if (!fixed.value)
|
|
45
|
-
return {};
|
|
46
|
-
const offset = props.offset ? `${props.offset}px` : 0;
|
|
47
|
-
return {
|
|
48
|
-
height: `${rootHeight.value}px`,
|
|
49
|
-
width: `${rootWidth.value}px`,
|
|
50
|
-
top: props.position === "top" ? offset : "",
|
|
51
|
-
bottom: props.position === "bottom" ? offset : "",
|
|
52
|
-
transform: transform.value ? `translateY(${transform.value}px)` : "",
|
|
53
|
-
zIndex: props.zIndex
|
|
54
|
-
};
|
|
55
|
-
});
|
|
56
|
-
const update = () => {
|
|
57
|
-
if (!scrollContainer.value)
|
|
58
|
-
return;
|
|
59
|
-
scrollTop.value = scrollContainer.value instanceof Window ? document.documentElement.scrollTop : scrollContainer.value.scrollTop || 0;
|
|
60
|
-
if (props.position === "top") {
|
|
61
|
-
if (props.target) {
|
|
62
|
-
const difference = targetRect.bottom.value - props.offset - rootHeight.value;
|
|
63
|
-
fixed.value = props.offset > rootTop.value && targetRect.bottom.value > 0;
|
|
64
|
-
transform.value = difference < 0 ? difference : 0;
|
|
65
|
-
} else {
|
|
66
|
-
fixed.value = props.offset > rootTop.value;
|
|
67
|
-
}
|
|
68
|
-
} else if (props.target) {
|
|
69
|
-
const difference = windowHeight.value - targetRect.top.value - props.offset - rootHeight.value;
|
|
70
|
-
fixed.value = windowHeight.value - props.offset < rootBottom.value && windowHeight.value > targetRect.top.value;
|
|
71
|
-
transform.value = difference < 0 ? -difference : 0;
|
|
72
|
-
} else {
|
|
73
|
-
fixed.value = windowHeight.value - props.offset < rootBottom.value;
|
|
74
|
-
}
|
|
75
|
-
};
|
|
76
|
-
const handleScroll = () => {
|
|
77
|
-
emit("scroll", {
|
|
78
|
-
scrollTop: scrollTop.value,
|
|
79
|
-
fixed: fixed.value
|
|
80
|
-
});
|
|
81
|
-
};
|
|
82
|
-
watch(fixed, (val) => emit("change", val));
|
|
83
|
-
onMounted(() => {
|
|
84
|
-
var _a;
|
|
85
|
-
if (props.target) {
|
|
86
|
-
target.value = (_a = document.querySelector(props.target)) != null ? _a : void 0;
|
|
87
|
-
if (!target.value)
|
|
88
|
-
throwError(COMPONENT_NAME, `Target is not existed: ${props.target}`);
|
|
89
|
-
} else {
|
|
90
|
-
target.value = document.documentElement;
|
|
91
|
-
}
|
|
92
|
-
scrollContainer.value = getScrollContainer(root.value, true);
|
|
93
|
-
updateRoot();
|
|
94
|
-
});
|
|
95
|
-
useEventListener(scrollContainer, "scroll", handleScroll);
|
|
96
|
-
watchEffect(update);
|
|
97
|
-
expose({
|
|
98
|
-
update
|
|
99
|
-
});
|
|
100
|
-
return (_ctx, _cache) => {
|
|
101
|
-
return openBlock(), createElementBlock("div", {
|
|
102
|
-
ref_key: "root",
|
|
103
|
-
ref: root,
|
|
104
|
-
class: normalizeClass(unref(ns).b()),
|
|
105
|
-
style: normalizeStyle(unref(rootStyle))
|
|
106
|
-
}, [
|
|
107
|
-
createElementVNode("div", {
|
|
108
|
-
class: normalizeClass({ [unref(ns).m("fixed")]: fixed.value }),
|
|
109
|
-
style: normalizeStyle(unref(affixStyle))
|
|
110
|
-
}, [
|
|
111
|
-
renderSlot(_ctx.$slots, "default")
|
|
112
|
-
], 6)
|
|
113
|
-
], 6);
|
|
114
|
-
};
|
|
7
|
+
const affixProps = buildProps({
|
|
8
|
+
zIndex: {
|
|
9
|
+
type: definePropType([Number, String]),
|
|
10
|
+
default: 100
|
|
11
|
+
},
|
|
12
|
+
target: {
|
|
13
|
+
type: String,
|
|
14
|
+
default: ""
|
|
15
|
+
},
|
|
16
|
+
offset: {
|
|
17
|
+
type: Number,
|
|
18
|
+
default: 0
|
|
19
|
+
},
|
|
20
|
+
position: {
|
|
21
|
+
type: String,
|
|
22
|
+
values: ["top", "bottom"],
|
|
23
|
+
default: "top"
|
|
115
24
|
}
|
|
116
25
|
});
|
|
117
|
-
|
|
26
|
+
const affixEmits = {
|
|
27
|
+
scroll: ({ scrollTop, fixed }) => isNumber(scrollTop) && isBoolean(fixed),
|
|
28
|
+
[CHANGE_EVENT]: (fixed) => isBoolean(fixed)
|
|
29
|
+
};
|
|
118
30
|
|
|
119
|
-
export {
|
|
31
|
+
export { affixEmits, affixProps };
|
|
120
32
|
//# sourceMappingURL=affix2.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"affix2.mjs","sources":["../../../../../../packages/components/affix/src/affix.
|
|
1
|
+
{"version":3,"file":"affix2.mjs","sources":["../../../../../../packages/components/affix/src/affix.ts"],"sourcesContent":["import {\n buildProps,\n definePropType,\n isBoolean,\n isNumber,\n} from '@element-plus/utils'\nimport { CHANGE_EVENT } from '@element-plus/constants'\nimport type { ExtractPropTypes } from 'vue'\nimport type { ZIndexProperty } from 'csstype'\nimport type Affix from './affix.vue'\n\nexport const affixProps = buildProps({\n zIndex: {\n type: definePropType<ZIndexProperty>([Number, String]),\n default: 100,\n },\n target: {\n type: String,\n default: '',\n },\n offset: {\n type: Number,\n default: 0,\n },\n position: {\n type: String,\n values: ['top', 'bottom'],\n default: 'top',\n },\n} as const)\nexport type AffixProps = ExtractPropTypes<typeof affixProps>\n\nexport const affixEmits = {\n scroll: ({ scrollTop, fixed }: { scrollTop: number; fixed: boolean }) =>\n isNumber(scrollTop) && isBoolean(fixed),\n [CHANGE_EVENT]: (fixed: boolean) => isBoolean(fixed),\n}\nexport type AffixEmits = typeof affixEmits\n\nexport type AffixInstance = InstanceType<typeof Affix>\n"],"names":[],"mappings":";;;;;;AAOY,MAAC,UAAU,GAAG,UAAU,CAAC;AACrC,EAAE,MAAM,EAAE;AACV,IAAI,IAAI,EAAE,cAAc,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAC1C,IAAI,OAAO,EAAE,GAAG;AAChB,GAAG;AACH,EAAE,MAAM,EAAE;AACV,IAAI,IAAI,EAAE,MAAM;AAChB,IAAI,OAAO,EAAE,EAAE;AACf,GAAG;AACH,EAAE,MAAM,EAAE;AACV,IAAI,IAAI,EAAE,MAAM;AAChB,IAAI,OAAO,EAAE,CAAC;AACd,GAAG;AACH,EAAE,QAAQ,EAAE;AACZ,IAAI,IAAI,EAAE,MAAM;AAChB,IAAI,MAAM,EAAE,CAAC,KAAK,EAAE,QAAQ,CAAC;AAC7B,IAAI,OAAO,EAAE,KAAK;AAClB,GAAG;AACH,CAAC,EAAE;AACS,MAAC,UAAU,GAAG;AAC1B,EAAE,MAAM,EAAE,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,KAAK,QAAQ,CAAC,SAAS,CAAC,IAAI,SAAS,CAAC,KAAK,CAAC;AAC3E,EAAE,CAAC,YAAY,GAAG,CAAC,KAAK,KAAK,SAAS,CAAC,KAAK,CAAC;AAC7C;;;;"}
|
package/es/components/index.mjs
CHANGED
|
@@ -72,7 +72,7 @@ export { ElMessage } from './message/index.mjs';
|
|
|
72
72
|
export { ElMessageBox } from './message-box/index.mjs';
|
|
73
73
|
export { ElNotification } from './notification/index.mjs';
|
|
74
74
|
export { ElPopover, ElPopoverDirective } from './popover/index.mjs';
|
|
75
|
-
export { affixEmits, affixProps } from './affix/src/
|
|
75
|
+
export { affixEmits, affixProps } from './affix/src/affix2.mjs';
|
|
76
76
|
export { alertEffects, alertEmits, alertProps } from './alert/src/alert.mjs';
|
|
77
77
|
export { autocompleteEmits, autocompleteProps } from './autocomplete/src/autocomplete.mjs';
|
|
78
78
|
export { avatarEmits, avatarProps } from './avatar/src/avatar.mjs';
|
package/es/index.mjs
CHANGED
|
@@ -7,7 +7,7 @@ import './hooks/index.mjs';
|
|
|
7
7
|
import './tokens/index.mjs';
|
|
8
8
|
export { makeInstaller } from './make-installer.mjs';
|
|
9
9
|
export { default as dayjs } from 'dayjs';
|
|
10
|
-
export { affixEmits, affixProps } from './components/affix/src/
|
|
10
|
+
export { affixEmits, affixProps } from './components/affix/src/affix2.mjs';
|
|
11
11
|
export { ElAffix } from './components/affix/index.mjs';
|
|
12
12
|
export { alertEffects, alertEmits, alertProps } from './components/alert/src/alert.mjs';
|
|
13
13
|
export { ElAlert } from './components/alert/index.mjs';
|
package/es/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "0.0.
|
|
1
|
+
export declare const version = "0.0.20220801";
|
package/es/version.mjs
CHANGED
package/es/version.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.mjs","sources":["../../../packages/element-plus/version.ts"],"sourcesContent":["export const version = '0.0.
|
|
1
|
+
{"version":3,"file":"version.mjs","sources":["../../../packages/element-plus/version.ts"],"sourcesContent":["export const version = '0.0.20220801'\n"],"names":[],"mappings":"AAAY,MAAC,OAAO,GAAG;;;;"}
|
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
require('../../utils/index.js');
|
|
6
|
-
var affix$1 = require('./src/
|
|
7
|
-
var affix = require('./src/
|
|
6
|
+
var affix$1 = require('./src/affix.js');
|
|
7
|
+
var affix = require('./src/affix2.js');
|
|
8
8
|
var install = require('../../utils/vue/install.js');
|
|
9
9
|
|
|
10
10
|
const ElAffix = install.withInstall(affix$1["default"]);
|
|
@@ -2,36 +2,123 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
require('
|
|
6
|
-
require('../../../constants/index.js');
|
|
7
|
-
var runtime = require('../../../utils/vue/props/runtime.js');
|
|
5
|
+
var vue = require('vue');
|
|
8
6
|
var core = require('@vueuse/core');
|
|
9
|
-
|
|
7
|
+
require('../../../utils/index.js');
|
|
8
|
+
require('../../../hooks/index.js');
|
|
9
|
+
var affix = require('./affix2.js');
|
|
10
|
+
var pluginVue_exportHelper = require('../../../_virtual/plugin-vue_export-helper.js');
|
|
11
|
+
var index = require('../../../hooks/use-namespace/index.js');
|
|
12
|
+
var error = require('../../../utils/error.js');
|
|
13
|
+
var scroll = require('../../../utils/dom/scroll.js');
|
|
10
14
|
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
15
|
+
const __default__ = {
|
|
16
|
+
name: "ElAffix"
|
|
17
|
+
};
|
|
18
|
+
const _sfc_main = /* @__PURE__ */ vue.defineComponent({
|
|
19
|
+
...__default__,
|
|
20
|
+
props: affix.affixProps,
|
|
21
|
+
emits: affix.affixEmits,
|
|
22
|
+
setup(__props, { expose, emit }) {
|
|
23
|
+
const props = __props;
|
|
24
|
+
const COMPONENT_NAME = "ElAffix";
|
|
25
|
+
const ns = index.useNamespace("affix");
|
|
26
|
+
const target = vue.shallowRef();
|
|
27
|
+
const root = vue.shallowRef();
|
|
28
|
+
const scrollContainer = vue.shallowRef();
|
|
29
|
+
const { height: windowHeight } = core.useWindowSize();
|
|
30
|
+
const {
|
|
31
|
+
height: rootHeight,
|
|
32
|
+
width: rootWidth,
|
|
33
|
+
top: rootTop,
|
|
34
|
+
bottom: rootBottom,
|
|
35
|
+
update: updateRoot
|
|
36
|
+
} = core.useElementBounding(root);
|
|
37
|
+
const targetRect = core.useElementBounding(target);
|
|
38
|
+
const fixed = vue.ref(false);
|
|
39
|
+
const scrollTop = vue.ref(0);
|
|
40
|
+
const transform = vue.ref(0);
|
|
41
|
+
const rootStyle = vue.computed(() => {
|
|
42
|
+
return {
|
|
43
|
+
height: fixed.value ? `${rootHeight.value}px` : "",
|
|
44
|
+
width: fixed.value ? `${rootWidth.value}px` : ""
|
|
45
|
+
};
|
|
46
|
+
});
|
|
47
|
+
const affixStyle = vue.computed(() => {
|
|
48
|
+
if (!fixed.value)
|
|
49
|
+
return {};
|
|
50
|
+
const offset = props.offset ? `${props.offset}px` : 0;
|
|
51
|
+
return {
|
|
52
|
+
height: `${rootHeight.value}px`,
|
|
53
|
+
width: `${rootWidth.value}px`,
|
|
54
|
+
top: props.position === "top" ? offset : "",
|
|
55
|
+
bottom: props.position === "bottom" ? offset : "",
|
|
56
|
+
transform: transform.value ? `translateY(${transform.value}px)` : "",
|
|
57
|
+
zIndex: props.zIndex
|
|
58
|
+
};
|
|
59
|
+
});
|
|
60
|
+
const update = () => {
|
|
61
|
+
if (!scrollContainer.value)
|
|
62
|
+
return;
|
|
63
|
+
scrollTop.value = scrollContainer.value instanceof Window ? document.documentElement.scrollTop : scrollContainer.value.scrollTop || 0;
|
|
64
|
+
if (props.position === "top") {
|
|
65
|
+
if (props.target) {
|
|
66
|
+
const difference = targetRect.bottom.value - props.offset - rootHeight.value;
|
|
67
|
+
fixed.value = props.offset > rootTop.value && targetRect.bottom.value > 0;
|
|
68
|
+
transform.value = difference < 0 ? difference : 0;
|
|
69
|
+
} else {
|
|
70
|
+
fixed.value = props.offset > rootTop.value;
|
|
71
|
+
}
|
|
72
|
+
} else if (props.target) {
|
|
73
|
+
const difference = windowHeight.value - targetRect.top.value - props.offset - rootHeight.value;
|
|
74
|
+
fixed.value = windowHeight.value - props.offset < rootBottom.value && windowHeight.value > targetRect.top.value;
|
|
75
|
+
transform.value = difference < 0 ? -difference : 0;
|
|
76
|
+
} else {
|
|
77
|
+
fixed.value = windowHeight.value - props.offset < rootBottom.value;
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
const handleScroll = () => {
|
|
81
|
+
emit("scroll", {
|
|
82
|
+
scrollTop: scrollTop.value,
|
|
83
|
+
fixed: fixed.value
|
|
84
|
+
});
|
|
85
|
+
};
|
|
86
|
+
vue.watch(fixed, (val) => emit("change", val));
|
|
87
|
+
vue.onMounted(() => {
|
|
88
|
+
var _a;
|
|
89
|
+
if (props.target) {
|
|
90
|
+
target.value = (_a = document.querySelector(props.target)) != null ? _a : void 0;
|
|
91
|
+
if (!target.value)
|
|
92
|
+
error.throwError(COMPONENT_NAME, `Target is not existed: ${props.target}`);
|
|
93
|
+
} else {
|
|
94
|
+
target.value = document.documentElement;
|
|
95
|
+
}
|
|
96
|
+
scrollContainer.value = scroll.getScrollContainer(root.value, true);
|
|
97
|
+
updateRoot();
|
|
98
|
+
});
|
|
99
|
+
core.useEventListener(scrollContainer, "scroll", handleScroll);
|
|
100
|
+
vue.watchEffect(update);
|
|
101
|
+
expose({
|
|
102
|
+
update
|
|
103
|
+
});
|
|
104
|
+
return (_ctx, _cache) => {
|
|
105
|
+
return vue.openBlock(), vue.createElementBlock("div", {
|
|
106
|
+
ref_key: "root",
|
|
107
|
+
ref: root,
|
|
108
|
+
class: vue.normalizeClass(vue.unref(ns).b()),
|
|
109
|
+
style: vue.normalizeStyle(vue.unref(rootStyle))
|
|
110
|
+
}, [
|
|
111
|
+
vue.createElementVNode("div", {
|
|
112
|
+
class: vue.normalizeClass({ [vue.unref(ns).m("fixed")]: fixed.value }),
|
|
113
|
+
style: vue.normalizeStyle(vue.unref(affixStyle))
|
|
114
|
+
}, [
|
|
115
|
+
vue.renderSlot(_ctx.$slots, "default")
|
|
116
|
+
], 6)
|
|
117
|
+
], 6);
|
|
118
|
+
};
|
|
28
119
|
}
|
|
29
120
|
});
|
|
30
|
-
|
|
31
|
-
scroll: ({ scrollTop, fixed }) => core.isNumber(scrollTop) && core.isBoolean(fixed),
|
|
32
|
-
[event.CHANGE_EVENT]: (fixed) => core.isBoolean(fixed)
|
|
33
|
-
};
|
|
121
|
+
var Affix = /* @__PURE__ */ pluginVue_exportHelper["default"](_sfc_main, [["__file", "/home/runner/work/element-plus/element-plus/packages/components/affix/src/affix.vue"]]);
|
|
34
122
|
|
|
35
|
-
exports
|
|
36
|
-
exports.affixProps = affixProps;
|
|
123
|
+
exports["default"] = Affix;
|
|
37
124
|
//# sourceMappingURL=affix.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"affix.js","sources":["../../../../../../packages/components/affix/src/affix.
|
|
1
|
+
{"version":3,"file":"affix.js","sources":["../../../../../../packages/components/affix/src/affix.vue"],"sourcesContent":["<template>\n <div ref=\"root\" :class=\"ns.b()\" :style=\"rootStyle\">\n <div :class=\"{ [ns.m('fixed')]: fixed }\" :style=\"affixStyle\">\n <slot />\n </div>\n </div>\n</template>\n\n<script lang=\"ts\" setup>\nimport { computed, onMounted, ref, shallowRef, watch, watchEffect } from 'vue'\nimport {\n useElementBounding,\n useEventListener,\n useWindowSize,\n} from '@vueuse/core'\nimport { getScrollContainer, throwError } from '@element-plus/utils'\nimport { useNamespace } from '@element-plus/hooks'\nimport { affixEmits, affixProps } from './affix'\nimport type { CSSProperties } from 'vue'\n\nconst COMPONENT_NAME = 'ElAffix'\ndefineOptions({\n name: 'ElAffix',\n})\n\nconst props = defineProps(affixProps)\nconst emit = defineEmits(affixEmits)\n\nconst ns = useNamespace('affix')\n\nconst target = shallowRef<HTMLElement>()\nconst root = shallowRef<HTMLDivElement>()\nconst scrollContainer = shallowRef<HTMLElement | Window>()\nconst { height: windowHeight } = useWindowSize()\nconst {\n height: rootHeight,\n width: rootWidth,\n top: rootTop,\n bottom: rootBottom,\n update: updateRoot,\n} = useElementBounding(root)\nconst targetRect = useElementBounding(target)\n\nconst fixed = ref(false)\nconst scrollTop = ref(0)\nconst transform = ref(0)\n\nconst rootStyle = computed<CSSProperties>(() => {\n return {\n height: fixed.value ? `${rootHeight.value}px` : '',\n width: fixed.value ? `${rootWidth.value}px` : '',\n }\n})\n\nconst affixStyle = computed<CSSProperties>(() => {\n if (!fixed.value) return {}\n\n const offset = props.offset ? `${props.offset}px` : 0\n return {\n height: `${rootHeight.value}px`,\n width: `${rootWidth.value}px`,\n top: props.position === 'top' ? offset : '',\n bottom: props.position === 'bottom' ? offset : '',\n transform: transform.value ? `translateY(${transform.value}px)` : '',\n zIndex: props.zIndex,\n }\n})\n\nconst update = () => {\n if (!scrollContainer.value) return\n\n scrollTop.value =\n scrollContainer.value instanceof Window\n ? document.documentElement.scrollTop\n : scrollContainer.value.scrollTop || 0\n\n if (props.position === 'top') {\n if (props.target) {\n const difference =\n targetRect.bottom.value - props.offset - rootHeight.value\n fixed.value = props.offset > rootTop.value && targetRect.bottom.value > 0\n transform.value = difference < 0 ? difference : 0\n } else {\n fixed.value = props.offset > rootTop.value\n }\n } else if (props.target) {\n const difference =\n windowHeight.value -\n targetRect.top.value -\n props.offset -\n rootHeight.value\n fixed.value =\n windowHeight.value - props.offset < rootBottom.value &&\n windowHeight.value > targetRect.top.value\n transform.value = difference < 0 ? -difference : 0\n } else {\n fixed.value = windowHeight.value - props.offset < rootBottom.value\n }\n}\n\nconst handleScroll = () => {\n emit('scroll', {\n scrollTop: scrollTop.value,\n fixed: fixed.value,\n })\n}\n\nwatch(fixed, (val) => emit('change', val))\n\nonMounted(() => {\n if (props.target) {\n target.value =\n document.querySelector<HTMLElement>(props.target) ?? undefined\n if (!target.value)\n throwError(COMPONENT_NAME, `Target is not existed: ${props.target}`)\n } else {\n target.value = document.documentElement\n }\n scrollContainer.value = getScrollContainer(root.value!, true)\n updateRoot()\n})\n\nuseEventListener(scrollContainer, 'scroll', handleScroll)\nwatchEffect(update)\n\ndefineExpose({\n /** @description update affix status */\n update,\n})\n</script>\n"],"names":["useNamespace","shallowRef","useWindowSize","useElementBounding","ref","computed","watch","onMounted","throwError","getScrollContainer","useEventListener","watchEffect"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAoBA,IAAA,MAAA,cAAA,GAAA,SAAA,CAAA;AAQA,IAAA,MAAA,EAAA,GAAAA,mBAAA,OAAA,CAAA,CAAA;AAEA,IAAA,MAAA,SAAAC,cAAA,EAAA,CAAA;AACA,IAAA,MAAA,OAAAA,cAAA,EAAA,CAAA;AACA,IAAA,MAAA,kBAAAA,cAAA,EAAA,CAAA;AACA,IAAA,MAAA,EAAA,MAAA,EAAA,YAAA,EAAA,GAAAC,kBAAA,EAAA,CAAA;AACA,IAAA,MAAA;AAAA,MACA,MAAA,EAAA,UAAA;AAAA,MACA,KAAA,EAAA,SAAA;AAAA,MACA,GAAA,EAAA,OAAA;AAAA,MACA,MAAA,EAAA,UAAA;AAAA,MACA,MAAA,EAAA,UAAA;AAAA,KAAA,GACAC,wBAAA,IAAA,CAAA,CAAA;AACA,IAAA,MAAA,UAAA,GAAAA,wBAAA,MAAA,CAAA,CAAA;AAEA,IAAA,MAAA,KAAA,GAAAC,QAAA,KAAA,CAAA,CAAA;AACA,IAAA,MAAA,SAAA,GAAAA,QAAA,CAAA,CAAA,CAAA;AACA,IAAA,MAAA,SAAA,GAAAA,QAAA,CAAA,CAAA,CAAA;AAEA,IAAA,MAAA,SAAA,GAAAC,aAAA,MAAA;AACA,MAAA,OAAA;AAAA,QACA,MAAA,EAAA,KAAA,CAAA,KAAA,GAAA,CAAA,EAAA,WAAA,KAAA,CAAA,EAAA,CAAA,GAAA,EAAA;AAAA,QACA,KAAA,EAAA,KAAA,CAAA,KAAA,GAAA,CAAA,EAAA,UAAA,KAAA,CAAA,EAAA,CAAA,GAAA,EAAA;AAAA,OACA,CAAA;AAAA,KACA,CAAA,CAAA;AAEA,IAAA,MAAA,UAAA,GAAAA,aAAA,MAAA;AACA,MAAA,IAAA,CAAA,KAAA,CAAA,KAAA;AAAA,QAAA,OAAA,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