[英]How to make the variable globally accessible in this case?
CODEPEN 示例http://codepen.io/dada78/pen/b50de869b75b32e220956bb36052733b
我想弄清楚如何在代碼筆的第 40 行的函數“fadeOutUnselected(notThisId)”中訪問我的 highlightSelection 函數中使用的 selectedId 變量?
function fadeOutUnselected(notThisId) {
var tl = new TimelineMax();
tl.to(".options:not([id=" + notThisId +"]), input[type='radio']", 0.5, {autoAlpha:0}, "getSlidesReady+=4") //fade out all options but the selected one
//.to("#"+ selectedId, 0.5, {y:0}) //animate selectedId option up
.set(".options:not([id=" + notThisId +"]), input[type='radio']", {y:0})
return tl;
}
任何幫助表示贊賞。 我想要做的就是將用戶選擇的選項(“selectedId”變量)設置為動畫,直到位置 y:0。
謝謝!
你應該做類似的事情
var globalSelectedId;
function highlightSelection(label) {
// same code
globalSelectedId = selectedId;
}
function fadeOutUnselected(notThisId) {
// same code, you can acces globalSelectedID
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.