How to detect when the image has finished rendering? on IOS
- 在Chrome PC上 Android 方法
function loaded() { console.log('loaded and rendered') } <img onload={loaded()} />
2. 100% 保證的方法 (Safari也適用)
function rendered() { console.log('rendered') } function startRender() { requestAnimationFrame(rendered); } function loaded() { console.log('loaded') requestAnimationFrame(startRender); } <img onload={loaded()} />
基本上要確保100% 載入且渲染完成,要等2個frame,就一定會渲染完成
@copyright MRcodingRoom
觀看更多文章請點MRcoding筆記
觀看更多文章請點MRcoding筆記