let winScroll = 0; let modal = ''; let rand_list = []; $(window).bind('load scroll resize', function () { winScroll = $(this).scrollTop(); }); // 사이드 열기 공통 function side_open(modalName) { modal = $(modalName); $('body').addClass('modalFix').css('top', -winScroll); $(modal).stop().fadeIn(150); } // 사이드 닫기 공통 function side_close(modalName) { modal.fadeOut(100); let bodyWrap = $('body'); let winTop = Math.abs(parseInt(bodyWrap.css('top'))); bodyWrap.removeClass('modalFix').css('top', ''); $(window).scrollTop(winTop); } // 모달 열기 공용 function modal_open(modalName) { history.pushState(null, null, location.href); let modal = $(modalName); // 모달창 ID값으로 열기 let winScroll = $(this).scrollTop(); let modalBody = $(modal).children(".layer_container"); $(modal).stop().show(); let modalH = modalBody.height(); modalBody.css({ height: modalH, top: "0", left: "0", right: "0", bottom: "0" }); $('#wrap').addClass('modalFix').css('top', -winScroll); // 스크롤바 막고, 사이즈 고정 $('body').addClass('winFix'); // body 스크롤바 } // 랜덤 게임 공용 function fnRandGame() { if (!rand_list.length) { $('a').each(function () { href = $(this).attr('href'); if (href.startsWith('/game')) { rand_list.push(href); } }); } location.href = rand_list[Math.floor(Math.random() * rand_list.length)];; }