docs: 更新日志

This commit is contained in:
就眠儀式 2022-03-16 01:00:37 +08:00
parent a4bfb2f5df
commit 995bca261e
6 changed files with 289 additions and 32 deletions

View File

@ -127,7 +127,7 @@ export default {
<lay-button type="normal" radius>百搭按钮</lay-button> <lay-button type="normal" radius>百搭按钮</lay-button>
<lay-button type="warm" radius>暖色按钮</lay-button> <lay-button type="warm" radius>暖色按钮</lay-button>
<lay-button type="danger" radius>警告按钮</lay-button> <lay-button type="danger" radius>警告按钮</lay-button>
<lay-button @click="onClick" disabled radius>禁用按钮</lay-button> <lay-button disabled radius>禁用按钮</lay-button>
</template> </template>
<script> <script>
@ -136,12 +136,7 @@ import { ref } from 'vue'
export default { export default {
setup() { setup() {
const onClick = () => {
console.log("click event");
}
return { return {
onClick
} }
} }
} }
@ -280,7 +275,7 @@ import { ref } from 'vue'
export default { export default {
setup() { setup() {
const clickHandle = function() { const clickHandle = () => {
console.log('点击事件') console.log('点击事件')
} }

View File

@ -10,6 +10,20 @@
::: demo ::: demo
<template> <template>
<lay-timeline> <lay-timeline>
<lay-timeline-item title="0.4.0">
<ul>
<a name="0-4-0"> </a>
<li>
<h3>0.4.0 <span class="layui-badge-rim">2022-03-08</span></h3>
<ul>
<li>[重构] scroll 虚拟滚动, 代替浏览器原生滚动。</li>
<li>[新增] date-picker 日期选择组件, 支持 年月,日期,时间。</li>
<li>[修复] slider 滑块组件, 默认 step 值异常。</li>
<li>[升级] layer-vue 1.3.10 版本。</li>
</ul>
</li>
</ul>
</lay-timeline-item>
<lay-timeline-item title="0.3.x"> <lay-timeline-item title="0.3.x">
<ul> <ul>
<a name="0-3-9"></a> <a name="0-3-9"></a>

View File

@ -10,9 +10,6 @@
<lay-icon :type="iconType" size="40"> </lay-icon> <lay-icon :type="iconType" size="40"> </lay-icon>
</lay-button> </lay-button>
</div> </div>
<lay-scroll
class="layui-side-scroll-bar layui-side-scroll::-webkit-scrollbar"
>
<ul> <ul>
<li <li
v-for="(anchor, index) in anchorList" v-for="(anchor, index) in anchorList"
@ -29,7 +26,6 @@
> >
</li> </li>
</ul> </ul>
</lay-scroll>
</aside> </aside>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">

View File

@ -261,9 +261,9 @@ const MONTH_NAME = [
]; ];
const hms = ref({ const hms = ref({
hh: "23", hh: "00",
mm: "59", mm: "00",
ss: "59", ss: "00",
insertEls: [ insertEls: [
{ {
count: 24, count: 24,

View File

@ -1,13 +1,272 @@
<script lang="ts">
export default {
name: "LayScroll",
};
</script>
<script setup lang="ts"></script>
<template> <template>
<div class="layui-side-scroll"> <div
class="scrollbar-box"
:class="{ hide: winWidth < 500 }"
:style="{ height: height }"
>
<div class="scrollbar-y">
<div ref="scrollRef" class="scroll-wrap" @scroll="onMosewheel">
<slot></slot> <slot></slot>
</div> </div>
<div
ref="barRef"
class="scrollbar-track"
:style="{
backgroundColor: heightPre == 1 ? 'rgba(0,0,0,0)' : slotColor
}"
>
<!--
没有滑块方式背景色透明使用v-show窗口变大滑块不出现所以使用背景色控制
backgroundColor: heightPre == 1 ? 'rgba(0,0,0,0)' : scrollColor,
-->
<div
:style="{
height: barHeight + 'px',
width: scrollWidth + 'px',
transform: 'translateY(' + translateY + 'px)',
backgroundColor: heightPre == 1 ? 'rgba(0,0,0,0)' : scrollColor
}"
class="scrollbar-thumb"
@mousedown.stop.prevent="moveStart"
></div>
</div>
</div>
</div>
</template> </template>
<script>
import {
defineComponent,
toRefs,
onMounted,
nextTick,
reactive,
onUnmounted
} from 'vue'
export default defineComponent({
name: 'LayScroll',
props: {
height: {
//:height="'200px'"
type: String,
default: '100%'
},
slotColor: {
// :slotColor="'red'"
type: String,
default: 'rgba(0,0,0,0)'
},
scrollColor: {
// :scrollColor="'red'"
type: String,
default: '#eeeeee'
},
scrollWidth: {
// :scrollWidth="7"
type: Number,
default: 6
}
},
setup(props, ctx) {
const data = reactive({
scrollRef: null, //
barRef: null, //
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 //
//
onMounted(() => {
monitorWindow() //
monitorScrollBar() //
nextTick(() => {
//dom
calculationLength() //
})
})
//
onUnmounted(() => {
window.clearInterval(time)
time = null
})
//
const monitorWindow = function () {
let time //
window.addEventListener('resize', () => {
data.winWidth = document.body.clientWidth //
clearTimeout(time)
time = setTimeout(() => {
//500
// console.log("");
initScrollListner()
}, 500)
})
}
//
const monitorScrollBar = function () {
var monitorUl = data.scrollRef.children[0]
// var monitorDiv= document; // document
let MutationObserver =
window.MutationObserver ||
window.WebKitMutationObserver ||
window.MozMutationObserver
let observer = new MutationObserver(function (mutations) {
// console.log("");
initScrollListner()
})
// childList
//
observer.observe(monitorUl, {
attributes: true,
childList: true
})
}
//
const calculationLength = function () {
// initScrollListner
// dom
// 10
time = setInterval(() => {
//
initScrollListner()
}, 50)
// 500
setTimeout(() => {
window.clearInterval(time)
time = null
}, 2000)
}
//
const initScrollListner = function () {
let scroll = data.scrollRef
let bar = data.barRef
// scroll
if (scroll) {
wrapContentHeight = scroll.scrollHeight
wrapHeight = scroll.clientHeight
trackHeight = bar.clientHeight
// console.log(wrapContentHeight ,wrapHeight);
// / 100 150
data.heightPre = wrapHeight / wrapContentHeight
//
data.barHeight = data.heightPre * trackHeight
}
}
//
const onMosewheel = function (e) {
// scrollTop
// offsetHeight
// scrollHeight
// data.translateY
data.translateY = e.target.scrollTop * data.heightPre
if (data.translateY == 0) {
//
arrive('top')
} else if (
e.target.scrollTop + e.target.offsetHeight ==
e.target.scrollHeight
) {
// + ==
arrive('bottom')
}
}
//
const arrive = function name(tb) {
ctx.emit('arrive', tb)
}
//
const moveStart = function (e) {
isMove = true
// clientYy
// data.translateY
// moveClientY
moveClientY = e.clientY - data.translateY
moveTo() //
moveEnd() //
}
// thumbscrollTop
const moveTo = function () {
document.onmousemove = (e) => {
//
if (isMove) {
//
if (e.clientY - moveClientY > trackHeight - data.barHeight) {
// translateY
data.translateY = trackHeight - data.barHeight
} else if (e.clientY - moveClientY < 0) {
// translateY
data.translateY = 0
} else {
//
data.translateY = e.clientY - moveClientY
}
//
data.scrollRef.scrollTop = data.translateY / data.heightPre
}
}
}
//
const moveEnd = function () {
document.onmouseup = (e) => {
if (isMove) {
isMove = false
}
}
}
return {
...toRefs(data),
onMosewheel,
moveStart
}
}
})
</script>
<style lang="less" scoped>
.scrollbar-box {
height: 100%;
overflow: hidden !important;;
}
.scrollbar-y {
position: relative;
height: 100%;
margin-right: -17px; //
.scroll-wrap {
height: 100%;
overflow-y: scroll;
}
.scrollbar-track {
position: absolute;
top: 0;
right: 17px;
bottom: 0;
border-radius: 8px;
z-index: 20;
.scrollbar-thumb {
margin: 0 auto;
border-radius: 6px;
cursor: default;
}
}
}
//
.hide.scrollbar-box .scrollbar-track {
display: none;
}
//
.hide.scrollbar-box .scrollbar-y {
margin: 0;
}
</style>

View File

@ -34,8 +34,7 @@ hr {
} }
.layui-layout-body, .layui-layout-body,
.layui-side, .layui-side {
.layui-side-scroll {
overflow-x: hidden; overflow-x: hidden;
} }
@ -268,12 +267,6 @@ a cite {
margin: 0 auto; margin: 0 auto;
} }
.layui-side-scroll {
position: relative;
width: 220px;
height: 100%;
}
.layui-logo { .layui-logo {
left: 0; left: 0;
top: 0; top: 0;