first commit
This commit is contained in:
58
node_modules/vant/es/sticky/Sticky.d.ts
generated
vendored
Normal file
58
node_modules/vant/es/sticky/Sticky.d.ts
generated
vendored
Normal file
@@ -0,0 +1,58 @@
|
||||
import { type PropType, type ExtractPropTypes } from 'vue';
|
||||
export type StickyPosition = 'top' | 'bottom';
|
||||
export declare const stickyProps: {
|
||||
zIndex: (NumberConstructor | StringConstructor)[];
|
||||
position: {
|
||||
type: PropType<StickyPosition>;
|
||||
default: StickyPosition;
|
||||
};
|
||||
container: PropType<Element>;
|
||||
offsetTop: {
|
||||
type: (NumberConstructor | StringConstructor)[];
|
||||
default: number;
|
||||
};
|
||||
offsetBottom: {
|
||||
type: (NumberConstructor | StringConstructor)[];
|
||||
default: number;
|
||||
};
|
||||
};
|
||||
export type StickyProps = ExtractPropTypes<typeof stickyProps>;
|
||||
declare const _default: import("vue").DefineComponent<ExtractPropTypes<{
|
||||
zIndex: (NumberConstructor | StringConstructor)[];
|
||||
position: {
|
||||
type: PropType<StickyPosition>;
|
||||
default: StickyPosition;
|
||||
};
|
||||
container: PropType<Element>;
|
||||
offsetTop: {
|
||||
type: (NumberConstructor | StringConstructor)[];
|
||||
default: number;
|
||||
};
|
||||
offsetBottom: {
|
||||
type: (NumberConstructor | StringConstructor)[];
|
||||
default: number;
|
||||
};
|
||||
}>, () => import("vue/jsx-runtime").JSX.Element, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("scroll" | "change")[], "scroll" | "change", import("vue").PublicProps, Readonly<ExtractPropTypes<{
|
||||
zIndex: (NumberConstructor | StringConstructor)[];
|
||||
position: {
|
||||
type: PropType<StickyPosition>;
|
||||
default: StickyPosition;
|
||||
};
|
||||
container: PropType<Element>;
|
||||
offsetTop: {
|
||||
type: (NumberConstructor | StringConstructor)[];
|
||||
default: number;
|
||||
};
|
||||
offsetBottom: {
|
||||
type: (NumberConstructor | StringConstructor)[];
|
||||
default: number;
|
||||
};
|
||||
}>> & Readonly<{
|
||||
onChange?: ((...args: any[]) => any) | undefined;
|
||||
onScroll?: ((...args: any[]) => any) | undefined;
|
||||
}>, {
|
||||
position: StickyPosition;
|
||||
offsetTop: string | number;
|
||||
offsetBottom: string | number;
|
||||
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
||||
export default _default;
|
||||
138
node_modules/vant/es/sticky/Sticky.mjs
generated
vendored
Normal file
138
node_modules/vant/es/sticky/Sticky.mjs
generated
vendored
Normal file
@@ -0,0 +1,138 @@
|
||||
import { ref, watch, computed, nextTick, reactive, defineComponent, createVNode as _createVNode } from "vue";
|
||||
import { extend, isHidden, unitToPx, numericProp, windowWidth, windowHeight, getScrollTop, getZIndexStyle, makeStringProp, makeNumericProp, createNamespace } from "../utils/index.mjs";
|
||||
import { useRect, useEventListener, useScrollParent } from "@vant/use";
|
||||
import { useVisibilityChange } from "../composables/use-visibility-change.mjs";
|
||||
const [name, bem] = createNamespace("sticky");
|
||||
const stickyProps = {
|
||||
zIndex: numericProp,
|
||||
position: makeStringProp("top"),
|
||||
container: Object,
|
||||
offsetTop: makeNumericProp(0),
|
||||
offsetBottom: makeNumericProp(0)
|
||||
};
|
||||
var stdin_default = defineComponent({
|
||||
name,
|
||||
props: stickyProps,
|
||||
emits: ["scroll", "change"],
|
||||
setup(props, {
|
||||
emit,
|
||||
slots
|
||||
}) {
|
||||
const root = ref();
|
||||
const scrollParent = useScrollParent(root);
|
||||
const state = reactive({
|
||||
fixed: false,
|
||||
width: 0,
|
||||
// root width
|
||||
height: 0,
|
||||
// root height
|
||||
transform: 0
|
||||
});
|
||||
const isReset = ref(false);
|
||||
const offset = computed(() => unitToPx(props.position === "top" ? props.offsetTop : props.offsetBottom));
|
||||
const rootStyle = computed(() => {
|
||||
if (isReset.value) {
|
||||
return;
|
||||
}
|
||||
const {
|
||||
fixed,
|
||||
height,
|
||||
width
|
||||
} = state;
|
||||
if (fixed) {
|
||||
return {
|
||||
width: `${width}px`,
|
||||
height: `${height}px`
|
||||
};
|
||||
}
|
||||
});
|
||||
const stickyStyle = computed(() => {
|
||||
if (!state.fixed || isReset.value) {
|
||||
return;
|
||||
}
|
||||
const style = extend(getZIndexStyle(props.zIndex), {
|
||||
width: `${state.width}px`,
|
||||
height: `${state.height}px`,
|
||||
[props.position]: `${offset.value}px`
|
||||
});
|
||||
if (state.transform) {
|
||||
style.transform = `translate3d(0, ${state.transform}px, 0)`;
|
||||
}
|
||||
return style;
|
||||
});
|
||||
const emitScroll = (scrollTop) => emit("scroll", {
|
||||
scrollTop,
|
||||
isFixed: state.fixed
|
||||
});
|
||||
const onScroll = () => {
|
||||
if (!root.value || isHidden(root)) {
|
||||
return;
|
||||
}
|
||||
const {
|
||||
container,
|
||||
position
|
||||
} = props;
|
||||
const rootRect = useRect(root);
|
||||
const scrollTop = getScrollTop(window);
|
||||
state.width = rootRect.width;
|
||||
state.height = rootRect.height;
|
||||
if (position === "top") {
|
||||
if (container) {
|
||||
const containerRect = useRect(container);
|
||||
const difference = containerRect.bottom - offset.value - state.height;
|
||||
state.fixed = offset.value > rootRect.top && containerRect.bottom > 0;
|
||||
state.transform = difference < 0 ? difference : 0;
|
||||
} else {
|
||||
state.fixed = offset.value > rootRect.top;
|
||||
}
|
||||
} else {
|
||||
const {
|
||||
clientHeight
|
||||
} = document.documentElement;
|
||||
if (container) {
|
||||
const containerRect = useRect(container);
|
||||
const difference = clientHeight - containerRect.top - offset.value - state.height;
|
||||
state.fixed = clientHeight - offset.value < rootRect.bottom && clientHeight > containerRect.top;
|
||||
state.transform = difference < 0 ? -difference : 0;
|
||||
} else {
|
||||
state.fixed = clientHeight - offset.value < rootRect.bottom;
|
||||
}
|
||||
}
|
||||
emitScroll(scrollTop);
|
||||
};
|
||||
watch(() => state.fixed, (value) => emit("change", value));
|
||||
useEventListener("scroll", onScroll, {
|
||||
target: scrollParent,
|
||||
passive: true
|
||||
});
|
||||
useVisibilityChange(root, onScroll);
|
||||
watch([windowWidth, windowHeight], () => {
|
||||
if (!root.value || isHidden(root) || !state.fixed) {
|
||||
return;
|
||||
}
|
||||
isReset.value = true;
|
||||
nextTick(() => {
|
||||
const rootRect = useRect(root);
|
||||
state.width = rootRect.width;
|
||||
state.height = rootRect.height;
|
||||
isReset.value = false;
|
||||
});
|
||||
});
|
||||
return () => {
|
||||
var _a;
|
||||
return _createVNode("div", {
|
||||
"ref": root,
|
||||
"style": rootStyle.value
|
||||
}, [_createVNode("div", {
|
||||
"class": bem({
|
||||
fixed: state.fixed && !isReset.value
|
||||
}),
|
||||
"style": stickyStyle.value
|
||||
}, [(_a = slots.default) == null ? void 0 : _a.call(slots)])]);
|
||||
};
|
||||
}
|
||||
});
|
||||
export {
|
||||
stdin_default as default,
|
||||
stickyProps
|
||||
};
|
||||
1
node_modules/vant/es/sticky/index.css
generated
vendored
Normal file
1
node_modules/vant/es/sticky/index.css
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
:root,:host{--van-sticky-z-index: 99}.van-sticky--fixed{position:fixed;z-index:var(--van-sticky-z-index)}
|
||||
47
node_modules/vant/es/sticky/index.d.ts
generated
vendored
Normal file
47
node_modules/vant/es/sticky/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,47 @@
|
||||
export declare const Sticky: import("../utils").WithInstall<import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
||||
zIndex: (NumberConstructor | StringConstructor)[];
|
||||
position: {
|
||||
type: import("vue").PropType<import("./Sticky").StickyPosition>;
|
||||
default: import("./Sticky").StickyPosition;
|
||||
};
|
||||
container: import("vue").PropType<Element>;
|
||||
offsetTop: {
|
||||
type: (NumberConstructor | StringConstructor)[];
|
||||
default: number;
|
||||
};
|
||||
offsetBottom: {
|
||||
type: (NumberConstructor | StringConstructor)[];
|
||||
default: number;
|
||||
};
|
||||
}>, () => import("vue/jsx-runtime").JSX.Element, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("scroll" | "change")[], "scroll" | "change", import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
||||
zIndex: (NumberConstructor | StringConstructor)[];
|
||||
position: {
|
||||
type: import("vue").PropType<import("./Sticky").StickyPosition>;
|
||||
default: import("./Sticky").StickyPosition;
|
||||
};
|
||||
container: import("vue").PropType<Element>;
|
||||
offsetTop: {
|
||||
type: (NumberConstructor | StringConstructor)[];
|
||||
default: number;
|
||||
};
|
||||
offsetBottom: {
|
||||
type: (NumberConstructor | StringConstructor)[];
|
||||
default: number;
|
||||
};
|
||||
}>> & Readonly<{
|
||||
onChange?: ((...args: any[]) => any) | undefined;
|
||||
onScroll?: ((...args: any[]) => any) | undefined;
|
||||
}>, {
|
||||
position: import("./Sticky").StickyPosition;
|
||||
offsetTop: string | number;
|
||||
offsetBottom: string | number;
|
||||
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>>;
|
||||
export default Sticky;
|
||||
export { stickyProps } from './Sticky';
|
||||
export type { StickyProps, StickyPosition } from './Sticky';
|
||||
export type { StickyThemeVars } from './types';
|
||||
declare module 'vue' {
|
||||
interface GlobalComponents {
|
||||
VanSticky: typeof Sticky;
|
||||
}
|
||||
}
|
||||
10
node_modules/vant/es/sticky/index.mjs
generated
vendored
Normal file
10
node_modules/vant/es/sticky/index.mjs
generated
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
import { withInstall } from "../utils/index.mjs";
|
||||
import _Sticky from "./Sticky.mjs";
|
||||
const Sticky = withInstall(_Sticky);
|
||||
var stdin_default = Sticky;
|
||||
import { stickyProps } from "./Sticky.mjs";
|
||||
export {
|
||||
Sticky,
|
||||
stdin_default as default,
|
||||
stickyProps
|
||||
};
|
||||
1
node_modules/vant/es/sticky/style/index.d.ts
generated
vendored
Normal file
1
node_modules/vant/es/sticky/style/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export {};
|
||||
2
node_modules/vant/es/sticky/style/index.mjs
generated
vendored
Normal file
2
node_modules/vant/es/sticky/style/index.mjs
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
import "../../style/base.css";
|
||||
import "../index.css";
|
||||
3
node_modules/vant/es/sticky/types.d.ts
generated
vendored
Normal file
3
node_modules/vant/es/sticky/types.d.ts
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
export type StickyThemeVars = {
|
||||
stickyZIndex?: number | string;
|
||||
};
|
||||
0
node_modules/vant/es/sticky/types.mjs
generated
vendored
Normal file
0
node_modules/vant/es/sticky/types.mjs
generated
vendored
Normal file
Reference in New Issue
Block a user