当前位置: 首页 > news >正文

超值的镇江网站建设流量宝

超值的镇江网站建设,流量宝,网站建设公司业务提成多少,网站设计师需要什么知识与技能问题描述:默认情况下 vue-grid-layout 移动卡片到页面底部时页面滚动条并不会跟随卡片滚动。 问题解决: 在 grid-item中的move事件中,获取到当前移动的元素,并使用scrollIntoView方法来实现滚动条跟随。 代码如下: c…

问题描述:默认情况下 vue-grid-layout 移动卡片到页面底部时页面滚动条并不会跟随卡片滚动。

在这里插入图片描述

问题解决:

grid-item中的move事件中,获取到当前移动的元素,并使用scrollIntoView方法来实现滚动条跟随。
代码如下:

const moveEvent = (i: any) => {let cIdx = layout.value.findIndex(item => item.i === i)let el = gridItemRefs.value[cIdx].$elsetTimeout(() => {el?.scrollIntoView({ behavior: "smooth", block: "end" })}, 300)
}

此时优化效果如下:
在这里插入图片描述

  • 但是上面优化还有一个小问题,将卡片右移可以无效无限右移。
    所以根据元素的lastX来控制一下:
const moveEvent = (i: any) => {let cIdx = layout.value.findIndex(item => item.i === i)let el = gridItemRefs.value[cIdx].$elsetTimeout(() => {console.log(gridItemRefs.value[cIdx].lastX, '===gridItemRefs.value[cIdx]');if (gridItemRefs.value[cIdx].lastX < 900) {el?.scrollIntoView({ behavior: "smooth", block: "end" })}}, 300)
}

同理,如果是从外层拖到元素进来,也可以使用 scrollIntoView来设置滚动条跟随。
代码如下:
在这里插入图片描述

const colNum = 12
const drag = (item: any) => {let parentRect = document.getElementById('content')?.getBoundingClientRect()!;let mouseInGrid = false;if (((mouseXY.x > parentRect.left) && (mouseXY.x < parentRect.right)) && ((mouseXY.y > parentRect.top) && (mouseXY.y < parentRect.bottom))) {mouseInGrid = true;}if (mouseInGrid === true && (layout.value.findIndex(item => item.i === 'drop')) === -1) {layout.value.push({x: (layout.value.length * 2) % (colNum || 12),y: layout.value.length + (colNum || 12), // puts it at the bottomw: item.w,h: item.h,i: 'drop',});}let index = layout.value.findIndex(item => item.i === 'drop');if (index !== -1) {try {gridItemRefs.value[layout.value.length - 1].$refs.item.style.display = "none";} catch {}let el = gridItemRefs.value[index];if (el) {setTimeout(() => {el.$el?.scrollIntoView({ behavior: "smooth", block: "nearest" })}, 300)el.dragging = { "top": mouseXY.y - parentRect.top, "left": mouseXY.x - parentRect.left };let new_pos = el.calcXY(mouseXY.y - parentRect.top, mouseXY.x - parentRect.left);if (mouseInGrid === true) {gridlayout.value.dragEvent('dragstart', 'drop', new_pos.x || 0, new_pos.y || 0, item.h, item.w);// dragEvent('dragstart', 'drop', new_pos.x || 0, new_pos.y || 0, defaultH, defaultW);DragPos.i = String(new Date().getTime());DragPos.x = layout.value[index].x;DragPos.y = layout.value[index].y;DragPos.w = layout.value[index].w;DragPos.h = layout.value[index].h;}if (mouseInGrid === false) {gridlayout.value.dragEvent('dragend', 'drop', new_pos.x || 0, new_pos.y || 0, item.h, item.w);// dragEvent('dragend', 'drop', new_pos.x || 0, new_pos.y || 0, defaultH, defaultW);layout.value = layout.value.filter(obj => obj.i !== 'drop');}}}
}
const dragend = () => {let parentRect = document.getElementById('content')?.getBoundingClientRect()!;let mouseInGrid = false;if (((mouseXY.x > parentRect.left) && (mouseXY.x < parentRect.right)) && ((mouseXY.y > parentRect.top) && (mouseXY.y < parentRect.bottom))) {mouseInGrid = true;}if (mouseInGrid === true) {gridlayout.value.dragEvent('dragend', 'drop', DragPos.x, DragPos.y, DragPos.h, DragPos.w);let delIndex = layout.value.findIndex(item => item.i === 'drop')layout.value.splice(delIndex, 1)// UNCOMMENT below if you want to add a grid-itemlayout.value.push({x: DragPos.x,y: DragPos.y,w: DragPos.w,h: DragPos.h,i: DragPos.i,});gridlayout.value.dragEvent('dragend', DragPos.i, DragPos.x, DragPos.y, DragPos.h, DragPos.w);try {gridItemRefs.value[layout.value.length - 1].$refs.item.style.display = "block";} catch {}}
}
http://www.dinnco.com/news/29434.html

相关文章:

  • 网站广告手机网页制作软件
  • 网站开发 cms台州seo优化公司
  • 网站建设费用包括哪些苏州搜索引擎优化
  • 自己网站如何做关键词排名靠前admin5站长网
  • 网站文字模板抖音seo运营模式
  • 个人域名可以备案企业网站吗seo计费系统源码
  • 帝国怎么做中英文网站网站手机优化
  • 什么网站是做家教的产品网络推广方式
  • 免费做网站方案什么是软文写作
  • wordpress虚拟主机无法发邮件shopify seo
  • 沧州网站建设多少钱整站快速排名优化
  • 专业网站建设的意义银川网页设计公司
  • wordpress 与 thinkphp象山关键词seo排名
  • 如何做网站授权网址2022年关键词排名
  • 网站城市切换如何做厦门谷歌seo公司
  • 淘宝网站小视频怎么做百度推广页面投放
  • 中关村手机网衡阳seo优化推荐
  • 黄贝建设网站建设常熟网站建设
  • 做网站最多的行业武汉网络营销公司排名
  • 高端建站网站的网站推广优化c重庆
  • 东营网站建设app开发手机优化软件哪个好
  • 如何选网站建设公司网站免费下载安装
  • 如何做公司网站推广泉州排名推广
  • 公司网站建设需要哪些设备5000人朋友圈推广多少钱
  • 临漳seo整站排名平板电视seo优化关键词
  • net公司网站开发框架源代码网站建设策划方案
  • 网站的分类有哪些类型网络营销心得体会
  • 亚马逊虚拟主机做网站百度站长链接提交
  • 网站建设销售提点20个点网站seo技术能不能赚钱
  • 网站流量不够一呼百应推广平台