d
This commit is contained in:
@@ -47,6 +47,7 @@
|
||||
|
||||
let scrollLock = false;
|
||||
let handlerId = null;
|
||||
let currentVideo = null;
|
||||
const ul = document.querySelector("ul");
|
||||
|
||||
// 懒加载实例(只初始化一次)
|
||||
@@ -104,6 +105,8 @@
|
||||
video.loop = true;
|
||||
video.playsInline = true;
|
||||
|
||||
video.author = `https://www.kuaishou.com/profile/${item.author.id}`
|
||||
|
||||
const posterUrl = item.photo.animatedCoverUrl || item.photo.coverUrl;
|
||||
video.poster = posterUrl;
|
||||
video.dataset.src = item.photo.photoUrls[0]?.url || "";
|
||||
@@ -153,19 +156,26 @@
|
||||
*/
|
||||
document.onclick = toggleScroll;
|
||||
document.onkeydown = (e) => {
|
||||
if (e.keyCode === 32) {
|
||||
const { keyCode } = e
|
||||
|
||||
if (keyCode === 79) {
|
||||
e.preventDefault();
|
||||
if (currentVideo) open(currentVideo.author)
|
||||
}
|
||||
|
||||
if (keyCode === 32) {
|
||||
e.preventDefault();
|
||||
toggleScroll();
|
||||
}
|
||||
if (e.keyCode === 82) {
|
||||
if (keyCode === 82) {
|
||||
e.preventDefault();
|
||||
scrollSpeed = defaultSpeed;
|
||||
}
|
||||
if (e.keyCode === 40) {
|
||||
if (keyCode === 40) {
|
||||
e.preventDefault();
|
||||
scrollSpeed += 2;
|
||||
}
|
||||
if (e.keyCode === 38) {
|
||||
if (keyCode === 38) {
|
||||
e.preventDefault();
|
||||
scrollSpeed > defaultSpeed && (scrollSpeed -= 2);
|
||||
}
|
||||
@@ -195,6 +205,8 @@
|
||||
ul.addEventListener("mouseenter", (e) => {
|
||||
if (e.target.tagName === "VIDEO") {
|
||||
e.target.readyState >= 2 && e.target.play();
|
||||
currentVideo = e.target
|
||||
console.log("currentVideo: ", currentVideo);
|
||||
}
|
||||
}, true);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user