新增自定义列表

This commit is contained in:
lyswhut
2020-05-16 19:21:21 +08:00
parent eed8b36dc1
commit afc3f48f51
39 changed files with 1486 additions and 309 deletions
+30 -14
View File
@@ -55,15 +55,8 @@ const easeInOutQuad = (t, b, c, d) => {
t--
return (-c / 2) * (t * (t - 2) - 1) + b
}
/**
* 设置滚动条位置
* @param {*} element 要设置滚动的容器 dom
* @param {*} to 滚动的目标位置
* @param {*} duration 滚动完成时间 ms
* @param {*} fn 滚动完成后的回调
*/
export const scrollTo = (element, to, duration = 300, fn = () => {}) => {
if (!element) return
const handleScroll = (element, to, duration = 300, fn = () => {}) => {
if (!element) return fn()
const start = element.scrollTop || element.scrollY || 0
let cancel = false
if (to > start) {
@@ -99,6 +92,31 @@ export const scrollTo = (element, to, duration = 300, fn = () => {}) => {
cancel = true
}
}
/**
* 设置滚动条位置
* @param {*} element 要设置滚动的容器 dom
* @param {*} to 滚动的目标位置
* @param {*} duration 滚动完成时间 ms
* @param {*} fn 滚动完成后的回调
* @param {*} delay 延迟执行时间
*/
export const scrollTo = (element, to, duration = 300, fn = () => {}, delay) => {
let cancelFn
let timeout
if (delay) {
let scrollCancelFn
cancelFn = () => {
timeout == null ? scrollCancelFn && scrollCancelFn() : clearTimeout(timeout)
}
timeout = setTimeout(() => {
timeout = null
scrollCancelFn = handleScroll(element, to, duration, fn, delay)
}, delay)
} else {
cancelFn = handleScroll(element, to, duration, fn, delay)
}
return cancelFn
}
/**
* 检查路径是否存在
@@ -184,7 +202,7 @@ export const objectDeepMerge = (target, source) => {
* @param {*} setting
*/
export const updateSetting = (setting, version) => {
const defaultVersion = '1.0.24'
const defaultVersion = '1.0.26'
if (!version) {
if (setting) {
version = setting.version
@@ -203,10 +221,8 @@ export const updateSetting = (setting, version) => {
list: {
isShowAlbumName: true,
isShowSource: true,
scroll: {
enable: true,
locations: {},
},
prevSelectListId: 'default',
isSaveScrollLocation: true,
},
download: {
savePath: path.join(os.homedir(), 'Desktop'),
+2 -2
View File
@@ -52,7 +52,7 @@ const assertStopCallback = element => {
const handleKeyDown = event => {
if (assertStopCallback(event.target)) return
event.preventDefault()
// event.preventDefault()
let keys = eventModifiers(event)
switch (event.key) {
case 'Control':
@@ -61,7 +61,7 @@ const handleKeyDown = event => {
case 'Shift':
break
default:
keys.push(event.key)
keys.push(event.key.toLowerCase())
break
}
handleEvent('down', event, keys)
+2 -1
View File
@@ -109,7 +109,8 @@ export const httpFetch = (url, options = { method: 'get' }) => {
export const cancelHttp = requestObj => {
// console.log(requestObj)
if (!requestObj) return
console.log('cancel:', requestObj.href)
console.log('cancel:', requestObj)
if (!requestObj.abort) return
requestObj.abort()
}