@@ -1078,41 +1080,52 @@ let imageList = ref(null)
let imgList = ref([])
//图片距离
-let imageLIst = ref([])
+let imageLIstLeft = ref([])
let imgListTab = ref(0)
//计时器
let interval = ''
+let clientWidth = ref(null)
+let scrollWidth = ref(null)
//点击方向按钮
let moveImageList = (type) => {
- let clientWidth = imageList.value.clientWidth
- let scrollWidth = imageList.value.scrollWidth
- if (type === 'right' && imageLIst.value[imgListTab.value] + clientWidth >= scrollWidth) return
- if ((type === 'left' && imgListTab.value === 0) || (imgListTab.value === imageLIst.value.length - 1 && type === 'right')) return
+ if (type === 'right' && imgScrollBottom()) return
+ if ((type === 'left' && imgListTab.value === 0) || (imgListTab.value === imageLIstLeft.value.length - 1 && type === 'right')) return
type === 'left' ? imgListTab.value-- : imgListTab.value++
- setOffsetWidth(imageLIst.value[imgListTab.value], type)
+ setOffsetWidth(imageLIstLeft.value[imgListTab.value], type)
}
//设置滚动
let setOffsetWidth = (num, type) => {
let scroll = 0
- let clientWidth = imageList.value.clientWidth
- let scrollWidth = imageList.value.scrollWidth
interval = setInterval(() => {
if (!imageList.value) {
clearInterval(interval)
return
}
scroll = type === 'left' ? imageList.value.scrollLeft -= 10 : imageList.value.scrollLeft += 10
- if ((type === 'left' ? num >= scroll : num <= scroll) || scroll + clientWidth >= scrollWidth) {
+ if ((type === 'left' ? num >= scroll : num <= scroll) || scroll + clientWidth.value >= scrollWidth.value) {
clearInterval(interval)
}
})
}
+//判断是否触底
+let imgScrollBottom = () => {
+ let clientWidth = imageList.value.clientWidth
+ let scrollWidth = imageList.value.scrollWidth
+ return imageLIstLeft.value[imgListTab.value] + clientWidth >= scrollWidth
+}
+
let imgData = ref(null)
//获取图片宽度
let setImageWidth = (num) => {
- imageLIst.value[num] = imgData.value[num] && imgData.value[num].offsetLeft - 20
+ imageLIstLeft.value[num] = imgData.value[num] && imgData.value[num].offsetLeft - 20
+ console.log(imageLIstLeft.value)
+ if (imageLIstLeft.value.length === imgList.value.length) {
+ clientWidth.value = imageList.value.clientWidth
+ scrollWidth.value = imageList.value.scrollWidth
+ console.log(scrollWidth.value,clientWidth.value)
+ }
}
//学校地址数据
@@ -1494,7 +1507,8 @@ img {
.jus-x {
justify-content: center;
}
-.jus-sp{
+
+.jus-sp {
justify-content: space-around;
}
@@ -1674,8 +1688,8 @@ img {
letter-spacing: normal;
color: #333333;
- .mg-l-80{
- margin-left:80px;
+ .mg-l-80 {
+ margin-left: 80px;
}
.round {
@@ -1776,8 +1790,8 @@ img {
margin-bottom: 30px;
}
- .mg-b-50{
- margin-bottom:50px;
+ .mg-b-50 {
+ margin-bottom: 50px;
}
.mg-b-30 {
@@ -1793,7 +1807,7 @@ img {
margin-top: 20px;
.num-text {
- width:180px;
+ width: 180px;
word-wrap: break-word;
}
}