◆少前百科是非盈利性、非官方的少女前线维基百科。 ◆如果您发现某些内容错误/空缺,请勇于修正/添加!参与进来其实很容易!点这里 加入少前百科。 ◆有任何意见、建议、纠错,欢迎在 GFwiki:反馈与建议 提出和讨论。编辑事务讨论QQ群:597764980,微博@GFwiki少前百科 ◆To foreigners,You can use twitter to contact us. |
“Widget:Costume/js”的版本间的差异
(add switch animate) |
|||
(未显示同一用户的12个中间版本) | |||
第18行: | 第18行: | ||
let width = window.innerWidth; | let width = window.innerWidth; | ||
if(width > height) $("#suitdiv").height(height - 40); | if(width > height) $("#suitdiv").height(height - 40); | ||
+ | if(width > height) $("#skinImgDiv").width(height - 40); | ||
+ | else{ $("#skinImgDiv").width(width - 40); $("#skinImgDiv").height(width - 40);} | ||
− | var | + | var picState = 0; // 0:正常 1:重创 |
− | var | + | var picIndex = 0; // 当前选择的立绘Index |
− | loadcreat( | + | loadcreat(); |
− | + | function loadcreat(){ | |
− | function loadcreat( | ||
for(let i = 0; i < picarr.length; i++){ | for(let i = 0; i < picarr.length; i++){ | ||
− | var img = new Image(); | + | for(j in ["pic0", "pic1"]){ |
− | + | var img = new Image(); | |
− | + | $(img).load(function(){$(this).remove();}); | |
− | + | $(img).attr({"src":picarr[i][["pic0", "pic1"][j]]}); | |
− | + | } | |
− | |||
− | |||
− | |||
− | |||
} | } | ||
} | } | ||
− | + | // 人形装扮选择序列的DOM创建 | |
− | + | var skinNameDiv = document.querySelectorAll(".skinname"); | |
− | + | for(let i = 0; i < skinNameDiv.length; i++){ | |
− | + | let text = `<div class="skinnamedoll">` + picarr[i].doll + `<\/div><div class="skinnameskin">` + picarr[i].name + `<\/div>`; | |
− | + | $(skinNameDiv[i]).html(text); | |
− | |||
− | |||
− | |||
− | |||
} | } | ||
− | + | var picnDiv = document.querySelectorAll(".picndiv"); | |
− | + | for(let i = 0; i < picnDiv.length; i++) $(picnDiv[i]).attr("index", i); | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | var | ||
− | for(let i = 0; i < | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
$(".picndiv").click(function(){ | $(".picndiv").click(function(){ | ||
$("img.picn").css("border-top", "4px solid #eaeaea"); | $("img.picn").css("border-top", "4px solid #eaeaea"); | ||
第122行: | 第54行: | ||
$(this).children(".skinname").children("div").css({"color":"#000000"}); | $(this).children(".skinname").children("div").css({"color":"#000000"}); | ||
− | + | picIndex = $(this).attr("index"); | |
− | + | skinChange(Number($(this).attr("index"))); | |
}); | }); | ||
− | $( | + | $(picnDiv[0]).click(); |
− | + | $("#thepic").click(function(event){ | |
− | function | + | let relative_x = event.offsetX; |
− | + | let pic_width = $(this).width(); | |
− | |||
− | + | if(relative_x < pic_width / 4) skinPrev(); | |
− | + | else if(relative_x > pic_width / 4 * 3) skinNext(); | |
− | $( | + | else skinStateSwitch(); |
+ | }); | ||
+ | |||
+ | // 装扮切换的函数 分别处理立绘、spine、人形、装扮名称、台词 | ||
+ | function skinNext(){ | ||
+ | let nextNum = Number(picIndex) + 1; | ||
+ | if(picIndex >= picarr.length - 1) nextNum = 0; | ||
+ | $(picnDiv[nextNum]).click(); | ||
} | } | ||
− | function | + | |
+ | function skinPrev(){ | ||
+ | let prevNum = picIndex - 1; | ||
+ | if(picIndex <= 0) prevNum = picarr.length - 1; | ||
+ | $(picnDiv[prevNum]).click(); | ||
+ | } | ||
+ | |||
+ | function skinStateSwitch(){ | ||
+ | picState = (picState) ? 0 : 1; | ||
+ | skinChange("skinStateSwitch"); | ||
+ | } | ||
+ | |||
+ | function skinChange(mode){ | ||
+ | picChange(); | ||
+ | if(mode != "skinStateSwitch")spineChange(); | ||
+ | if(mode != "skinStateSwitch")$("#skininfodoll").html(picarr[picIndex].doll); | ||
+ | if(mode != "skinStateSwitch")$("#skininfoname").html(picarr[picIndex].name); | ||
+ | if(mode != "skinStateSwitch")$("#skindollline").html(picarr[picIndex].line); | ||
+ | } | ||
+ | |||
+ | function picChange(){ | ||
$("#thepic").fadeOut(60); | $("#thepic").fadeOut(60); | ||
setTimeout(function(){ | setTimeout(function(){ | ||
− | if( | + | if(picState == 0) $("#thepic").attr("src", picarr[picIndex].pic0); |
− | else $("#thepic").attr("src", picarr[ | + | else $("#thepic").attr("src", picarr[picIndex].pic1); |
setTimeout(function(){ | setTimeout(function(){ | ||
$("#thepic").fadeIn(60); | $("#thepic").fadeIn(60); | ||
第146行: | 第104行: | ||
}, 60); | }, 60); | ||
} | } | ||
− | function | + | |
+ | function spineChange(){ | ||
$("#spineSkinBox").children("canvas").fadeOut(100); | $("#spineSkinBox").children("canvas").fadeOut(100); | ||
setTimeout(function(){ | setTimeout(function(){ | ||
− | ($(".chibi-costume-switcher").children("option"))[ | + | ($(".chibi-costume-switcher").children("option"))[picIndex].selected = true; |
swap_costume($(".chibi-costume-switcher"), 'spineSkinBox'); | swap_costume($(".chibi-costume-switcher"), 'spineSkinBox'); | ||
$("#spineSkinBox").children("canvas").fadeIn(100); | $("#spineSkinBox").children("canvas").fadeIn(100); | ||
第155行: | 第114行: | ||
} | } | ||
− | // | + | // spine的DOM创建 黑盒 |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
let html_str = `<select class="chibi-costume-switcher" autocomplete="off" onchange="swap_costume(this)" style="display:none;">`; | let html_str = `<select class="chibi-costume-switcher" autocomplete="off" onchange="swap_costume(this)" style="display:none;">`; | ||
html_str += `<option selected="selected" value="` + picarr[0].num + `" data-tdoll="` + picarr[0].code + `"></option>`; | html_str += `<option selected="selected" value="` + picarr[0].num + `" data-tdoll="` + picarr[0].code + `"></option>`; | ||
− | for(let i = 1; i < picarr.length; i ++) | + | for(let i = 1; i < picarr.length; i ++) html_str += `<option value="` + picarr[i].num + `" data-tdoll="` + picarr[i].code + `"></option>`; |
− | |||
− | |||
html_str += `</select>`; | html_str += `</select>`; | ||