Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

添加奖品列表自动滚动的功能和修复一些BUG #25

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions product/src/lottery/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,11 @@ button:active {
transform: translateY(-50%);
}

.hidden {
display:none;
list-style-type:none;
}

.shine {
box-shadow: 0 0 15px 0 rgba(0, 255, 255, 0.5);
transform: scale(1.2);
Expand Down
18 changes: 14 additions & 4 deletions product/src/lottery/prizeList.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ const DEFAULT_MESS = [
let lastDanMuList = [];

let prizeElement = {},
lasetPrizeIndex = 0;
lasetPrizeIndex = 0,
skipPrizeIndex = 0;
class DanMu {
constructor(option) {
if (typeof option !== "object") {
Expand Down Expand Up @@ -155,6 +156,8 @@ function setPrizes(pri) {

function showPrizeList(currentPrizeIndex) {
let currentPrize = prizes[currentPrizeIndex];
let readySkipCount = currentPrizeIndex - 6;
skipPrizeIndex = readySkipCount;
if (currentPrize.type === defaultType) {
currentPrize.count === "不限制";
}
Expand All @@ -163,9 +166,10 @@ function showPrizeList(currentPrizeIndex) {
if (item.type === defaultType) {
return true;
}
htmlCode += `<li id="prize-item-${item.type}" class="prize-item ${
item.type == currentPrize.type ? "shine" : ""
}">
htmlCode += `<li id="prize-item-${item.type}" class="prize-item
${item.type == currentPrize.type ? "shine" : ""}
${--readySkipCount > 0 ? "hidden" : ""}
">
<span></span><span></span><span></span><span></span>
<div class="prize-img">
<img src="${item.img}" alt="${item.title}">
Expand Down Expand Up @@ -244,6 +248,12 @@ let setPrizeData = (function () {
prizeElement.prizeText.textContent = currentPrize.title;

lasetPrizeIndex = currentPrizeIndex;

if (skipPrizeIndex > 0) {
let newPrize = prizes[skipPrizeIndex--];
let newBox = document.querySelector(`#prize-item-${newPrize.type}`);
newBox.classList.remove("hidden");
}
}

if (currentPrizeIndex === 0) {
Expand Down