/* * @author: ecitlm * @date: 2017-08-04 23:18:26 * @last modified by: ecitlm * @last modified time: 2017-08-04 23:18:26 */ !(function() { var serviceonline = (function() { var sidecontent = document.queryselector(".side_content"); var show_btn = document.queryselector(".show_btn"); var close_btn = document.queryselector(".close_btn"); var timer = null; //����qq�����ƶ� var startmove = function(argument) { var scrollsidebar = document.getelementbyid("scrollsidebar"); clearinterval(timer); timer = setinterval(function() { var speed = (argument - scrollsidebar.offsettop) / 4; speed = speed > 0 ? math.ceil(speed) : math.floor(speed); if (argument == scrollsidebar.offsettop) { clearinterval(timer); } else { scrollsidebar.style.top = scrollsidebar.offsettop + speed + "px"; } }, 20); }; //����ƶ� var scrollmove = function() { window.onscroll = window.onload = function() { var scrollsidebar = document.getelementbyid("scrollsidebar"); var scrolltop = document.body.scrolltop || document.documentelement.scrolltop; startmove( parseint( (document.documentelement.clientheight - scrollsidebar.offsetheight) /2 +scrolltop ) ); }; }; //����qq��ʾ var slideshow = function() { if (!show_btn) return false; show_btn.addeventlistener( "click", function() { show_btn.style.width = 0; sidecontent.style.width = "154px"; }, false ); }; //����qq���� var slideclose = function() { if (!close_btn) return false; close_btn.addeventlistener( "click", function() { console.log(this); sidecontent.style.width = 0; show_btn.style.width = "25px"; }, false ); }; //���س����ķ��� return { init: function() { scrollmove(); slideclose(); slideshow(); } }; })(); //��ʼ�� serviceonline.init(); })();