Advertisement
Guest User

Untitled

a guest
Feb 20th, 2019
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.14 KB | None | 0 0
  1. (function($) {
  2.  
  3. $.fn.visible = function(partial) {
  4.  
  5. var $t = $(this),
  6. $w = $(window),
  7. viewTop = $w.scrollTop(),
  8. viewBottom = viewTop + $w.height(),
  9. _top = $t.offset().top,
  10. _bottom = _top + $t.height(),
  11. compareTop = partial === true ? _bottom : _top,
  12. compareBottom = partial === true ? _top : _bottom;
  13.  
  14. return ((compareBottom <= viewBottom) && (compareTop >= viewTop));
  15.  
  16. };
  17.  
  18. })(jQuery);
  19.  
  20. var win = $(window);
  21.  
  22. var allMods = $(".bubble-chat");
  23. var msgText = $(".text");
  24.  
  25. allMods.each(function(i, el) {
  26. var el = $(el);
  27. if (el.visible(true)) {
  28. el.addClass("already-visible");
  29. msgText.css('display', 'block');
  30. }
  31.  
  32. if(el.hasClass("already-visible")) {
  33. el.css('display', 'none')};
  34. })
  35.  
  36.  
  37. win.scroll(function(event) {
  38.  
  39. allMods.each(function(i, el) {
  40. var el = $(el);
  41. if (el.visible(true)) {
  42. el.addClass("come-in");
  43. el.delay(3000);
  44. el.queue(function (next) {
  45. $(this).css('display', 'none');
  46. msgText.css('display', 'block');
  47. next();
  48. });
  49. }});
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement