Guest User

Untitled

a guest
Mar 21st, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. function once(fn, context) {
  2. var result;
  3. return function() {
  4. if(fn) {
  5. result = fn.apply(context || this, arguments);
  6. fn = null;
  7. }
  8. return result;
  9. };
  10. }
  11.  
  12. var splits = new Array($(".split").length);
  13.  
  14. $('.split').each(function(i, obj) {
  15. $(this).addClass('split' + i);
  16. splits[i] = once(function() {
  17. fadeInText(".split"+i);
  18. })
  19. });
  20. $(window).scroll(function() {
  21.  
  22. for ( var i = 0; i <= $(".split").length; i++) {
  23. if ($(this).scrollTop() + $(window).height() > $(".split" + i).offset().top) {
  24. splits[i]();
  25. }
  26. }
  27. });
Add Comment
Please, Sign In to add comment