Skip to content

Commit

Permalink
closed #7
Browse files Browse the repository at this point in the history
  • Loading branch information
linyisonger committed Oct 12, 2024
1 parent 9f30e0e commit 7de0f61
Show file tree
Hide file tree
Showing 128 changed files with 294 additions and 16 deletions.
184 changes: 168 additions & 16 deletions 078.你更喜欢谁.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@
<style>
.pk-container {
display: flex;
align-items: center;
justify-content: center;
flex-direction: column;
height: 100vh;
max-width: 400px;
width: 100%;
overflow: hidden;
user-select: none;
}

.pk-cards {
Expand All @@ -23,10 +25,11 @@

.pk-card {
flex: 1;
display: flex;
display: inline-flex;
align-items: center;
justify-content: center;
flex-direction: column;
position: relative;
}

.pk-card img {
Expand All @@ -41,29 +44,38 @@
padding: 0 20px;
}

.moveIn {
.leftCardMoveIn {
animation-name: leftCardMoveIn;
animation-duration: 0.5s;
animation-timing-function: ease-in-out;
animation-fill-mode: forwards;
}

.pk-card {
animation-name: leftCardMoveIn;
.leftCardMoveOut {
animation-name: leftCardMoveOut;
animation-duration: 0.5s;
animation-timing-function: ease-in-out;
animation-fill-mode: forwards;
}

.pk-card:last-child {
.rightCardMoveIn {
animation-name: rightCardMoveIn;
animation-duration: 0.5s;
animation-timing-function: ease-in-out;
animation-fill-mode: forwards;
}

.pk-vs {
animation-name: vsFadeMoveIn;
.rightCardMoveOut {
animation-name: rightCardMoveOut;
animation-duration: 0.5s;
animation-timing-function: ease-in-out;
animation-fill-mode: forwards;
}

.moveOut {
.pk-vs {
animation-name: vsFadeMoveIn;
animation-duration: 0.5s;
animation-timing-function: ease-in-out;
animation-fill-mode: forwards;
animation-direction: reverse;
}

.like-btn {
Expand All @@ -79,7 +91,14 @@
transform: translateX(0);
}
}

@keyframes leftCardMoveOut {
0% {
transform: translateX(0);
}
100% {
transform: translateX(-200px);
}
}
@keyframes rightCardMoveIn {
0% {
transform: translateX(200px);
Expand All @@ -88,6 +107,14 @@
transform: translateX(0);
}
}
@keyframes rightCardMoveOut {
0% {
transform: translateX(0);
}
100% {
transform: translateX(200px);
}
}

@keyframes vsFadeMoveIn {
0% {
Expand All @@ -99,22 +126,147 @@
transform: translateY(0);
}
}

.pk-btns {
margin-top: 20px;
display: flex;
justify-content: flex-end;
}
.confirm-btn {
display: inline-block;
padding: 20px 40px;
background-color: #3575cf;
color: azure;
border-radius: 50px;
cursor: pointer;
user-select: none;
}
.confirm-btn:active {
opacity: 0.7;
}

.pk-card.like::after {
position: absolute;
border: 10px solid #e13b1e;
content: "";
left: 0;
top: 0;
bottom: 0;
right: 0;
user-select: none;
}
.pk-card span {
position: absolute;
left: 12px;
bottom: 12px;
width: 20px;
color: #fff;
text-shadow: 2px 2px #000000;
}
</style>
</head>

<body>
<div class="pk-container">
<h2>你更喜欢哪个?</h2>
<div class="pk-cards">
<div class="pk-card moveIn">
<div class="pk-card leftCardMoveIn">
<img src="./assets/movie-poster/m-byxz.jpg" />
<span>xxx</span>
</div>
<div class="pk-vs moveIn">VS</div>
<div class="pk-card moveIn">
<div class="pk-vs">VS</div>
<div class="pk-card rightCardMoveIn">
<img src="./assets/movie-poster/m-dbs.jpg" />
<span>xxx</span>
</div>
</div>
<div class="pk-btns">
<div class="confirm-btn">确定</div>
</div>
</div>

<script type="module"></script>
<script type="module">
import { Randoms } from "https://gcore.jsdelivr.net/npm/@3r/tool/lib/randoms.js";
// 加载配置数据
fetch("./assets/stars/label.txt")
.then((res) => res.text())
.then((res) => {
let stars = [];
let label = res.split("\r\n").filter((a) => a);

stars = label.map((n) => {
let tmpArr = n.split("_");
return {
name: tmpArr[2],
img: `./assets/stars/${tmpArr[1]}.jpg`,
};
});

// 卡片元素
let cardDom = document.querySelectorAll(".pk-card");
// 随机抽取10条数据
let pkStars = Randoms.getDisorganizeArray(stars).slice(0, 10);
// 左/右卡片
let leftCardDom = cardDom.item(0);
let rightCardDom = cardDom.item(1);
let vsTextDom = document.querySelector(".pk-vs");
// 确认按钮
let confirmBtnDom = document.querySelector(".confirm-btn");

nextStar(leftCardDom);
nextStar(rightCardDom);
// 下一个明星
function nextStar(dom) {
let star = pkStars.shift();
let animName =
dom === leftCardDom ? "leftCardMove" : "rightCardMove";

dom.classList.add(`${animName}Out`);
dom.classList.remove(`${animName}In`);

if (!star) {
console.log("对比结束");
setTimeout(() => {
dom.remove();
vsTextDom.remove();
confirmBtnDom.remove();
document
.querySelector(".pk-card.like")
.classList.remove("like");
}, 0.5);
return;
}

setTimeout(() => {
let img = dom.querySelector("img");
let span = dom.querySelector("span");
img.setAttribute("src", star.img);
span.textContent = star.name;
dom.classList.add(`${animName}In`);
dom.classList.remove(`${animName}Out`);
}, 0.5);
}

leftCardDom.addEventListener("click", (ev) => {
rightCardDom.classList.remove("like");
leftCardDom.classList.add("like");
});

rightCardDom.addEventListener("click", (ev) => {
leftCardDom.classList.remove("like");
rightCardDom.classList.add("like");
});

confirmBtnDom.addEventListener("click", (ev) => {
if (leftCardDom.classList.contains("like")) {
nextStar(rightCardDom);
} else if (rightCardDom.classList.contains("like")) {
nextStar(leftCardDom);
}
});
console.log(cardDom, pkStars);
console.log(stars);
});
</script>
</body>
</html>
Binary file added assets/stars/baibaihe.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/stars/bailu.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/stars/caiwenjing.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/stars/chenshu.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/stars/chenyuqi.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/stars/chenzihan.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/stars/dengjiajia.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/stars/dilireba.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/stars/dongxuan.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/stars/gaolu.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/stars/gaoyuanyuan.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/stars/guanxiaotong.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/stars/gulinuozha.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/stars/hailu.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/stars/haiqing.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/stars/hanxue.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/stars/haolei.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/stars/huangshengyi.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/stars/huangyi.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/stars/hubingqing.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/stars/hujing.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/stars/huosiyan.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/stars/jialing.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/stars/jiangmengjie.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/stars/jiangqinqin.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/stars/jiangshuying.jpg
Binary file added assets/stars/jiangxin.jpg
Binary file added assets/stars/jiangyingrong.jpg
Binary file added assets/stars/jiangyiyan.jpg
Binary file added assets/stars/jiangyiyi.jpg
Binary file added assets/stars/jiaojunyan.jpg
Binary file added assets/stars/jiaqing.jpg
Binary file added assets/stars/jinchen.jpg
Binary file added assets/stars/jingtian.jpg
Binary file added assets/stars/jujingyi.jpg
Binary file added assets/stars/kanqingzi.jpg
126 changes: 126 additions & 0 deletions assets/stars/label.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
0_yangying_杨颖
1_dilireba_迪丽热巴
2_guanxiaotong_关晓彤
3_jialing_贾玲
4_libingbing_李冰冰
5_liushishi_刘诗诗
6_liutao_刘涛
7_liuyifei_刘亦菲
8_nini_倪妮
9_songjia_宋佳
10_songqian_宋茜
11_sunli_孙俪
12_tangyan_唐嫣
13_tongliya_佟丽娅
14_xienuo_谢娜
15_yangmi_杨幂
16_yangzi_杨紫
17_yaochen_姚晨
18_zhangziyi_章子怡
19_zhaoliying_赵丽颖
20_zhaolusi_赵露思
21_zhoudongyu_周冬雨
22_zhouxun_周迅
23_baibaihe_白百何
24_bailu_白鹿
25_caiwenjing_蔡文静
26_chenshu_陈数
27_chenyuqi_陈钰琪
28_chenzihan_陈紫函
29_dengjiajia_邓家佳
30_dongxuan_董璇
31_gaolu_高露
32_gaoyuanyuan_高圆圆
33_gulinuozha_古力娜扎
34_hailu_海陆
35_haiqing_海清
36_hanxue_韩雪
37_haolei_郝蕾
38_hubingqing_胡冰卿
39_hujing_胡静
40_huangshengyi_黄圣依
41_huangyi_黄奕
42_huosiyan_霍思燕
43_jiaqing_贾青
44_jiangshuying_江疏影
45_jiangmengjie_蒋梦婕
46_jiangqinqin_蒋勤勤
47_jiangxin_蒋欣
48_jiangyiyi_蒋依依
49_jiangyingrong_江映蓉
50_jiangyiyan_江一燕
51_jiaojunyan_焦俊艳
52_jinchen_金晨
53_jingtian_景甜
54_jujingyi_鞠婧祎
55_kanqingzi_阚清子
56_lamuyangzi_辣目洋子
57_lifeier_李菲儿
58_liqin_李沁
59_lisheng_李晟
60_lixirui_李溪芮
61_lixiaoran_李小冉
62_liyitong_李一桐
63_linyun_林允
64_liuhaocun_刘浩存
65_liuxijun_刘惜君
66_liuyan_柳岩
67_liuyun_刘芸
68_louyixiao_娄艺潇
69_lvyi_吕一
70_mali_马丽
71_masichun_马思纯
72_masu_马苏
73_mayili_马伊俐
74_maoxiaotong_毛晓彤
75_meiting_梅婷
76_mengmeiqi_孟美岐
77_qiwei_戚薇
78_qinhailu_秦海璐
79_qinlan_秦岚
80_rensuxi_任素汐
81_shenmengchen_沈梦辰
82_shenyue_沈月
83_shuchang_舒畅
84_songyi_宋轶
85_songzuer_宋祖儿
86_sunyi_孙怡
87_tansongyun_谭松韵
88_tanweiwei_谭维维
89_tangyixin_唐艺昕
90_tongyao_童瑶
91_wanqian_万茜
92_wanglikun_王丽坤
93_wangluodan_王珞丹
94_wangou_王鸥
95_wangxiaochen_王晓晨
96_wangziwen_王子文
97_wujinyan_吴谨言
98_wuqian_吴倩
99_wuxuanyi_吴宣仪
100_xingfei_邢菲
101_xulu_徐璐
102_yangchaoyue_杨超越
103_yangrong_杨蓉
104_yexuan_叶璇
105_yintao_殷桃
106_yinger_颖儿
107_yushuxin_虞书欣
108_yuanbingyan_袁冰妍
109_yuanquan_袁泉
110_yuanshanshan_袁姗姗
111_zhaojinmai_赵今麦
112_zhaoyingzi_赵樱子
113_zhanghuiwen_张慧雯
114_zhangli_张俪
115_zhangmeng_张萌
116_zhanghanyun_张含韵
117_zhangjiani_张嘉倪
118_zhangtianai_张天爱
119_zhangxiaofei_张小斐
120_zhangxinyi_张歆艺
121_zhangxinyu_张馨予
122_zhangxueying_张雪迎
123_zhangyuqi_张雨绮
124_zhangzifeng_张子枫
125_zuoxiaoqing_左小青
Binary file added assets/stars/lamuyangzi.jpg
Binary file added assets/stars/libingbing.jpg
Binary file added assets/stars/lifeier.jpg
Binary file added assets/stars/linyun.jpg
Binary file added assets/stars/liqin.jpg
Binary file added assets/stars/lisheng.jpg
Binary file added assets/stars/liuhaocun.jpg
Binary file added assets/stars/liushishi.jpg
Binary file added assets/stars/liutao.jpg
Binary file added assets/stars/liuxijun.jpg
Binary file added assets/stars/liuyan.jpg
Binary file added assets/stars/liuyifei.jpg
Binary file added assets/stars/liuyun.jpg
Binary file added assets/stars/lixiaoran.jpg
Binary file added assets/stars/lixirui.jpg
Binary file added assets/stars/liyitong.jpg
Binary file added assets/stars/louyixiao.jpg
Binary file added assets/stars/lvyi.jpg
Binary file added assets/stars/mali.jpg
Binary file added assets/stars/maoxiaotong.jpg
Binary file added assets/stars/masichun.jpg
Binary file added assets/stars/masu.jpg
Binary file added assets/stars/mayili.jpg
Binary file added assets/stars/meiting.jpg
Binary file added assets/stars/mengmeiqi.jpg
Binary file added assets/stars/nini.jpg
Binary file added assets/stars/qinhailu.jpg
Binary file added assets/stars/qinlan.jpg
Binary file added assets/stars/qiwei.jpg
Binary file added assets/stars/rensuxi.jpg
Binary file added assets/stars/shenmengchen.jpg
Binary file added assets/stars/shenyue.jpg
Binary file added assets/stars/shuchang.jpg
Binary file added assets/stars/songjia.jpg
Binary file added assets/stars/songqian.jpg
Binary file added assets/stars/songyi.jpg
Binary file added assets/stars/songzuer.jpg
Binary file added assets/stars/sunli.jpg
Binary file added assets/stars/sunyi.jpg
Binary file added assets/stars/tangyan.jpg
Binary file added assets/stars/tangyixin.jpg
Binary file added assets/stars/tansongyun.jpg
Binary file added assets/stars/tanweiwei.jpg
Binary file added assets/stars/tongliya.jpg
Binary file added assets/stars/tongyao.jpg
Binary file added assets/stars/wanglikun.jpg
Binary file added assets/stars/wangluodan.jpg
Binary file added assets/stars/wangou.jpg
Binary file added assets/stars/wangxiaochen.jpg
Binary file added assets/stars/wangziwen.jpg
Binary file added assets/stars/wanqian.jpg
Binary file added assets/stars/wujinyan.jpg
Binary file added assets/stars/wuqian.jpg
Binary file added assets/stars/wuxuanyi.jpg
Binary file added assets/stars/xienuo.jpg
Binary file added assets/stars/xingfei.jpg
Binary file added assets/stars/xulu.jpg
Binary file added assets/stars/yangchaoyue.jpg
Binary file added assets/stars/yangmi.jpg
Binary file added assets/stars/yangrong.jpg
Binary file added assets/stars/yangying.jpg
Binary file added assets/stars/yangzi.jpg
Binary file added assets/stars/yaochen.jpg
Binary file added assets/stars/yexuan.jpg
Binary file added assets/stars/yinger.jpg
Binary file added assets/stars/yintao.jpg
Binary file added assets/stars/yuanbingyan.jpg
Binary file added assets/stars/yuanquan.jpg
Binary file added assets/stars/yuanshanshan.jpg
Binary file added assets/stars/yushuxin.jpg
Binary file added assets/stars/zhanghanyun.jpg
Binary file added assets/stars/zhanghuiwen.jpg
Binary file added assets/stars/zhangjiani.jpg
Binary file added assets/stars/zhangli.jpg
Binary file added assets/stars/zhangmeng.jpg
Binary file added assets/stars/zhangtianai.jpg
Binary file added assets/stars/zhangxiaofei.jpg
Binary file added assets/stars/zhangxinyi.jpg
Binary file added assets/stars/zhangxinyu.jpg
Binary file added assets/stars/zhangxueying.jpg
Binary file added assets/stars/zhangyuqi.jpg
Binary file added assets/stars/zhangzifeng.jpg
Binary file added assets/stars/zhangziyi.jpg
Binary file added assets/stars/zhaojinmai.jpg
Binary file added assets/stars/zhaoliying.jpg
Binary file added assets/stars/zhaolusi.jpg
Binary file added assets/stars/zhaoyingzi.jpg
Binary file added assets/stars/zhoudongyu.jpg
Binary file added assets/stars/zhouxun.jpg
Binary file added assets/stars/zuoxiaoqing.jpg

0 comments on commit 7de0f61

Please sign in to comment.