新增列表滚动条位置恢复

This commit is contained in:
lyswhut
2019-09-22 11:33:37 +08:00
parent bebf1906a2
commit f7267806df
5 changed files with 73 additions and 10 deletions
+24 -2
View File
@@ -44,7 +44,7 @@ export const decodeName = str => str.replace(/'/g, '\'')
export const scrollTo = (element, to, duration = 300, fn = function() {}) => {
if (!element) return
const start = element.scrollTop || element.scrollY
const start = element.scrollTop || element.scrollY || 0
const change = to - start
const increment = 10
if (!change) {
@@ -164,7 +164,7 @@ export const isChildren = (parent, children) => {
* @param {*} setting
*/
export const updateSetting = setting => {
const defaultVersion = '1.0.9'
const defaultVersion = '1.0.10'
const defaultSetting = {
version: defaultVersion,
player: {
@@ -175,6 +175,10 @@ export const updateSetting = setting => {
},
list: {
isShowAlbumName: true,
scroll: {
enable: true,
location: 0,
},
},
download: {
savePath: path.join(os.homedir(), 'Desktop'),
@@ -281,3 +285,21 @@ export const saveLrc = (filePath, lrc) => {
if (err) console.log(err)
})
}
/**
* 生成节流函数
* @param {*} fn
* @param {*} delay
*/
export const throttle = (fn, delay = 100) => {
let timer = null
let _args = null
return function(...args) {
_args = args
if (timer) return
timer = setTimeout(() => {
timer = null
fn.apply(this, _args)
}, delay)
}
}