我有一個函數,我知道這不是編寫它的最有效的方法,不僅是爲了這個函數,而且是爲了將來的其他人。使簡單的jQuery功能更有效
這是相同的行,除了一個數字每次重複獲得+ = 1,所以我確信這是一個for,或者if,或者每個方法來循環這個,並且減少代碼並且同時增加可維護性。
function lines() {
$('#bottom-1').lazylinepainter(
{
"svgData": pathObj1, //only line that changes
"strokeWidth": 1,
"strokeColor": "#fff"
}).lazylinepainter('paint');
$('#bottom-2').lazylinepainter(
{
"svgData": pathObj2, //only line that changes
"strokeWidth": 1,
"strokeColor": "#fff"
}).lazylinepainter('paint');
$('#bottom-3').lazylinepainter(
{
"svgData": pathObj3, //only line that changes
"strokeWidth": 1,
"strokeColor": "#fff"
}).lazylinepainter('paint');
$('#bottom-4').lazylinepainter(
{
"svgData": pathObj4, //only line that changes
"strokeWidth": 1,
"strokeColor": "#fff"
}).lazylinepainter('paint');
$('#solutions h2').delay().animate({opacity:'1'}, 1000, 'easeInQuint')
}