Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (function($) {
- $.fn.visible = function(partial) {
- var $t = $(this),
- $w = $(window),
- viewTop = $w.scrollTop(),
- viewBottom = viewTop + $w.height(),
- _top = $t.offset().top,
- _bottom = _top + $t.height(),
- compareTop = partial === true ? _bottom : _top,
- compareBottom = partial === true ? _top : _bottom;
- return ((compareBottom <= viewBottom) && (compareTop >= viewTop));
- };
- })(jQuery);
- var win = $(window);
- var allMods = $(".bubble-chat");
- var msgText = $(".text");
- allMods.each(function(i, el) {
- var el = $(el);
- if (el.visible(true)) {
- el.addClass("already-visible");
- msgText.css('display', 'block');
- }
- if(el.hasClass("already-visible")) {
- el.css('display', 'none')};
- })
- win.scroll(function(event) {
- allMods.each(function(i, el) {
- var el = $(el);
- if (el.visible(true)) {
- el.addClass("come-in");
- el.delay(3000);
- el.queue(function (next) {
- $(this).css('display', 'none');
- msgText.css('display', 'block');
- next();
- });
- }});
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement