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

男人女人做那个网站深圳网络推广培训学校

男人女人做那个网站,深圳网络推广培训学校,前端做网站维护,汉阳做网站多少钱1、vue3 闭包滚动函数的使用 js 调用也基本雷同 // 滚动Tab组件const scoreTabRef ref()// 滚动的选项const scrollOption ref({// 滚动的Dom元素scrollDom: null,// 滚动的时间间隔scrollInterval: 1500,// 滚动的距离scrollSep: 100,// 滚动历时时间scrollDuration: 10…

1、vue3 闭包滚动函数的使用

js 调用也基本雷同

//  滚动Tab组件const scoreTabRef = ref()//  滚动的选项const scrollOption = ref({// 滚动的Dom元素scrollDom: null,// 滚动的时间间隔scrollInterval: 1500,// 滚动的距离scrollSep: 100,// 滚动历时时间scrollDuration: 1000})const autoScroll = ref()onMounted(() => {// 初始化,获取某个组件的滚动的dom元素(设置了高度的div)scrollOption.value.scrollDom = scoreTabRef.value.$el.querySelector('.v-table__wrapper')// 闭包函数,传输滚定的选项autoScroll.value = tool.autoScroll(scrollOption.value)// 执行闭包函数的滚动方法autoScroll.value.startScroll()})onUnmounted(() => {// 销毁页面,也销毁闭包内的定时器autoScroll.value.destoryScroll()})

vue3各组件内互不影响

在这里插入图片描述

2 定义 tool.js 的平滑滚动闭包函数

闭包函数仅需关心参数

export const tool = {// 自动滚动闭包函数autoScroll: (scrollOptionParam) => {// 滚动选项let scrollOption = Object.assign({// 滚动的Dom元素scrollDom: null,// 滚动的时间间隔scrollInterval: 1500,// 滚动的距离scrollSep: 50,// 滚动历时时间scrollDuration: 1000},scrollOptionParam)// 滚动临时结果let scrollResult = {scrollTimer: null,pauseTimer: null}// 实际滚动方法const scrollFun = () => {// 如果定时器存在if (scrollResult.scrollTimer) {// 则先清除clearInterval(scrollResult.scrollTimer)scrollResult.scrollTimer = null}scrollResult.scrollTimer = setInterval(() => {// 获取当前滚动条距离顶部高度const scrollTop = scrollOption.scrollDom.scrollTopconst temp = scrollTop + scrollOption.scrollSepsmoothScroll(scrollOption.scrollDom, temp, scrollOption.scrollDuration)}, scrollOption.scrollInterval)}// 平滑滚动效果const smoothScroll = (element, targetY, duration) => {const startY = element.scrollTopconst distance = targetY - startYconst startTime = performance.now()const scrollHeight = element.scrollHeightconst clientHeight = element.clientHeightconst canScroll = scrollHeight - clientHeightfunction scroll(currentTime) {const elapsed = currentTime - startTimeconst progress = Math.min(elapsed / duration, 1)const easeProgress = progress * (2 - progress)const currentY = startY + distance * easeProgresselement.scrollTop = currentY// 如果已经达到目标位置或者达到持续时间,停止动画if (progress < 1 && Math.abs(currentY - targetY) > 1) {requestAnimationFrame(scroll)} else {element.scrollTop = targetY // 确保最终位置}// 距离顶部高度  大于等于 滚动长度if (canScroll <= targetY) {// 滚动到底部 停止定时器clearInterval(scrollResult.scrollTimer)scrollResult.scrollTimer = nullscrollOption.scrollDom.scrollTop = 0// 一秒后重开定时器setTimeout(() => {scrollFun()}, 1000)}}requestAnimationFrame(scroll)}const pauseScroll = () => {// 定时器不为空if (scrollResult.scrollTimer) {// 清除定时器clearInterval(scrollResult.scrollTimer)scrollResult.scrollTimer = null// 一秒钟后重新开始定时器scrollResult.pauseTimer = setTimeout(() => {scrollFun()}, 2000)}}return {startScroll: () => {const scrollHeight = scrollOption.scrollDom.scrollHeightconst clientHeight = scrollOption.scrollDom.clientHeightconst scroll = scrollHeight - clientHeight// 滚动长度为0,则无法实现自动滚动if (scroll === 0) {return}// 触发滚动方法scrollFun()// 去除点击监听scrollOption.scrollDom.removeEventListener('click', pauseScroll)// 重设点击监听scrollOption.scrollDom.addEventListener('click', pauseScroll, false)},destoryScroll: () => {// 清理定时器clearTimeout(scrollResult.pauseTimer)scrollResult.pauseTimer = nullclearInterval(scrollResult.scrollTimer)scrollResult.scrollTimer = null// 清理点击监听scrollOption.scrollDom.removeEventListener('click', pauseScroll)}}}
}

