我面臨以下問(wèn)題。HTML:<div id='loading'> <svg> /* inline SVG with animateTransform tags */ </svg> <span>Loading, please wait...</span></div><button id='generateResult'></button><span id='result'></span>記者:$('#generateResult').click(function(){ $('#loading').fadeIn(100, function(){ // After showing the 'loading' container, run the calculate_result function let result = calculate_result(); // When it's done, output the result into #result span $('#result').html(result); });});注意:這不是實(shí)際代碼,只是一個(gè)快捷示例。問(wèn)題是執(zhí)行該calculate_result函數(shù)大約需要 10 秒。在此期間#loading,容器應(yīng)該是可見(jiàn)的,其中包含一個(gè)動(dòng)畫(huà)svg加載圖標(biāo)。但由于某種原因,該calculate_result函數(shù)導(dǎo)致 SVG 圖標(biāo)停止動(dòng)畫(huà)。有什么辦法可以防止這種情況發(fā)生嗎?
Javascript 執(zhí)行阻止 SVG 動(dòng)畫(huà)
有只小跳蛙
2023-03-24 14:45:05