first commit
This commit is contained in:
58
node_modules/vant/lib/sticky/Sticky.d.ts
generated
vendored
Normal file
58
node_modules/vant/lib/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;
|
||||
157
node_modules/vant/lib/sticky/Sticky.js
generated
vendored
Normal file
157
node_modules/vant/lib/sticky/Sticky.js
generated
vendored
Normal file
@@ -0,0 +1,157 @@
|
||||
var __defProp = Object.defineProperty;
|
||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __export = (target, all) => {
|
||||
for (var name2 in all)
|
||||
__defProp(target, name2, { get: all[name2], enumerable: true });
|
||||
};
|
||||
var __copyProps = (to, from, except, desc) => {
|
||||
if (from && typeof from === "object" || typeof from === "function") {
|
||||
for (let key of __getOwnPropNames(from))
|
||||
if (!__hasOwnProp.call(to, key) && key !== except)
|
||||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
||||
}
|
||||
return to;
|
||||
};
|
||||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
||||
var stdin_exports = {};
|
||||
__export(stdin_exports, {
|
||||
default: () => stdin_default,
|
||||
stickyProps: () => stickyProps
|
||||
});
|
||||
module.exports = __toCommonJS(stdin_exports);
|
||||
var import_vue = require("vue");
|
||||
var import_utils = require("../utils");
|
||||
var import_use = require("@vant/use");
|
||||
var import_use_visibility_change = require("../composables/use-visibility-change");
|
||||
const [name, bem] = (0, import_utils.createNamespace)("sticky");
|
||||
const stickyProps = {
|
||||
zIndex: import_utils.numericProp,
|
||||
position: (0, import_utils.makeStringProp)("top"),
|
||||
container: Object,
|
||||
offsetTop: (0, import_utils.makeNumericProp)(0),
|
||||
offsetBottom: (0, import_utils.makeNumericProp)(0)
|
||||
};
|
||||
var stdin_default = (0, import_vue.defineComponent)({
|
||||
name,
|
||||
props: stickyProps,
|
||||
emits: ["scroll", "change"],
|
||||
setup(props, {
|
||||
emit,
|
||||
slots
|
||||
}) {
|
||||
const root = (0, import_vue.ref)();
|
||||
const scrollParent = (0, import_use.useScrollParent)(root);
|
||||
const state = (0, import_vue.reactive)({
|
||||
fixed: false,
|
||||
width: 0,
|
||||
// root width
|
||||
height: 0,
|
||||
// root height
|
||||
transform: 0
|
||||
});
|
||||
const isReset = (0, import_vue.ref)(false);
|
||||
const offset = (0, import_vue.computed)(() => (0, import_utils.unitToPx)(props.position === "top" ? props.offsetTop : props.offsetBottom));
|
||||
const rootStyle = (0, import_vue.computed)(() => {
|
||||
if (isReset.value) {
|
||||
return;
|
||||
}
|
||||
const {
|
||||
fixed,
|
||||
height,
|
||||
width
|
||||
} = state;
|
||||
if (fixed) {
|
||||
return {
|
||||
width: `${width}px`,
|
||||
height: `${height}px`
|
||||
};
|
||||
}
|
||||
});
|
||||
const stickyStyle = (0, import_vue.computed)(() => {
|
||||
if (!state.fixed || isReset.value) {
|
||||
return;
|
||||
}
|
||||
const style = (0, import_utils.extend)((0, import_utils.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 || (0, import_utils.isHidden)(root)) {
|
||||
return;
|
||||
}
|
||||
const {
|
||||
container,
|
||||
position
|
||||
} = props;
|
||||
const rootRect = (0, import_use.useRect)(root);
|
||||
const scrollTop = (0, import_utils.getScrollTop)(window);
|
||||
state.width = rootRect.width;
|
||||
state.height = rootRect.height;
|
||||
if (position === "top") {
|
||||
if (container) {
|
||||
const containerRect = (0, import_use.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 = (0, import_use.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);
|
||||
};
|
||||
(0, import_vue.watch)(() => state.fixed, (value) => emit("change", value));
|
||||
(0, import_use.useEventListener)("scroll", onScroll, {
|
||||
target: scrollParent,
|
||||
passive: true
|
||||
});
|
||||
(0, import_use_visibility_change.useVisibilityChange)(root, onScroll);
|
||||
(0, import_vue.watch)([import_utils.windowWidth, import_utils.windowHeight], () => {
|
||||
if (!root.value || (0, import_utils.isHidden)(root) || !state.fixed) {
|
||||
return;
|
||||
}
|
||||
isReset.value = true;
|
||||
(0, import_vue.nextTick)(() => {
|
||||
const rootRect = (0, import_use.useRect)(root);
|
||||
state.width = rootRect.width;
|
||||
state.height = rootRect.height;
|
||||
isReset.value = false;
|
||||
});
|
||||
});
|
||||
return () => {
|
||||
var _a;
|
||||
return (0, import_vue.createVNode)("div", {
|
||||
"ref": root,
|
||||
"style": rootStyle.value
|
||||
}, [(0, import_vue.createVNode)("div", {
|
||||
"class": bem({
|
||||
fixed: state.fixed && !isReset.value
|
||||
}),
|
||||
"style": stickyStyle.value
|
||||
}, [(_a = slots.default) == null ? void 0 : _a.call(slots)])]);
|
||||
};
|
||||
}
|
||||
});
|
||||
1
node_modules/vant/lib/sticky/index.css
generated
vendored
Normal file
1
node_modules/vant/lib/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/lib/sticky/index.d.ts
generated
vendored
Normal file
47
node_modules/vant/lib/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;
|
||||
}
|
||||
}
|
||||
39
node_modules/vant/lib/sticky/index.js
generated
vendored
Normal file
39
node_modules/vant/lib/sticky/index.js
generated
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
var __create = Object.create;
|
||||
var __defProp = Object.defineProperty;
|
||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||
var __getProtoOf = Object.getPrototypeOf;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __export = (target, all) => {
|
||||
for (var name in all)
|
||||
__defProp(target, name, { get: all[name], enumerable: true });
|
||||
};
|
||||
var __copyProps = (to, from, except, desc) => {
|
||||
if (from && typeof from === "object" || typeof from === "function") {
|
||||
for (let key of __getOwnPropNames(from))
|
||||
if (!__hasOwnProp.call(to, key) && key !== except)
|
||||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
||||
}
|
||||
return to;
|
||||
};
|
||||
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
||||
// If the importer is in node compatibility mode or this is not an ESM
|
||||
// file that has been converted to a CommonJS file using a Babel-
|
||||
// compatible transform (i.e. "__esModule" has not been set), then set
|
||||
// "default" to the CommonJS "module.exports" for node compatibility.
|
||||
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
||||
mod
|
||||
));
|
||||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
||||
var stdin_exports = {};
|
||||
__export(stdin_exports, {
|
||||
Sticky: () => Sticky,
|
||||
default: () => stdin_default,
|
||||
stickyProps: () => import_Sticky2.stickyProps
|
||||
});
|
||||
module.exports = __toCommonJS(stdin_exports);
|
||||
var import_utils = require("../utils");
|
||||
var import_Sticky = __toESM(require("./Sticky"));
|
||||
var import_Sticky2 = require("./Sticky");
|
||||
const Sticky = (0, import_utils.withInstall)(import_Sticky.default);
|
||||
var stdin_default = Sticky;
|
||||
1
node_modules/vant/lib/sticky/style/index.d.ts
generated
vendored
Normal file
1
node_modules/vant/lib/sticky/style/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export {};
|
||||
2
node_modules/vant/lib/sticky/style/index.js
generated
vendored
Normal file
2
node_modules/vant/lib/sticky/style/index.js
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
require("../../style/base.css");
|
||||
require("../index.css");
|
||||
3
node_modules/vant/lib/sticky/types.d.ts
generated
vendored
Normal file
3
node_modules/vant/lib/sticky/types.d.ts
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
export type StickyThemeVars = {
|
||||
stickyZIndex?: number | string;
|
||||
};
|
||||
15
node_modules/vant/lib/sticky/types.js
generated
vendored
Normal file
15
node_modules/vant/lib/sticky/types.js
generated
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
var __defProp = Object.defineProperty;
|
||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __copyProps = (to, from, except, desc) => {
|
||||
if (from && typeof from === "object" || typeof from === "function") {
|
||||
for (let key of __getOwnPropNames(from))
|
||||
if (!__hasOwnProp.call(to, key) && key !== except)
|
||||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
||||
}
|
||||
return to;
|
||||
};
|
||||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
||||
var stdin_exports = {};
|
||||
module.exports = __toCommonJS(stdin_exports);
|
||||
Reference in New Issue
Block a user