2017-01-13 3 views
1

Ich verwende ein Plugin namens Letter js, um vier Absätze mit html jQuery und CSS zu animieren.Letter js delay

Das Plugin funktioniert gut, aber ich habe ein Problem versucht, die Animation eines jeden Absatzes zu verzögern, das heißt, Absatz 1 sollte nach 1 Sekunde beginnen, Absatz 2 sollte nach 2 Sekunden mit anderen Worten beginnen, so dass jeder Absatz allmählich erscheint.

Ich habe versucht, die Verzögerungsfunktion nach Inhalt, aber das hat nicht funktioniert, kann jemand helfen?

// The plugin js (l-by-l.min.js) file is the following: 
 
! function(e) { 
 
    e.fn.lbyl = function(n) { 
 
    { 
 
     var t = e.extend({ 
 
      content: "", 
 
      speed: 10, 
 
      type: "fade", 
 
      fadeSpeed: 500, 
 
      finished: function() {} 
 
     }, n), 
 
     d = e(this), 
 
     s = [], 
 
     i = t.content; 
 
     e(this).length 
 
    } 
 
    d.empty(), d.attr("data-time", i.length * t.speed); 
 
    for (var p = 0; p < i.length; p++) s.push(i[p]); 
 
    e.each(s, function(e, n) { 
 
     d.append('<span style="display: none;">' + n + "</span>"), setTimeout(function() { 
 
     "show" == t.type ? d.find("span:eq(" + e + ")").show() : "fade" == t.type && d.find("span:eq(" + e + ")").fadeIn(t.fadeSpeed) 
 
     }, e * t.speed) 
 
    }), setTimeout(function() { 
 
     t.finished() 
 
    }, i.length * t.speed) 
 
    } 
 
}(jQuery); 
 

 
// My Script is the following: 
 

 
jQuery(document).ready(function($) { 
 
    $(".welcome_Text1_dk").lbyl({ 
 
    content: "this is paragraph one", 
 
    speed: 100, //time between each new letter being added 
 
    type: 'fade', // 'show' or 'fade' 
 
    fadeSpeed: 500, // Only relevant when the 'type' is set to 'fade' 
 
    finished: function() { 
 
     console.log('finished') 
 
     } // Finished Callback 
 
    }) 
 
}); 
 

 
jQuery(document).ready(function($) { 
 
    $(".welcome_Text2_dk").lbyl({ 
 
    content: "this is paragraph two", 
 
    speed: 100, //time between each new letter being added 
 
    type: 'fade', // 'show' or 'fade' 
 
    fadeSpeed: 500, // Only relevant when the 'type' is set to 'fade' 
 
    finished: function() { 
 
     console.log('finished') 
 
     } // Finished Callback 
 
    }) 
 
}); 
 

 
jQuery(document).ready(function($) { 
 
    $(".welcome_Text3_dk").lbyl({ 
 
    content: "this is paragraph three", 
 
    speed: 100, //time between each new letter being added 
 
    type: 'fade', // 'show' or 'fade' 
 
    fadeSpeed: 500, // Only relevant when the 'type' is set to 'fade' 
 
    finished: function() { 
 
     console.log('finished') 
 
     } // Finished Callback 
 
    }) 
 
}); 
 

 
jQuery(document).ready(function($) { 
 
    $(".welcome_Text4_dk").lbyl({ 
 
    content: "this is paragraph four", 
 
    speed: 100, //time between each new letter being added 
 
    type: 'fade', // 'show' or 'fade' 
 
    fadeSpeed: 500, // Only relevant when the 'type' is set to 'fade' 
 
    finished: function() { 
 
     console.log('finished') 
 
     } // Finished Callback 
 
    }) 
 
});
#home_dk { 
 
    width: 100%; 
 
    height: 100vh; 
 
    background: #fff; 
 
    background-attachment: fixed; 
 
    display: flex; 
 
    flex-direction: column; 
 
    justify-content: center; 
 
} 
 
#welcome_Text_Wrapper_dk { 
 
    display: block; 
 
    margin-left: auto; 
 
    margin-right: auto; 
 
    width: auto; 
 
} 
 
.welcome_Text1_dk, 
 
.welcome_Text2_dk, 
 
.welcome_Text3_dk { 
 
    color: #b6b69c; 
 
    font-size: 2.6em; 
 
    font-family: "SuperGroteskWebPro-Bold W01 Rg"; 
 
    text-transform: uppercase; 
 
    text-align: left; 
 
    line-height: 1em; 
 
} 
 
