♻️: 更新 scroll 组件属性命名

This commit is contained in:
就眠儀式 2022-05-01 18:45:27 +08:00
parent f7fccdcff9
commit edbb777928
3 changed files with 32 additions and 18 deletions

View File

@ -12,20 +12,16 @@
ref="barRef" ref="barRef"
class="layui-scroll-track" class="layui-scroll-track"
:style="{ :style="{
backgroundColor: data.heightPre == 1 ? 'rgba(0,0,0,0)' : slotColor, backgroundColor: data.heightPre == 1 ? 'rgba(0,0,0,0)' : trackColor,
}" }"
> >
<!--
没有滑块方式背景色透明使用v-show窗口变大滑块不出现所以使用背景色控制
backgroundColor: heightPre == 1 ? 'rgba(0,0,0,0)' : scrollColor,
-->
<div <div
:style="{ :style="{
height: data.barHeight + 'px', height: data.barHeight + 'px',
width: scrollWidth + 'px', width: thumbWidth + 'px',
transform: 'translateY(' + data.translateY + 'px)', transform: 'translateY(' + data.translateY + 'px)',
backgroundColor: backgroundColor:
data.heightPre == 1 ? 'rgba(0,0,0,0)' : scrollColor, data.heightPre == 1 ? 'rgba(0,0,0,0)' : thumbColor,
}" }"
class="layui-scroll-thumb" class="layui-scroll-thumb"
@mousedown.stop.prevent="moveStart" @mousedown.stop.prevent="moveStart"
@ -47,16 +43,16 @@ import { toRefs, onMounted, nextTick, reactive, onUnmounted, ref } from "vue";
export interface LayScrollProps { export interface LayScrollProps {
height?: string; height?: string;
slotColor?: string; trackColor?: string;
scrollColor?: string; thumbColor?: string;
scrollWidth?: number; thumbWidth?: number;
} }
const props = withDefaults(defineProps<LayScrollProps>(), { const props = withDefaults(defineProps<LayScrollProps>(), {
height: "100%", height: "100%",
slotColor: "rgba(0,0,0,0)", trackColor: "rgba(0,0,0,0)",
scrollColor: "#eeeeee", thumbColor: "#eeeeee",
scrollWidth: 6, thumbWidth: 6,
}); });
const emit = defineEmits(["arrive"]); const emit = defineEmits(["arrive"]);
@ -70,6 +66,7 @@ const data = reactive({
barHeight: 0, // barHeight: 0, //
winWidth: document.body.clientWidth, // winWidth: document.body.clientWidth, //
}); });
let time = null; // let time = null; //
let isMove = false; // let isMove = false; //
let moveClientY = 0; // let moveClientY = 0; //
@ -86,11 +83,13 @@ onMounted(() => {
calculationLength(); // calculationLength(); //
}); });
}); });
// //
onUnmounted(() => { onUnmounted(() => {
window.clearInterval(time); window.clearInterval(time);
time = null; time = null;
}); });
// //
const monitorWindow = function () { const monitorWindow = function () {
let time; // let time; //
@ -120,7 +119,6 @@ const monitorScrollBar = function () {
initScrollListner(); initScrollListner();
}); });
// childList
// //
observer.observe(monitorUl, { observer.observe(monitorUl, {
attributes: true, attributes: true,
@ -143,6 +141,7 @@ const calculationLength = function () {
time = null; time = null;
}, 2000); }, 2000);
}; };
// //
const initScrollListner = function () { const initScrollListner = function () {
let scroll = scrollRef.value; let scroll = scrollRef.value;
@ -159,6 +158,7 @@ const initScrollListner = function () {
data.barHeight = data.heightPre * trackHeight; data.barHeight = data.heightPre * trackHeight;
} }
}; };
// //
const onMosewheel = function (e) { const onMosewheel = function (e) {
// scrollTop // scrollTop
@ -177,10 +177,12 @@ const onMosewheel = function (e) {
arrive("bottom"); arrive("bottom");
} }
}; };
// //
const arrive = function name(tb) { const arrive = function name(tb) {
emit("arrive", tb); emit("arrive", tb);
}; };
// //
const moveStart = function (e) { const moveStart = function (e) {
isMove = true; isMove = true;
@ -191,6 +193,7 @@ const moveStart = function (e) {
moveTo(); // moveTo(); //
moveEnd(); // moveEnd(); //
}; };
// thumbscrollTop // thumbscrollTop
const moveTo = function () { const moveTo = function () {
document.onmousemove = (e) => { document.onmousemove = (e) => {
@ -212,6 +215,7 @@ const moveTo = function () {
} }
}; };
}; };
// //
const moveEnd = function () { const moveEnd = function () {
document.onmouseup = (e) => { document.onmouseup = (e) => {

View File

@ -40,9 +40,9 @@ export default {
| 属性 | 描述 | 可选值 | | 属性 | 描述 | 可选值 |
| ----------- | -------- | ------ | | ----------- | -------- | ------ |
| height | 高度 | -- | | height | 高度 | -- |
| scrollWidth | 滑块宽度 | -- | | thumbWidth | 滑块宽度 | -- |
| scrollColor | 滑块颜色 | -- | | thumbColor | 滑块颜色 | -- |
| slotColor | 滑槽颜色 | -- | | trackColor | 滑槽颜色 | -- |
::: :::

View File

@ -11,12 +11,22 @@
<template> <template>
<lay-timeline> <lay-timeline>
<lay-timeline-item title="1.0.x"> <lay-timeline-item title="1.0.x">
<ul>
<a name="1-0-6"> </a>
<li>
<h3>1.0.6 <span class="layui-badge-rim">2022-05-02</span></h3>
<ul>
<li>[修复] scroll 组件 height 属性必填警告。</li>
<li>[修复] scroll 组件 slotColor 属性必填警告。</li>
</ul>
</li>
</ul>
<ul> <ul>
<a name="1-0-5"> </a> <a name="1-0-5"> </a>
<li> <li>
<h3>1.0.5 <span class="layui-badge-rim">2022-05-01</span></h3> <h3>1.0.5 <span class="layui-badge-rim">2022-05-01</span></h3>
<ul> <ul>
<li>[新增] dropdown 组件 context-menu 属性。。</li> <li>[新增] dropdown 组件 context-menu 属性。</li>
<li>[修复] layer 组件 tooltip 组件 index 层级冲突。</li> <li>[修复] layer 组件 tooltip 组件 index 层级冲突。</li>
<li>[修复] table 组件 columns 宽度超出 table-box 错位。</li> <li>[修复] table 组件 columns 宽度超出 table-box 错位。</li>
<li>[修复] table 组件 selected-keys 属性 deep 监听。</li> <li>[修复] table 组件 selected-keys 属性 deep 监听。</li>