<template>
<div id="wrapper" ref="wrapper" :class="className">
<div class="scroller" :class="{'scroll-static': showIcon && !scrolling, 'no-scroll': !up && !down}" ref="scroller">
<div class="scroll-head-mask" v-if="up" :style="headbg"></div>
<div v-if="up" :style="textColor" class="scroll-head tc">
<p v-show="showBeforeText">松开刷新</p>
<p :class="{'no-fixation': !shadowIcon}" >
<span class="shadow-icon" :style="shadowColor"></span>
<span class="pull-icon" ref="pullIcon"></span>
</p>
<span class="size10">上次更新时间: {{ headText }}</span>
</div>
<slot>
<!-- <div class="tc">暂无数据</div> -->
</slot>
<div class="scroll-foot" v-if="down">
<div v-show="!allLoaded">{{ footText }}</div>
<div v-show="allLoaded">全部加载完成</div>
</div>
</div>
</div>
</template>
<script>
/**
* @author liyulin
* @description 下拉刷新,上拉加载组件
* @date 2018-7-4
* @param value Object 控制关闭刷新,IScroll重新计算滚动高度
* @param up Boolean 是否需要下拉刷新
* @param down Boolean 是否需要上拉刷新
* @param allLoaded Boolean 是否全部加载完毕
* @param refreshColor Object 自定义头部样式
* @param className String wrapper类名
* @param getScrilling Boolean 滚动时是否需要scroll实例信息
* @event refresh 下拉刷新事件
* @event getMore 上拉加载更多
* @method scrollIntoView 使内容滚动到视图区域,同原生srollIntoView,默认参数true
*/
import IScroll from '@/assets/js/iscroll-probe'
import { formatDate } from '@/assets/js/utils'
export default {
name: 'NfScroll',
props: {
value: {
type: [Boolean, Number],
default: true
},
up: {
type: [Boolean, Number],
default: false
},
down: {
type: [Boolean, Number],
default: false
},
allLoaded: {
type: [Boolean, Number],
default: false
},
refreshColor: {
type: Object,
default() {
return {
loadBgColor: '#F5F5F5', // 背景色
textColor: '#666', // 文本颜色
cirCleColor: '#d2d2d2' // 跳跃阴影颜色
}
}
},
className: String,
getScrilling: Boolean
},
data() {
return {
myScroll: null, // IScroll实例
observer: null, // 观察者实例
headText: formatDate(new Date(), 'yyyy-MM-dd hh:mm:ss'), // 头部提示
footText: '上拉加载更多', // 底部提示
timer: 0, // 刷新时请求的计时器
minTimer: 1000, // 刷新最少延时
maxTimer: 29000, // 刷新最大延时(实际是30秒)
showIcon: false, // 下拉刷新动画图标
scrolling: false, // 滚动时
showBeforeText: false, // 提示文字
shadowIcon: true, // 阴影图标
recordOldHeight: '0' // 记录下旧的高度,避免重复触发回调函数
}
},
computed: {
// 计算头部样式
headbg() {
const r = this.refreshColor && this.refreshColor.loadBgColor
return r
? `background-color: ${this.refreshColor.loadBgColor}`
: 'background-color: #F5F5F5'
},
// 头部文字样式
textColor() {
var textColor = '#666'
if (this.refreshColor && this.refreshColor.textColor) {
if (this.refreshColor.textColor) {
textColor = this.refreshColor.textColor
}
}
textColor = 'color:' + textColor + ';' + this.headbg
return textColor
},
// icon样式
shadowColor() {
let bc = ''
const jumpBc = this.CONSTS.jumpBcColor
this.refreshColor &&
this.refreshColor.cirCleColor &&
(bc = this.refreshColor.cirCleColor)
!this.showIcon && (bc = jumpBc === bc ? '#062db2' : '#999')
return `background-color: ${bc}`
}
},
watch: {
value(a) {
if (!a) {
const _this = this
let timer = this.minTimer - (+new Date() - +new Date(this.timer))
timer = timer > 0 ? timer : 800
setTimeout(() => {
_this.headText = formatDate(new Date(), 'yyyy-MM-dd hh:mm:ss')
_this.footText = '上拉加载更多'
_this.$store.commit('SET_LOADING_STATE', '1')
_this.shadowIcon = true
setTimeout(() => {
_this.showIcon = a
}, 600)
}, timer)
}
}
},
mounted() {
this.initLoad()
this.mutaionObserver()
},
beforeDestroy() {
this.myScroll && this.myScroll.destroy && this.myScroll.destroy()
this.myScroll = null
if (this.observer) {
this.observer.disconnect()
this.observer.takeRecords()
this.observer = null
}
},
methods: {
mutaionObserver() {
const MObserver = window.MutationObserver || window.WebKitMutationObserver || window.MozMutationObserver
if (!MObserver) {
console.warn('此设备暂不支持MutationObserver属性')
return
}
const scroller = this.$refs.scroller
// 低版本(如android4.3及以下)无MutationObserver属性时,节点的添加删除,需要刷新isroll的页面,需自行处理
this.observer = new MObserver(mutationList => {
const height = getComputedStyle(scroller).getPropertyValue('height')
if (height !== this.recordOldHeight) {
this.recordOldHeight = height
this.myScroll.refresh()
}
})
this.observer.observe(scroller, {
childList: true,
subtree: true,
attributeFilter: ['client-height']
})
},
initLoad() {
let that = this
const options = {
mouseWheel: true, // 是否支持鼠标滚轮
scrollX: false, // 是否显示横向滚动条
bounce: this.up || this.down, // 是否弹跳效果
probeType: 2, // 为2的时候,会在屏幕滑动的过程中实时的派发scroll,为3,实时的派发scroll事件,可能会卡顿
preventDefault: false // 不阻止默认事件,解决ios点击移动不触发事件
}
// 兼容andirod系统内核也可以滚动
if (this.CONSTS.isAndroidSys) {
Object.assign(options, {
preventDefault: true,
preventDefaultException: {
tagName: /^(SPAN|I|P|B|UL|LI|H1|H2|DIV|A|INPUT|TEXTAREA|BUTTON|SELECT|IMG)$/
}
})
}
// 初始化IScroll
this.myScroll = new IScroll(this.$refs.wrapper, options)
const wrapper = this.$refs.wrapper
const scroller = this.$refs.scroller
const pullIcon = this.$refs.pullIcon
this.myScroll.on('beforeScrollStart', () => {
this.myScroll.y === 0 && this.showIcon && this.myScroll._translate(0, 80)
})
// 开始滚动
this.myScroll.on('scrollStart', () => {
if (!this.myScroll) return
this.scrolling = true
this.myScroll.refresh()
})
// 滚动时
this.myScroll.on('scroll', () => {
if (!this.myScroll) return
this.getScrilling && this.$emit('getScrollData', this.myScroll)
const y = this.myScroll.y
if (that.up && y > 0) {
if (!this.showIcon && y >= 80) {
that.showBeforeText = true
} else {
that.showBeforeText = false
const bottom = parseFloat(getComputedStyle(pullIcon).getPropertyValue('bottom'))
bottom <= 0 && (pullIcon.style.bottom = -20 + (y / 4) + 'px')
}
}
const fh = scroller.clientHeight - wrapper.clientHeight + y
if (
that.down && y < 0 && fh < 0 &&
that.footText === '上拉加载更多' &&
!that.allLoaded
) {
that.footText = '正在加载...'
that.$emit('input', true)
that.$store.commit('SET_LOADING_STATE', '0')
setTimeout(() => {
that.$emit('getMore')
}, 1000)
that.maxDelayed()
}
})
// 滚动结束
this.myScroll.on('scrollEnd', () => {
if (!this.myScroll) return
this.getScrilling && this.$emit('getScrollData', this.myScroll)
this.myScroll.y >= 0 && !this.showBeforeText && (this.scrolling = false)
})
// 触摸结束
this.$refs.wrapper.addEventListener('touchend', () => {
if (!this.myScroll) return
if (this.up && this.showBeforeText && !this.showIcon) {
this.showBeforeText = false
this.showIcon = true
this.shadowIcon = false
this.timer = new Date()
this.$emit('input', true)
setTimeout(() => {
this.$emit('refresh')
this.$store.commit('SET_LOADING_STATE', '0')
this.maxDelayed()
}, 20)
}
this.myScroll.y >= 0 && !this.showBeforeText && (this.scrolling = false)
})
},
// 请求最大延时
maxDelayed() {
setTimeout(() => {
this.$emit('input', false)
this.$store.commit('SET_LOADING_STATE', '1')
}, this.maxTimer)
},
// 滚动内容到视图区域,外层调用,勿删
scrollIntoView(p = true) {
if (p) {
this.myScroll.scrollTo(0, 0)
} else {
this.$nextTick(() => {
this.myScroll.refresh()
this.myScroll.scrollTo(0, this.myScroll.maxScrollY, 200)
})
}
},
// 刷新icroll
refresh() {
this.$nextTick(() => {
this.myScroll.refresh()
})
}
}
}
</script>
<style lang="scss" scoped>
#wrapper {
height: 100%;
overflow: hidden;
.scroller {
max-width: 100%; // 解决第一次安装,部分页面可以左右滑动的问题
width: 100%;
min-height: calc(100% + 1.5px);
position: relative;
display: flex;
flex-flow: column;
&.no-scroll {
min-height: 100%;
}
&.scroll-static {
transform: translate(0px, 80px) translateZ(0px) !important;
transition-duration: 400ms !important;
.no-fixation {
.pull-icon {
animation: jumps .8s linear infinite;
}
.shadow-icon {
border-radius: 50%;
animation: jump-b .8s linear infinite;
}
}
}
}
.scroll-head {
position: absolute;
top: -5rem;
left: 0;
right: 0;
height: 5rem;
display: flex;
flex-direction: column;
justify-content: center;
p {
width: 100%;
height: 3.75rem;
position: relative;
display: flex;
justify-content: center;
overflow: hidden;
.pull-icon {
display: inline-block;
box-sizing: border-box;
width: 1.625rem;
height: 1.5625rem;
background: url(../assets/img/scroll-icon.png) no-repeat center;
background-size: 1.625rem 1.5625rem;
position: absolute;
bottom: -1.25rem;
animation: jump-one .6s linear 1;
}
.shadow-icon {
display: inline-block;
width: 1.875rem;
height: .25rem;
position: absolute;
bottom: 0;
}
}
}
.scroll-head-mask {
height: 50vh;
position: absolute;
top: -50vh;
left: 0;
right: 0;
background-color: #ccc;
}
.scroll-foot {
> div {
height: 35px;
text-align: center;
line-height: 35px;
color: #bdbdbd;
}
}
}
@keyframes jump-one {
from {
bottom: 19px;
}
to {
bottom: -1.25rem;
}
}
@keyframes jumps {
from {
bottom: 0px;
}
50% {
bottom: 28px;
}
to {
bottom: 0px;
}
}
@keyframes jump-b {
from {
width: 1.375rem;
}
50% {
width: .8rem;
}
to {
width: 1.375rem;
}
}
</style>
相关推荐
【RF】Receiver Function接收函数:从理论到实践的深度解析
本文深入解析地震学中的接收函数(Receiver Function, RF)技术,从理论原理到实践操作。文章将RF比作地球的“听诊器”,详细阐述了其通过反褶积剥离震源影响、揭示地下结构(如莫霍面)的核心机制,并提供了使用Python和rf库进行数据处理、计算、动校正与叠加的完整实战流程,同时探讨了其应用、局限性与常见问题的解决方案。
Vue常用插件汇总
分享一套阿里大牛整理的前端资料给大家,点击前端校招面试题精编解析大全即可获取[外链图片转存中…(img-wmj3LHAs-1712977961250)]既有适合小白学习的零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,基本涵盖了95%以上前端开发知识点,真正体系化![外链图片转存中…(img-uMrKd7zw-1712977961251)]由于文件比较大,这里只是将部分目录截图出来,每个节点里面都包含大厂面经、学习笔记、源码讲义、实战项目、讲解视频,并且会持续更新!
An AI compute of cities based on Distributed-Platform and Distributed-Databases(天池地铁流量预测)
摘要 在日益城市化的今天,城市居民出行问题逐渐成为衡量一个城市现代化能力的标准;城市出行方式多元化的同时,也对各交通系统的调度运营能力提出了更高的要求:如何提高运营效率,如何运用有限的安保力量进行有效的安检部署等问题一直在阻挠着城市交通的发展。 An AI compute of cities based on Distributed-Platform and Distributed-Databas...
vue3实现无缝滚动 列表滚动 vue3-seamlessscroll
vue3框架内的无缝滚动
安卓手机必备:Auto.js快手极速版自动刷视频避坑指南(含最新3.0脚本)
本文是一份安卓自动化工具Auto.js的全面实践指南,重点解析了如何搭建稳定运行环境、配置关键权限以及管理脚本。针对快手极速版等应用的自动化需求,文章详细介绍了设备选择、Auto.js版本对比、各品牌手机后台保活设置,并强调了脚本安全与调试技巧,帮助用户有效避坑,实现自动化任务的稳定执行。
NLP自然语言处理:神经网络语言模型(NNLM)
目录 一、传统语言模型 1.1 稀疏性 1.2泛化能力差 二、神经网络语言模型 2.1 前馈神经网络模型(FFLM) 2.2 循环神经网络模型(RNNLM) 2.2.1循环神经网络模型示例 2.2.2RNN语言模型训练过程 2.2.3RNN语言模型反向传播 2.2.4语言模型评估 语言模型的构建目的是为了对语言中的各要素的分布进行估计,具有较长的研究历史和广泛...
基于vue.js网页滚动条VScroll组件|vue自定义模拟滚动条
基于Vue.js桌面端自定义美化滚动条组件VScroll。 VScroll 最近捣鼓的一款基于vue.js构建的pc端自定义模拟滚动条组件。拥有完美顺滑的原生滚动条体验!支持自定义是否原生滚动条、自动隐藏、滚动条大小及颜色等功能。 vscroll组件在开发之初有参考饿了么el-scrollbar滚动条组件。 组件本着极简原则,使用起来非常简单。只需 <v-scroll>...</v-scroll> 即可快速生成一个漂亮的替换原生滚动条。 提供非常简单的参数
别再手动算频谱了!用这个在线FFT工具,5分钟搞定JSON/CSV数据分析
本文介绍了一款高效的在线FFT工具,帮助用户快速分析JSON/CSV格式的时域数据,5分钟内完成频谱分析。通过傅里叶变换(FFT)算法,大幅提升计算效率,解决传统手动计算的痛点,适用于工业振动分析、设备故障诊断等场景。
css列名不动_利用js+css+html实现固定table的列头不动
话不多说,跟这小编来一起看下吧1、CSS#scroll_head {position: absolute;display: none;}2、Javascript//该函数在上面一个table数据加载完成后调用//把表头的宽度设置到会滚动的页头去var copyWidth = function () {var b = $('#data_tbody').prev().find('t...
【OpenClaw从入门到精通】第23篇:OpenClaw办公自动化实战—报表生成+文档批量处理+跨系统同步(2026实操进阶版)
本文聚焦OpenClaw在办公自动化场景的进阶应用,针对职场中高频且重复的报表生成、文档批量处理、跨系统数据同步三大痛点,提供从环境搭建、原理讲解到完整代码实现的全流程实操指南。方案基于Python生态工具链(pandas、Playwright、PyPDF2等)与OpenClaw的低代码编排能力,兼顾新手入门与进阶提升——新手可直接复用代码快速落地,进阶读者可学习流程编排逻辑进行二次开发。所有案例均基于真实办公场景设计,部分虚拟场景已明确标注,代码经本地环境验证可复现。
30、模态组合规则在振动分析中的应用
本文详细介绍了模态组合规则在振动分析中的应用,重点讨论了绝对峰值叠加法(SRSS)和完全二次组合(CQC)的理论基础、应用场景及优缺点。通过具体工程实例,展示了模态组合规则在地震载荷下结构响应分析中的实际效果,并提供了应用步骤和注意事项,为结构设计和安全评估提供了科学依据。
vue2,vue3项目无限滚动组件,支持滑动
把item结构出来然后在设计样式,使用参考类似饿了吗的table。threshold:判断是否需要滚动的项目数量阈值。stepTime:每一步滚动的时间间隔(毫秒)stepHeight:垂直滚动时每一步的高度。stepWidth:水平滚动时每一步的宽度。containerHeight:容器的高度。containerWidth:容器的宽度。fadeInOut:是否启用淡入淡出效果。horizontal:是否水平滚动。items:项目数组。
【雕爷学编程】MicroPython手册之 Teensy 4.1 实时时钟 (RTC)
在类的初始化函数中,定义了用于控制I2C总线的i2c对象和RTC模块的I2C地址。接着,使用该引脚初始化了一个Pin对象。它还提供了8个串口,3个SPI端口,3个I2C端口,2个I2S/TDM数字音频端口,3个CAN总线(其中一个支持CAN FD),以及一个SDIO(4位数据)原生SD卡端口12。2、内存:Teensy 4.1配备了1024 KB的RAM(其中512 KB是紧密耦合的),8 MB的Flash(其中64 KB用于恢复和EEPROM模拟),以及两个位置可以选择添加更多的QSPI内存芯片。
Vue中使用滚动组件iscroll
首先安装iscroll npm install iscroll 创建scroll组件 <template> <div id="wrapper" ref="wrapper"> <slot></slot> </div> </template> <script> import IScroll from 'iscroll/build/iscroll-probe' //专业版本可以监听滚动的细节 export de
lwip-2.0.3
lwip是瑞典计算机科学院(SICS)的Adam Dunkels 开发的一个小型开源的TCP/IP协议栈。实现的重点是在保持TCP协议主要功能的基础上减少对RAM 的占用。
WINCC7.3破解文件
WINCC7.3硬件够破解文件,有需要的下载!WINCC7.3硬件够破解文件,有需要的下载!
iScroll的相关使用
1.简介 iScroll是一个高性能,资源占用少,无依赖,多平台的javascript滚动插件。 iScroll 2.使用 2.1 使用场景 网易音乐详情页,下拉滚动数据的时候,图片放大 默认状态 放大后的效果 2.2 使用 2.2.1 安装 npm install iscroll --save 2.2.2 代码实现 封装滚动组件 <template> <div id="wrapper" ref="wrapper"> <slot><
LinePhone3.2.7(android端最新版本) sip客户端
SIP客户端For android:LinePhone3.2.7(最新版本),官网地址:http://www.linphone.org/
Vue scroll组件,实现数据加载更多,防抖,刷新
Vue 组件scroll,实现加载更多,防抖,刷新 (该组件利用到了iscroll) 实现思路 利用iscroll插件实现可滚动的功能,然后利用iscroll的api(myScroll.refresh())去进行刷新滚动条,得到刷新后的滚动条高度。vue里有个nextTick的方法,作用是等dom渲染完执行回调函数,利用这个作用可以在加载完数据并且渲染成功后才能进行加载请求更多的数据,优化项目。为...
全球国家地区城市数据
MySQL全球国家地区城市数据报。。。。。。。。。。。。
vue中的滚动效果: better-scroll
vue中的滚动效果: better-scroll
BetterScroll Movable 可移动区域插件完全指南:从配置到源码原理
Movable 是 BetterScroll 官方插件体系中用于构建"可移动区域"(Movable Area)的解决方案,它让内容小于容器(wrapper)时仍能在容器内自由拖动、定位,并提供了 `putAt` API 精确控制内容的停留位置。本文以 `@better-scroll/movable` 的[官方中文文档](https://link.gitcode.com/i/206f435d0bfd
滚动列表组件 vue-seamless-scroll
【代码】滚动列表组件 vue-seamless-scroll。
史上最全vue滚动列表组件(结合多种业务场景)-解决VueSeamlessScroll多个痛点问题
2.VueSeamlessScroll 不兼容滚动至最后一条返回第一条。1.VueSeamlessScroll 无缝滚动点击事件不生效。
vue 内容滚动组件
内容滚动组件,封装成一个vue组件了
iscroll插件使用
iScroll的版本 针对iScroll的优化。为了达到更高的性能,iScroll分为了多个版本。你可以选择最适合你的版本。 目前我们有以下版本: iscroll.js,这个版本是常规应用的脚本。它包含大多数常用的功能,有很高的性能和很小的体积。 iscroll-lite.js,精简版本。它不支持快速跳跃,滚动条,鼠标滚轮,快捷键绑定。但如果你所需要的是滚动(特别是在移动平台) iScroll 精...
Vue3 实现一个无缝滚动组件(支持鼠标手动滚动)
在日常开发中,经常遇到需要支持列表循环滚动展示,特别是在数据化大屏开发中,无缝滚动使用频率更为频繁,在jquery时代,我们常用的无缝滚动组件为liMarquee,在vue中已经有vue-seamless-scroll组件(通过Vue2实现,不支持鼠标手动滚动),但是在使用过程中,发现滚动后会存在点击事件失效的问题,并且产品提了个需求,需要支持鼠标手动滚动,也要支持自动滚动,于是痛定思痛,决定通过Vue3来实现该功能,该组件已经实现上传npm,可以直接安装使用,链接在文尾。
【Vue】无缝滚动组件
使用 vue3-seamless-scroll 插件,实现列表无缝滚动
滚动条插件vue-scroll
vuescroll 是一个基于vue.js 2.X虚拟滚动条, 它支持定制滚动条的样式,检测内容尺寸变化、能够使内容分页、支持上拉-刷新,下推加载等诸多特性。
Vue滚动组件终极指南:如何选择最适合的滚动解决方案
在Vue项目开发中,滚动效果是一个常见需求。本文将详细介绍几种主流的滚动解决方案,帮助开发者根据实际场景选择最适合的组件。选择合适的滚动组件需要考虑:1. 数据量大小2. 性能要求3. 功能需求4. 用户体验根据实际场景选择最适合的解决方案,能够大大提升开发效率和用户体验。
129




被折叠的 条评论
为什么被折叠?



