国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

??
?? ????? ???? ????? ???
? ?? ??? ?? ???? ?? ??? ???? ?? ????? ???? ?????? ????? ??? ?????.

??? ???? ?? ????? ???? ?????? ????? ??? ?????.

Dec 28, 2021 am 10:21 AM
????? ??? ?? ????

? ????? ?? ???? ????? ??? ??? ???? ?? ???? ???? ?????? ????? ??? ???????. ???? ??? ??? ????.

??? ???? ?? ????? ???? ?????? ????? ??? ?????.

?? ????? ???? ????? ???

?? ?? ?????? ??? ???? ?? ???? ??? ?????? ?????. ? ??? ?????? ??? ??? ? ?? ??? ?????. ?? ?? js ??? ??? ??? ?? ?????? ???? ?? ??? ???? ???? ?????. ??? ?? ?? ???? ???? ???? ??? ?????

this.goodBoxTimer = setInterval(() => {
  index--
  this.setData({
    'movingBallInfo.posX': linePos[index][0],
    'movingBallInfo.posY': linePos[index][1],
  })
  if (index < 1) {
    this.resetGoodBoxStatus()
  }
}, 30)

?? ??: ??? ??, ??, ???? ??, UI ???

Javascript? ?? ??? ????? ?? ??? ?? ????. ???? ? ?? ??? ????. ??? ?? ??(??)?? ?? ??? ??? ??(???)???. ?? ??? ?? ????? ??? ?? ?? ?? ??? ????, ?? ??? ??? ??? ?? ??? ??? ? ????. "?? ???"? ??? ??? ??? ? ??? ?? ???? ?? ?? ??? ??? ?? ?? ???? ?????.

??? ??? ??? ??(Task)? ???? ??(Micro Task)?? ?????. ????? ?? ???? ??? ?? ???? ???? ?? ???? ?????.

??? ??? ???? ??:

  • ?? ??? ??? ?? ????? ???? ?? ???? ??? ?????.

  • ??? ??? ?? ??? ?? ? ???? ?? ???? ?????.

  • ?? ??? ??? ??? ??? ? ??? ?? ???? ??? ?? ?? ?? ??? ?????. ??? ??? ? ?? ???????? ?? ????. ?? ?? ??? ???????? ???? ? ???????? ??????? ???? ?????. ?? ???? ??????? ???? ?? ?? ??? ??? ?????? ???? ?? ?? ?? ??? ?????.

  • ?? ???? ?? ? ?? ??? ?? ?????.

?? ??? ??:

  • setTimeout
  • setInterval
  • postMessage
  • ...

?? ???? ??:

  • Promise
  • MutationObserver

??? ??? UI ??? ?? ?? ? ??? ??????? ???? ?? ???????? ??? ? ????? ??? ????? ???? ??? ?????.

