mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-05-23 15:09:16 +08:00
chore(FloatingPanel): improve code style (#12175)
This commit is contained in:
parent
392da16c30
commit
fb1cafd105
@ -1,8 +1,8 @@
|
|||||||
import {
|
import {
|
||||||
computed,
|
|
||||||
defineComponent,
|
|
||||||
ref,
|
ref,
|
||||||
watch,
|
watch,
|
||||||
|
computed,
|
||||||
|
defineComponent,
|
||||||
type ExtractPropTypes,
|
type ExtractPropTypes,
|
||||||
} from 'vue';
|
} from 'vue';
|
||||||
|
|
||||||
@ -13,6 +13,7 @@ import {
|
|||||||
createNamespace,
|
createNamespace,
|
||||||
makeArrayProp,
|
makeArrayProp,
|
||||||
makeNumericProp,
|
makeNumericProp,
|
||||||
|
preventDefault,
|
||||||
truthProp,
|
truthProp,
|
||||||
windowHeight,
|
windowHeight,
|
||||||
} from '../utils';
|
} from '../utils';
|
||||||
@ -36,8 +37,6 @@ export type FloatingPanelProps = ExtractPropTypes<typeof floatingPanelProps>;
|
|||||||
|
|
||||||
const [name, bem] = createNamespace('floating-panel');
|
const [name, bem] = createNamespace('floating-panel');
|
||||||
|
|
||||||
const DAMP = 0.2;
|
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
name,
|
name,
|
||||||
|
|
||||||
@ -46,6 +45,7 @@ export default defineComponent({
|
|||||||
emits: ['heightChange', 'update:height'],
|
emits: ['heightChange', 'update:height'],
|
||||||
|
|
||||||
setup(props, { emit, slots }) {
|
setup(props, { emit, slots }) {
|
||||||
|
const DAMP = 0.2;
|
||||||
const rootRef = ref<HTMLDivElement>();
|
const rootRef = ref<HTMLDivElement>();
|
||||||
const contentRef = ref<HTMLDivElement>();
|
const contentRef = ref<HTMLDivElement>();
|
||||||
const height = useSyncPropRef(
|
const height = useSyncPropRef(
|
||||||
@ -89,8 +89,8 @@ export default defineComponent({
|
|||||||
return moveY;
|
return moveY;
|
||||||
};
|
};
|
||||||
|
|
||||||
let startY: number,
|
let startY: number;
|
||||||
maxScroll: number = -1;
|
let maxScroll: number = -1;
|
||||||
const touch = useTouch();
|
const touch = useTouch();
|
||||||
|
|
||||||
const onTouchstart = (e: TouchEvent) => {
|
const onTouchstart = (e: TouchEvent) => {
|
||||||
@ -112,11 +112,11 @@ export default defineComponent({
|
|||||||
if (!props.contentDraggable) return;
|
if (!props.contentDraggable) return;
|
||||||
|
|
||||||
if (-startY < boundary.value.max) {
|
if (-startY < boundary.value.max) {
|
||||||
if (e.cancelable) e.preventDefault();
|
preventDefault(e, true);
|
||||||
e.stopPropagation();
|
} else if (
|
||||||
} else if (!(scrollTop <= 0 && touch.deltaY.value > 0)) {
|
!(scrollTop <= 0 && touch.deltaY.value > 0) ||
|
||||||
return;
|
maxScroll > 0
|
||||||
} else if (maxScroll > 0) {
|
) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user