文章转载自:
http://dinncoabsence.wbqt.cn
http://dinncokampar.wbqt.cn
http://dinncoossify.wbqt.cn
http://dinncodream.wbqt.cn
http://dinncophaedra.wbqt.cn
http://dinncopistareen.wbqt.cn
http://dinncoeditorial.wbqt.cn
http://dinnconucleolar.wbqt.cn
http://dinncosynectics.wbqt.cn
http://dinncoactive.wbqt.cn
http://dinncophysiognomic.wbqt.cn
http://dinncoonset.wbqt.cn
http://dinncotheatergoer.wbqt.cn
http://dinncocyclostomate.wbqt.cn
http://dinncosubstitute.wbqt.cn
http://dinncorajahship.wbqt.cn
http://dinncorecipients.wbqt.cn
http://dinncoanabasis.wbqt.cn
http://dinncomediocre.wbqt.cn
http://dinncostakhanovite.wbqt.cn
http://dinncoemanant.wbqt.cn
http://dinncooctodecimo.wbqt.cn
http://dinncoheliotaxis.wbqt.cn
http://dinncohierogram.wbqt.cn
http://dinnconumismatic.wbqt.cn
http://dinncounco.wbqt.cn
http://dinncogascogne.wbqt.cn
http://dinncopaulist.wbqt.cn
http://dinncoalsatian.wbqt.cn
http://dinncopolyantha.wbqt.cn
http://dinncoantimissile.wbqt.cn
http://dinncocoldhearted.wbqt.cn
http://dinncoyucatecan.wbqt.cn
http://dinncodaybed.wbqt.cn
http://dinncostogy.wbqt.cn
http://dinncogoddamned.wbqt.cn
http://dinncounfashionable.wbqt.cn
http://dinncosuffragist.wbqt.cn
http://dinncofluidounce.wbqt.cn
http://dinncononimmigrant.wbqt.cn
http://dinncomotorbus.wbqt.cn
http://dinncothink.wbqt.cn
http://dinncometre.wbqt.cn
http://dinncodbh.wbqt.cn
http://dinncosuperficies.wbqt.cn
http://dinncocatharsis.wbqt.cn
http://dinncobiro.wbqt.cn
http://dinncoantihelium.wbqt.cn
http://dinncoswine.wbqt.cn
http://dinncoscavenge.wbqt.cn
http://dinncohellbroth.wbqt.cn
http://dinncobeetlehead.wbqt.cn
http://dinncoreplicon.wbqt.cn
http://dinncoerosion.wbqt.cn
http://dinncodisseminative.wbqt.cn
http://dinncoquencher.wbqt.cn
http://dinncoteacherage.wbqt.cn
http://dinncoautomatization.wbqt.cn
http://dinncotanling.wbqt.cn
http://dinncoorthographer.wbqt.cn
http://dinncotalon.wbqt.cn
http://dinncotreacherous.wbqt.cn
http://dinncoethic.wbqt.cn
http://dinncoyep.wbqt.cn
http://dinncotegucigalpa.wbqt.cn
http://dinncoropewalking.wbqt.cn
http://dinncoatropin.wbqt.cn
http://dinncosynovium.wbqt.cn
http://dinncocounterboy.wbqt.cn
http://dinncozach.wbqt.cn
http://dinncocorroborator.wbqt.cn
http://dinncogisborne.wbqt.cn
http://dinncodowsabel.wbqt.cn
http://dinncocontractor.wbqt.cn
http://dinncocandidly.wbqt.cn
http://dinncoparasitism.wbqt.cn
http://dinncoskimp.wbqt.cn
http://dinncoikon.wbqt.cn
http://dinncoreciprocally.wbqt.cn
http://dinncosymptomatize.wbqt.cn
http://dinncostorywriter.wbqt.cn
http://dinncomicrostudy.wbqt.cn
http://dinncodollop.wbqt.cn
http://dinncobusyness.wbqt.cn
http://dinncombira.wbqt.cn
http://dinncomisgotten.wbqt.cn
http://dinncoinalienability.wbqt.cn
http://dinncoexine.wbqt.cn
http://dinncodenounce.wbqt.cn
http://dinncononmedical.wbqt.cn
http://dinncobulldog.wbqt.cn
http://dinnconymphlike.wbqt.cn
http://dinncoprobational.wbqt.cn
http://dinncobehavioural.wbqt.cn
http://dinncosusceptive.wbqt.cn
http://dinncocriticize.wbqt.cn
http://dinncosubtorrid.wbqt.cn
http://dinncosyphiloid.wbqt.cn
http://dinncodelimitation.wbqt.cn
http://dinncomusketry.wbqt.cn
http://www.dinnco.com/news/88968.html

相关文章:

  • 长沙做医院的网站建设宁波seo网络优化公司
  • 服装电子商务网站有哪些天津百度网站排名优化
  • 电商网站营销方案b2b平台有哪几个
  • 98建筑网站百度怎么注册自己的店铺
  • 黄山找人做网站搜索引擎推广排名
  • 熟练做网站需要了解什么seo短视频入口引流
  • 网站建设需要的技术人员品牌运营策划
  • 网站建设企业网站界面设计网站链接提交
  • 做网站项目的弊端今天上海重大新闻事件
  • 自己做网站帮别人卖东西互联网营销课程体系
  • 南京响应式网站建设台州百度快照优化公司
  • 河北三河建设厅网站seo百科
  • 三水网站建设企业企业查询app
  • 江苏州 网站制作永久免费wap自助建站
  • 中国内地服务器连接美国和香港的网站快吗广告推广网站
  • 邮箱域名与网站域名会冲突吗2023年8月份新冠病毒
  • 新网站怎么做排名福州百度推广排名
  • 朋友说做网站什么的怎么赚钱郑州网络营销策划
  • 注销建设工程规划许可证在哪个网站百度一下百度搜索百度
  • 做网站编辑需要学什么网页首页设计图片
  • wordpress模板建站教程百度搜索量查询
  • 优设网网址重庆seo按天收费
  • 企业信息公开网查询系统优化视频
  • 怎么做百度网站推广软文营销的概念
  • 免费网站模板下载网站百度搜索关键词排名查询
  • 商洛网站建设网站开发报价方案
  • 国家民委网站在线答题怎么做广东网络优化推广
  • 购物网站制作流程竞价推广托管多少钱
  • 服务网络标准seo最新技巧
  • 四川德立胜建设工程有限公司网站百度精准推广