chore: edit README.en.md

This commit is contained in:
就眠儀式 2022-03-16 11:17:05 +08:00
parent 995bca261e
commit 7f0dfd5776
5 changed files with 93 additions and 103 deletions

View File

@ -7,7 +7,7 @@
<a href="https://coveralls.io/r/sentsin/layui?branch=master"><img alt="Test Coverage" src="https://img.shields.io/coveralls/sentsin/layui/master.svg"></a>
</p>
**[🔶 Explore the docs »](http://www.layui-vue.com)**
**[🔶 Explore the docs »](http://www.layui-vue.com)** **[Join us](https://jq.qq.com/?_wv=1027&k=ffiUQgnE)**
An enterprise-class UI components based on Layui and Vue.
@ -75,4 +75,4 @@ This project follows the [all-contributors](https://github.com/layui-vue/layui-v
## Licence
Layui vue is licensed under the [MIT license](https://opensource.org/licenses/MIT).
Layui vue is licensed under the [MIT license](https://opensource.org/licenses/MIT).

View File

@ -7,7 +7,7 @@
<a href="https://coveralls.io/r/sentsin/layui?branch=master"><img alt="Test Coverage" src="https://img.shields.io/coveralls/sentsin/layui/master.svg"></a>
</p>
**[🔶 Explore the docs »](http://www.layui-vue.com)**
**[🔶 Explore the docs »](http://www.layui-vue.com)** **[Join us](https://jq.qq.com/?_wv=1027&k=ffiUQgnE)**
An enterprise-class UI components based on Layui and Vue.
@ -75,4 +75,4 @@ This project follows the [all-contributors](https://github.com/layui-vue/layui-v
## Licence
Layui vue is licensed under the [MIT license](https://opensource.org/licenses/MIT).
Layui vue is licensed under the [MIT license](https://opensource.org/licenses/MIT).

View File

@ -16,8 +16,9 @@
<li>
<h3>0.4.0 <span class="layui-badge-rim">2022-03-08</span></h3>
<ul>
<li>[重构] scroll 虚拟滚动, 代替浏览器原生滚动。</li>
<li>[新增] date-picker 日期选择组件, 支持 年月,日期,时间。</li>
<li>[新增] scroll 虚拟滚动组件。</li>
<li>[新增] water-marker 水印组件。</li>
<li>[新增] date-picker 日期选择组件, 支持年月, 日期, 时间。</li>
<li>[修复] slider 滑块组件, 默认 step 值异常。</li>
<li>[升级] layer-vue 1.3.10 版本。</li>
</ul>

View File

@ -159,13 +159,6 @@ const throttle = (func: Function, wait: number) => {
};
</script>
<style lang="less" scoped>
.layui-side-scroll-bar {
overflow-y: scroll;
max-width: 156px;
}
.layui-side-scroll::-webkit-scrollbar {
width: 0;
}
.lay-aside {
position: fixed;
top: 65px;
@ -270,8 +263,5 @@ const throttle = (func: Function, wait: number) => {
.lay-aside-list {
max-width: 68px;
}
.layui-side-scroll-bar {
max-width: 68px;
}
}
</style>

View File

@ -1,4 +1,3 @@
<template>
<div
class="scrollbar-box"
@ -13,7 +12,7 @@
ref="barRef"
class="scrollbar-track"
:style="{
backgroundColor: heightPre == 1 ? 'rgba(0,0,0,0)' : slotColor
backgroundColor: heightPre == 1 ? 'rgba(0,0,0,0)' : slotColor,
}"
>
<!--
@ -25,7 +24,7 @@
height: barHeight + 'px',
width: scrollWidth + 'px',
transform: 'translateY(' + translateY + 'px)',
backgroundColor: heightPre == 1 ? 'rgba(0,0,0,0)' : scrollColor
backgroundColor: heightPre == 1 ? 'rgba(0,0,0,0)' : scrollColor,
}"
class="scrollbar-thumb"
@mousedown.stop.prevent="moveStart"
@ -34,7 +33,7 @@
</div>
</div>
</template>
<script>
import {
defineComponent,
@ -42,31 +41,31 @@ import {
onMounted,
nextTick,
reactive,
onUnmounted
} from 'vue'
onUnmounted,
} from "vue";
export default defineComponent({
name: 'LayScroll',
name: "LayScroll",
props: {
height: {
//:height="'200px'"
type: String,
default: '100%'
default: "100%",
},
slotColor: {
// :slotColor="'red'"
type: String,
default: 'rgba(0,0,0,0)'
default: "rgba(0,0,0,0)",
},
scrollColor: {
// :scrollColor="'red'"
type: String,
default: '#eeeeee'
default: "#eeeeee",
},
scrollWidth: {
// :scrollWidth="7"
type: Number,
default: 6
}
default: 6,
},
},
setup(props, ctx) {
const data = reactive({
@ -75,64 +74,64 @@ export default defineComponent({
translateY: 0, //
heightPre: 0, //
barHeight: 0, //
winWidth: document.body.clientWidth //
})
let time = null //
let isMove = false //
let moveClientY = 0 //
let trackHeight = 0 //
let wrapHeight = 0 //
let wrapContentHeight = 0 //
winWidth: document.body.clientWidth, //
});
let time = null; //
let isMove = false; //
let moveClientY = 0; //
let trackHeight = 0; //
let wrapHeight = 0; //
let wrapContentHeight = 0; //
//
onMounted(() => {
monitorWindow() //
monitorScrollBar() //
monitorWindow(); //
monitorScrollBar(); //
nextTick(() => {
//dom
calculationLength() //
})
})
calculationLength(); //
});
});
//
onUnmounted(() => {
window.clearInterval(time)
time = null
})
window.clearInterval(time);
time = null;
});
//
const monitorWindow = function () {
let time //
window.addEventListener('resize', () => {
data.winWidth = document.body.clientWidth //
clearTimeout(time)
let time; //
window.addEventListener("resize", () => {
data.winWidth = document.body.clientWidth; //
clearTimeout(time);
time = setTimeout(() => {
//500
// console.log("");
initScrollListner()
}, 500)
})
}
initScrollListner();
}, 500);
});
};
//
const monitorScrollBar = function () {
var monitorUl = data.scrollRef.children[0]
var monitorUl = data.scrollRef.children[0];
// var monitorDiv= document; // document
let MutationObserver =
window.MutationObserver ||
window.WebKitMutationObserver ||
window.MozMutationObserver
window.MozMutationObserver;
let observer = new MutationObserver(function (mutations) {
// console.log("");
initScrollListner()
})
initScrollListner();
});
// childList
//
observer.observe(monitorUl, {
attributes: true,
childList: true
})
}
childList: true,
});
};
//
const calculationLength = function () {
// initScrollListner
@ -140,62 +139,62 @@ export default defineComponent({
// 10
time = setInterval(() => {
//
initScrollListner()
}, 50)
initScrollListner();
}, 50);
// 500
setTimeout(() => {
window.clearInterval(time)
time = null
}, 2000)
}
window.clearInterval(time);
time = null;
}, 2000);
};
//
const initScrollListner = function () {
let scroll = data.scrollRef
let bar = data.barRef
let scroll = data.scrollRef;
let bar = data.barRef;
// scroll
if (scroll) {
wrapContentHeight = scroll.scrollHeight
wrapHeight = scroll.clientHeight
trackHeight = bar.clientHeight
wrapContentHeight = scroll.scrollHeight;
wrapHeight = scroll.clientHeight;
trackHeight = bar.clientHeight;
// console.log(wrapContentHeight ,wrapHeight);
// / 100 150
data.heightPre = wrapHeight / wrapContentHeight
data.heightPre = wrapHeight / wrapContentHeight;
//
data.barHeight = data.heightPre * trackHeight
data.barHeight = data.heightPre * trackHeight;
}
}
};
//
const onMosewheel = function (e) {
// scrollTop
// offsetHeight
// scrollHeight
// data.translateY
data.translateY = e.target.scrollTop * data.heightPre
data.translateY = e.target.scrollTop * data.heightPre;
if (data.translateY == 0) {
//
arrive('top')
arrive("top");
} else if (
e.target.scrollTop + e.target.offsetHeight ==
e.target.scrollHeight
) {
// + ==
arrive('bottom')
arrive("bottom");
}
}
};
//
const arrive = function name(tb) {
ctx.emit('arrive', tb)
}
ctx.emit("arrive", tb);
};
//
const moveStart = function (e) {
isMove = true
isMove = true;
// clientYy
// data.translateY
// moveClientY
moveClientY = e.clientY - data.translateY
moveTo() //
moveEnd() //
}
moveClientY = e.clientY - data.translateY;
moveTo(); //
moveEnd(); //
};
// thumbscrollTop
const moveTo = function () {
document.onmousemove = (e) => {
@ -204,40 +203,40 @@ export default defineComponent({
//
if (e.clientY - moveClientY > trackHeight - data.barHeight) {
// translateY
data.translateY = trackHeight - data.barHeight
data.translateY = trackHeight - data.barHeight;
} else if (e.clientY - moveClientY < 0) {
// translateY
data.translateY = 0
data.translateY = 0;
} else {
//
data.translateY = e.clientY - moveClientY
data.translateY = e.clientY - moveClientY;
}
//
data.scrollRef.scrollTop = data.translateY / data.heightPre
data.scrollRef.scrollTop = data.translateY / data.heightPre;
}
}
}
};
};
//
const moveEnd = function () {
document.onmouseup = (e) => {
if (isMove) {
isMove = false
isMove = false;
}
}
}
};
};
return {
...toRefs(data),
onMosewheel,
moveStart
}
}
})
moveStart,
};
},
});
</script>
<style lang="less" scoped>
.scrollbar-box {
height: 100%;
overflow: hidden !important;;
overflow: hidden !important;
}
.scrollbar-y {
position: relative;
@ -269,4 +268,4 @@ export default defineComponent({
.hide.scrollbar-box .scrollbar-y {
margin: 0;
}
</style>
</style>