😉 修复 layer offset 百分比偏移
This commit is contained in:
42
src/module/avatar/index.less
Normal file
42
src/module/avatar/index.less
Normal file
@@ -0,0 +1,42 @@
|
||||
.layui-avatar {
|
||||
box-sizing: border-box;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
color: #000000d9;
|
||||
font-size: 14px;
|
||||
font-variant: tabular-nums;
|
||||
line-height: 1.5715;
|
||||
list-style: none;
|
||||
font-feature-settings: tnum;
|
||||
position: relative;
|
||||
display: inline-block;
|
||||
overflow: hidden;
|
||||
color: #fff;
|
||||
white-space: nowrap;
|
||||
text-align: center;
|
||||
vertical-align: middle;
|
||||
background: #ccc;
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
line-height: 32px;
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
.layui-avatar.layui-avatar-radius {
|
||||
border-radius: 50%;
|
||||
}
|
||||
|
||||
.layui-avatar.layui-avatar-sm {
|
||||
height: 30px;
|
||||
width: 30px;
|
||||
}
|
||||
|
||||
.layui-avatar.layui-avatar-lg {
|
||||
height: 36px;
|
||||
width: 36px;
|
||||
}
|
||||
|
||||
.layui-avatar.layui-avatar-xs {
|
||||
height: 28px;
|
||||
width: 28px;
|
||||
}
|
||||
@@ -1,3 +1,20 @@
|
||||
<script lang="ts">
|
||||
export default {
|
||||
name: "LayAvatar"
|
||||
}
|
||||
</script>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { defineProps } from 'vue'
|
||||
import "./index.less"
|
||||
|
||||
const props = defineProps<{
|
||||
src?: String
|
||||
radius?: boolean
|
||||
size?: string
|
||||
}>()
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<img
|
||||
:src="src"
|
||||
@@ -7,14 +24,4 @@
|
||||
size ? 'layui-avatar-' + size : '',
|
||||
]"
|
||||
/>
|
||||
</template>
|
||||
|
||||
<script setup name="LayAvatar" lang="ts">
|
||||
import { defineProps } from 'vue'
|
||||
|
||||
const props = defineProps<{
|
||||
src?: String
|
||||
radius?: boolean
|
||||
size?: string
|
||||
}>()
|
||||
</script>
|
||||
</template>
|
||||
@@ -61,11 +61,12 @@ const props = withDefaults(defineProps<LayLayerProps>(), {
|
||||
isOutAnim: true
|
||||
});
|
||||
|
||||
const top = ref(props.offset[0]);
|
||||
const left = ref(props.offset[1]);
|
||||
const top = ref(props.offset[0].indexOf('%') != -1 ? "calc(" + props.offset[0] + " - (" + props.height + "/2 ))" : props.offset[0]);
|
||||
const left = ref(props.offset[1].indexOf('%') != -1 ? "calc(" + props.offset[1] + " - (" + props.width + "/2 ))" : props.offset[1]);
|
||||
const width = ref(props.width);
|
||||
const height = ref(props.height);
|
||||
const max = ref(false);
|
||||
|
||||
const contentHeight = ref(
|
||||
props.btn.length > 0
|
||||
? "calc(" + height.value + " - 100px)"
|
||||
@@ -112,13 +113,19 @@ const minHandle = function () {
|
||||
emit("update:visible", false);
|
||||
};
|
||||
|
||||
const maxBeforeTop = ref()
|
||||
const maxBeforeLeft = ref()
|
||||
|
||||
const maxHandle = function () {
|
||||
if (max.value) {
|
||||
width.value = props.width;
|
||||
height.value = props.height;
|
||||
top.value = props.offset[0];
|
||||
left.value = props.offset[1];
|
||||
top.value = maxBeforeTop.value;
|
||||
left.value = maxBeforeLeft.value;
|
||||
} else {
|
||||
let dom = document.getElementById(props.id);
|
||||
maxBeforeTop.value = dom?.style.top
|
||||
maxBeforeLeft.value = dom?.style.left
|
||||
width.value = "100%";
|
||||
height.value = "100%";
|
||||
top.value = "0px";
|
||||
|
||||
Reference in New Issue
Block a user