.welcome_Text4_dk { 
 
    color: #b6b69c; 
 
    font-size: 2.6em; 
 
    font-family: 'FF_Super_Grotesk'; 
 
    text-transform: uppercase; 
 
    text-align: left; 
 
    line-height: 1em; 
 
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> 
 
<div id="home_dk"> 
 

 
    <article id="welcome_Text_Wrapper_dk"> 
 

 
    <div class="welcome_Text1_dk"></div> 
 
    <div class="welcome_Text2_dk"></div> 
 
    <div class="welcome_Text3_dk"></div> 
 
    <div class="welcome_Text4_dk"></div> 
 

 
    </article> 
 

 
</div>

+0

So ist die Veränderung auf der (l-by-l.min.js) Datei? – user5434403

+0

Wo gebe ich die Zeit an? Könnten Sie mir bitte ein Beispiel geben? – user5434403

Antwort

2

// The plugin js (l-by-l.min.js) file is the following: 
 
! function(e) { 
 
    e.fn.lbyl = function(n) { 
 
    { 
 
     var t = e.extend({ 
 
      content: "", 
 
      speed: 10, 
 
      type: "fade", 
 
      fadeSpeed: 500, 
 
      finished: function() {} 
 
     }, n), 
 
     d = e(this), 
 
     s = [], 
 
     i = t.content; 
 
     e(this).length 
 
    } 
 
    d.empty(), d.attr("data-time", i.length * t.speed); 
 
    for (var p = 0; p < i.length; p++) s.push(i[p]); 
 
    e.each(s, function(e, n) { 
 
     d.append('<span style="display: none;">' + n + "</span>"), setTimeout(function() { 
 
     "show" == t.type ? d.find("span:eq(" + e + ")").show() : "fade" == t.type && d.find("span:eq(" + e + ")").fadeIn(t.fadeSpeed) 
 
     }, e * t.speed) 
 
    }), setTimeout(function() { 
 
     t.finished() 
 
    }, i.length * t.speed) 
 
    } 
 
}(jQuery); 
 

 
// My Script is the following: 
 

 
jQuery(document).ready(function($) { 
 

 
    // create an array of paragraphs 
 
    var myParagraphs = [{ 
 
    selector: ".welcome_Text1_dk", 
 
    content: "this is paragraph one" 
 
    }, { 
 
    selector: ".welcome_Text2_dk", 
 
    content: "this is paragraph two" 
 
    }, { 
 
    selector: ".welcome_Text3_dk", 
 
    content: "this is paragraph three" 
 
    }, { 
 
    selector: ".welcome_Text4_dk", 
 
    content: "this is paragraph four" 
 
    }]; 
 

 
    // loops it 
 
    for (let i = 0; i < myParagraphs.length; i++) { 
 
    setTimeout(function() { 
 
     $(myParagraphs[i].selector).lbyl({ 
 
     content: myParagraphs[i].content, 
 
     speed: 100, //time between each new letter being added 
 
     type: 'fade', // 'show' or 'fade' 
 
     fadeSpeed: 500, // Only relevant when the 'type' is set to 'fade' 
 
     finished: function() { 
 
      console.log('finished') 
 
      } // Finished Callback 
 
     }); 
 
    }, 1000 * i); 
 
    } 
 

 
});
#home_dk { 
 
    width: 100%; 
 
    height: 100vh; 
 
    background: #fff; 
 
    background-attachment: fixed; 
 
    display: flex; 
 
    flex-direction: column; 
 
    justify-content: center; 
 
} 
 
#welcome_Text_Wrapper_dk { 
 
    display: block; 
 
    margin-left: auto; 
 
    margin-right: auto; 
 
    width: auto; 
 
} 
 
.welcome_Text1_dk, 
 
.welcome_Text2_dk, 
 
.welcome_Text3_dk { 
 
    color: #b6b69c; 
 
    font-size: 2.6em; 
 
    font-family: "SuperGroteskWebPro-Bold W01 Rg"; 
 
    text-transform: uppercase; 
 
    text-align: left; 
 
    line-height: 1em; 
 
} 
 
.welcome_Text4_dk { 
 
    color: #b6b69c; 
 
    font-size: 2.6em; 
 
    font-family: 'FF_Super_Grotesk'; 
 
    text-transform: uppercase; 
 
    text-align: left; 
 
    line-height: 1em; 
 
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> 
 
<div id="home_dk"> 
 

 
    <article id="welcome_Text_Wrapper_dk"> 
 

 
    <div class="welcome_Text1_dk"></div> 
 
    <div class="welcome_Text2_dk"></div> 
 
    <div class="welcome_Text3_dk"></div> 
 
    <div class="welcome_Text4_dk"></div> 
 

 
    </article> 
 

 
</div>

+0

Vielen Dank Ihnen beiden, ich schätze Ihre Hilfe! – user5434403

+1

glücklich zu helfen, nur damit Sie wissen, Sie brauchen nicht die 'l-by-l.js' und die' l-by-l.min.js', sie sind beide das gleiche Skript, man ist nur minimiert . Vergessen Sie auch nicht, die Antwort zu markieren, die Ihnen am besten gefallen hat. Viel Glück. –

+1

Gotcha, nochmals vielen Dank, einen schönen Tag! – user5434403

1

können Sie die setTimeout()-Funktion verwenden.

jQuery(document).ready(function($) { 
    // run first one here 
    setTimeout(function(){ 
     // do the second one here 
    }, 1000); // in milliseconds; 1 second 
    setTimeout(function(){ 
     // do the third one 
    }, 2000); // in milliseconds; 2 second 
    setTimeout(function(){ 
     // do the fourth one here 
    }, 3000); // in milliseconds; 3 second 
    // etc. 
});