第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

用于在頁(yè)面上逐步滑動(dòng)點(diǎn)的對(duì)象內(nèi)的復(fù)合值

用于在頁(yè)面上逐步滑動(dòng)點(diǎn)的對(duì)象內(nèi)的復(fù)合值

我無(wú)法讓變量作為我對(duì)象中的 translateX 值正常運(yùn)行。每次單擊下一個(gè)按鈕時(shí),我都想讓點(diǎn)在頁(yè)面上滾動(dòng)。我的代碼只能在第一步來(lái)回移動(dòng)它。我是動(dòng)畫(huà) API 的新手,我已經(jīng)使用 CSS 轉(zhuǎn)換完成了這項(xiàng)工作,但我正在嘗試很好地處理 API。html:<div class="progress__container">                <div class="progress__bar">                        <div id="progress__fill" class="step1"></div>                        <div class="circ" id="circ__1"></div>                        <div class="circ" id="circ__2"></div>                        <div class="circ" id="circ__3"></div>                        <div class="circ" id="circ__4"></div>                        <div id="progress__dot" class="prog__1"></div>                    </div>            <div class="backBar"></div>            <div class="flexrow">                    <span class="stepName">Account</span>                    <span class="stepName">Frequency</span>                    <span class="stepName">Amount</span>                    <span class="stepName">Taxes</span>                </div>            <div class="button__container">                <button class="buttonStep" id="back">Back</button>                <button class="buttonStep is-active" id="next">Next</button>            </div>    </div>js:// give a starting value for the transformationvar startVal = 0;// define the keyframesvar moveDot = [    { transform: `translateX(${startVal}px)`},    { transform: `translateX(${startVal + 190}px)`}  ];// definte the timingvar dotTiming = {    duration: 400,      fill: "forwards",      easing: 'ease-in',} // make the animation happenvar movingDot = document.getElementById("progress__dot").animate(    moveDot,    dotTiming  );//  pause the animation until calledmovingDot.pause();    // on click fire the animationdocument.getElementById('next').addEventListener('click', function() {    movingDot.playbackRate = 1;    if (startVal <= 380) {        movingDot.play();        startVal += 190;    } });按照我的設(shè)置方式,我希望 translateX 值根據(jù)單擊事件偵聽(tīng)器而增加或減少,這將使圓圈在頁(yè)面上滑動(dòng)。實(shí)際發(fā)生的是,只有第一步有效。它不會(huì)超過(guò)第一個(gè)停止點(diǎn)。如果我在控制臺(tái)中記錄 moveDot,它會(huì)給我我期望的值,但它只會(huì)在 0 和 190 處啟動(dòng)/停止。后退按鈕的功能相同。
查看完整描述

1 回答

?
繁星淼淼

TA貢獻(xiàn)1775條經(jīng)驗(yàn) 獲得超11個(gè)贊

它每次都在同一個(gè)地方進(jìn)行動(dòng)畫(huà)處理。將 的定義移動(dòng)moveDot到事件偵聽(tīng)器中:


// give a starting value for the transformation

var startVal = 0;


// definte the timing

var dotTiming = {

  duration: 400,

  fill: "forwards",

  easing: 'ease-in',

}


// on click fire the animation

document.getElementById('next').addEventListener('click', function() {

  if (startVal > 380){return;}


  // define the keyframes

  var moveDot = [{transform: `translateX(${startVal}px)`},

    {transform: `translateX(${startVal + 190}px)`}];


  // make the animation happen

  var movingDot = document.getElementById("progress__dot").animate(

    moveDot,

    dotTiming

  );


  movingDot.playbackRate = 1;



  movingDot.play();

  startVal += 190;




});



document.getElementById('back').addEventListener('click', function() {

  movingDot.playbackRate = -1;

  if (startVal >= 0) {

    movingDot.play();

    startVal -= 190;

  }


});


查看完整回答
反對(duì) 回復(fù) 2021-11-04
  • 1 回答
  • 0 關(guān)注
  • 175 瀏覽
慕課專(zhuān)欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢(xún)優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)