// demo1
// 渲染發(fā)生在微任務(wù)之后
const con = document.getElementById(&#39;con&#39;);
con.onclick = function () {
  Promise.resolve().then(function Promise1 () {
    con.textContext = 0;
  })
};

??? ???? ?? ????? ???? ?????? ????? ??? ?????.

// demo2
// 兩次EventLoop中間沒有渲染
const con = document.getElementById(&#39;con&#39;);
con.onclick = function () {
  setTimeout(function setTimeout1() {
      con.textContent = 0;
      Promise.resolve().then(function Promise1 () {
          console.log(&#39;Promise1&#39;)
    })
  }, 0)
  setTimeout(function setTimeout2() {
    con.textContent = 1;
    Promise.resolve().then(function Promise2 () {
        console.log(&#39;Promise2&#39;)
    })
  }, 0)
};

??? ???? ?? ????? ???? ?????? ????? ??? ?????.

??? ???? ???? ????? ??? ??? 60fps, ? ? ???? ??? ? 16.66ms?? ?? ?? ????. Dom? ? ????? ? ? ???? ????? ????? ??? ?? ???? ?????.

// demo3
// 兩次eventloop中有渲染
const con = document.getElementById(&#39;con&#39;);
con.onclick = function () {
  setTimeout(function  setTimeout1() {
    con.textContent = 0;
  }, 0);
  setTimeout(function  setTimeout2() {
    con.textContent = 1;
  }, 16.7);
};

??? ???? ?? ????? ???? ?????? ????? ??? ?????.

setInterval? ???? ???

??? ? ? ??? setInterval? ??? ?????. setInterval? ??? ?? ???? ??? ?? ???? ?? ??? ?????. ?? ???? ???? ????. ?? ???? setInterval ?? ??? ?????. ??? ?? ???? ? ??? ???? ?? ??? ???? ?? ???? ??? ??? ??? ??? ???? ????. ??? ??? ?? ???? ?? ??? ???? setInterval ??? ???? ????. ? ?? ?? ?? ??? ?? ??? ??? ?? ???? ?? ?????.

??? ? setInterval ??? ?? ??? ????? ?? ???? ?????

// demo4
const btn = document.getElementById(&#39;btn&#39;)
btn.addEventListener(&#39;click&#39;, setIntervalFn)
let sum = 0
function setIntervalFn() {
  let last
  let countIdx = 0
  const timer = setInterval(function timeFn() {
    countIdx++
    const newTime = new Date().getTime()
    const gap = newTime - last
    last = newTime
    console.log(&#39;setInterval&#39;, gap, countIdx)
    if (countIdx > 5) clearInterval(timer)
    // 10000000
    // 100000
    for (let i = 0; i < 100000; i++) {
      sum+= i
    }
  }, 100)
  last = new Date().getTime()
}

??? ???? ?? ????? ???? ?????? ????? ??? ?????.

setInterval? ??:

  • ?? ???? ?? ??? ??? ??? ?? ???? ?? ?????. ?? ?? ?? ?? ??? ?? ??. ?? ??? ?? ???? ?? ??? ?? ????? ??? ?? ??? ???? ???????.
  • setInterval? ?? ??? ????? ???? ????? ? ??? ???? ?? ?? ?? ??? ?? ? ????? ??? ??? ????? ??? ???? ??? ?? ????. ?? ???.

??? setInterval ?? setTimeout? ??? ???

requestAnimationFrame? ?????

js? ???? ?????? ??? ?? setTimeout ?? ?? ???? requestAnimationFrame? ?????.

window.requestAnimationFrame() ????? ?????? ???? ??? ??? ?? ?? ??? ?? ?????? ?????? ?? ??? ?? ??? ????? ????? ?????

由上面的例子可知,兩個(gè)宏任務(wù)之間不一定會觸發(fā)瀏覽器渲染,這個(gè)由瀏覽器自己決定,并且瀏覽器的幀率并會一直是60fps,有時(shí)可能會下降到30fps,而setTimeout的回調(diào)時(shí)間是寫死的,就有可能導(dǎo)致修改了多次Dom,而只觸發(fā)了一次ui更新,造成掉幀。

// demo5
const con = document.getElementById(&#39;con&#39;);
let i = 0;
function rAF(){
  requestAnimationFrame(function aaaa() {
    con.textContent = i;
    Promise.resolve().then(function bbbb(){
      if(i < 5) {rAF(); i++;}
    });
  });
}
con.onclick = function () {
  rAF();
};

??? ???? ?? ????? ???? ?????? ????? ??? ?????.

可以看到渲染了5次(五條豎直虛線)

小程序上的動畫優(yōu)化

小程序是雙線程架構(gòu)

??? ???? ?? ????? ???? ?????? ????? ??? ?????.

好處是:ui渲染和js主線程是分開的,我們知道在瀏覽器中這兩者是互斥的,所以當(dāng)主線程有阻塞時(shí),頁面交互就會失去響應(yīng),而小程序中不會出現(xiàn)這樣的情況。

壞處是:邏輯層、渲染層有通信延時(shí),大量的通信也會造成性能瓶頸。

小程序提供了wxs用來處理渲染層的邏輯。

購物車拋物線動畫優(yōu)化

所以我們不應(yīng)該用setInterval去執(zhí)行動畫,我們修改成,當(dāng)點(diǎn)擊加購時(shí),把點(diǎn)擊坐標(biāo)與目標(biāo)坐標(biāo)傳入wxs,然后計(jì)算運(yùn)行軌跡點(diǎn)的坐標(biāo)計(jì)算,接著用requestAnimationFrame執(zhí)行動畫幀

// wxs
function executeCartAnimation () {
  curCoordIdx = coordArr.length - 1
  ins.requestAnimationFrame(setStyleByFrame)
}

function setStyleByFrame() {
  if (curCoordIdx >= 0) {
    ins.selectComponent(&#39;.cart-animation&#39;).setStyle({
      display: &#39;block&#39;,
      left: coordArr[curCoordIdx].x + &#39;px&#39;, 
      top: coordArr[curCoordIdx].y + &#39;px&#39;
    })
    curCoordIdx -= 1
    ins.requestAnimationFrame(setStyleByFrame)
  } else {
    ins.selectComponent(&#39;.cart-animation&#39;).setStyle({
      display: &#39;none&#39;
    })
  }
}

在真機(jī)上效果非常明顯,低端安卓機(jī)上的動畫也非常絲滑。但是錄屏效果不好,這里就不放了。

【相關(guān)學(xué)習(xí)推薦:小程序開發(fā)教程

? ??? ??? ???? ?? ????? ???? ?????? ????? ??? ?????.? ?? ?????. ??? ??? PHP ??? ????? ?? ?? ??? ?????!

? ????? ??
? ?? ??? ????? ???? ??? ??????, ???? ?????? ????. ? ???? ?? ???? ?? ??? ?? ????. ???? ??? ???? ???? ??? ?? admin@php.cn?? ?????.

? AI ??

Undresser.AI Undress

Undresser.AI Undress

???? ?? ??? ??? ?? AI ?? ?

AI Clothes Remover

AI Clothes Remover

???? ?? ???? ??? AI ?????.

Video Face Swap

Video Face Swap

??? ??? AI ?? ?? ??? ???? ?? ???? ??? ?? ????!

???

??? ??

???++7.3.1

???++7.3.1

???? ?? ?? ?? ???

SublimeText3 ??? ??

SublimeText3 ??? ??

??? ??, ???? ?? ????.

???? 13.0.1 ???

???? 13.0.1 ???

??? PHP ?? ?? ??

???? CS6

???? CS6

??? ? ?? ??

SublimeText3 Mac ??

SublimeText3 Mac ??

? ??? ?? ?? ?????(SublimeText3)

???

??? ??

??? ????
1601
29
PHP ????
1502
276
???
Python? ???? WeChat ??? ?? Python? ???? WeChat ??? ?? Jun 17, 2023 pm 06:34 PM

??? ??? ??? ????? ???? ?? WeChat? ???? ?? ???? ?? ??????? ?????. WeChat ?? ????? ???? ???? ??????? ?????? ???? ??? ?? ????? ?? ???? ? ?? ??? ?? ??? ??? ? ????. ? ????? Python? ???? WeChat ???? ???? ??? ?????. 1. ?? Python? ???? WeChat ???? ???? ?? ?? Python ?????? ???? ???. ???? wxpy? itchat ? ?????? ???? ?? ????. wxpy? ?? ?????

WeChat ?? ?????? ?? ??? ?? ?? WeChat ?? ?????? ?? ??? ?? ?? Nov 21, 2023 am 10:55 AM

WeChat ?? ?????? ?? ??? ?? ?? WeChat ?? ?????? ?? ??? ??? ???? ?? ??? ??? ????? ?? ??? ??? ???? ? ?? ???? ????? ?????. ??? WeChat ????? ?? ??? ??? ???? ??? ??? ???? ?? ?? ??? ?????. ??, ?? ????? ??? ???? ??? ? ?? ?? ??? ???? ???. ??? ?? ??? ???? ?? ??? ?? ??? ?? ??? ???? ?? ????. &lt;--index.wxml- -&gt;&l

Alipay, ?? ?? ?????? ???? ???? '?? ??-?? ??' ?? ???? ?? Alipay, ?? ?? ?????? ???? ???? '?? ??-?? ??' ?? ???? ?? Oct 31, 2023 pm 09:25 PM

10? 31? ? ???? ??? ??? ?? 5? 27? Ant Group? '?? ?? ????'? ????? ????? ?? ??? ??? ?????. Alipay? '?? ?? - ??? ?? ??' ?? ????? ??????. ?? ???? ?? ??? ?????? ???? ?? ???? ?? ??? ?? ??? ???? Alipay? ?? ??? ?? ??? ???? ? ??? ???. ?? ???? "????", "????" ?? ???? ???? "????" ???? ??? ? ????. ?? ?????? ???? ????? ?? ? ???? ?? ?? ??? ??? ??? ? ??? ?? ? Alipay ????? ?? ?????? ?? ??? ?????. ? ??????? ?? ??????? ?? ?? ?? ?? ??? ??? ? ??? ?????. ? ?? ??? ??? ???? ?? ??? ?? ???????. ??? ??

?? ????? ??? ? ???? ?? ????? ??? ? ???? Dec 29, 2022 am 11:06 AM

?? ????? ??? ??? ? ????. ?? ??: 1. "react-reconciler"? ???? ???? ???? DSL? ?????. 2. DSL? ?? ???? ????? ?? ?? ???? ?? ??? ????. 3. npm? ???? ???? ?????. ???? npm? ?????. 4. ??? ???? ???? ??? ?? API? ???? ??? ?????.

uniapp? ?? ????? H5 ?? ?? ??? ???? ?? uniapp? ?? ????? H5 ?? ?? ??? ???? ?? Oct 20, 2023 pm 02:12 PM

???? ?? ????? H5 ??? ??? ????? ???? ?? ??? ?????. ?? ??? ???? ??? ????? ???? ?? ?? ????? H5? ?? ?????? ??? ?????. ??? ??? ?? ?????? uniapp? ?? ??? ???? ?? ????? H5 ?? ??? ???? ???? ?? ???? ?? ???? ? ????. ? ????? uniapp? ?? ????? H5 ?? ??? ??? ???? ??? ???? ???? ?? ??? ?????. 1. ??? ??? ??

?? ?????? ?? ?? ??? ???? ???? ??? ?????(?? ???? ??). ?? ?????? ?? ?? ??? ???? ???? ??? ?????(?? ???? ??). Nov 04, 2022 pm 04:53 PM

?? ?? ?? ?? ????? ??? ? ?? ??? ?? ????, ?? ?????? ?? ?? ??? ???? ???? ??? ?? ???????.

Python?? ??? ?? ???? ?? ???? Python?? ??? ?? ???? ?? ???? May 08, 2023 pm 06:37 PM

?? ???? x01 ?? ?? ??, ?? ???? ??? ???? ???? ?????. ?? ??? ??? ??? ? ???? ?? ??? ?? ? ??? ?????. ?? ???? ???? ???? ??? ?? ??? ?????. x02 ?????? ??? ???? ?? ?????. ?????? ??? ???? ??? ?? ???? ?? ??? ???? ?????. ??? ??? ??? ????? ????? ??? ? ?? ???? ???? ???. ??? ??? ?? ???? ?? ??? ??? ?? ?????. ????, ??

PHP? ?? ????? ??? ??? ?? ?? ? ?? ?? PHP? ?? ????? ??? ??? ?? ?? ? ?? ?? Jul 04, 2023 pm 04:01 PM

PHP ? ?? ????? ??? ?? ?? ? ?? ?? ??? ?? ?? ? ?? ??? ?? ???? ??? ?? ? ??? ?????. ??? ??? ??? ?? ?? ?? ? ?? ??? ?? ???? ??? ???? ????. ?? ???? PHP? ???? ? ?? ???? ?? ?????. ? ????? PHP ? ?? ?????? ??? ?? ?? ? ?? ?? ?? ??? ???? ?? ?? ??? ?????. 1. PHP? ???? PHP??? ?? ????? ??? ? ????.

See all articles