<script>
(function($) {
var $doc = $(document);
var $win = $(window);
$(#leftmenu).scrollFollower = function (options){
var options = $.extend({}, $(#leftmenu).scrollFollower.defaults, options);
if (options.pageWidth)
var pageWidth = parseInt(options.pageWidth);
else
{
alert('pageWidth는 필수 옵션값입니다.');
return false;
}
var $layer = $(this);
var varType = options.varType;
var pageAlign = options.pageAlign;
var offset = pageWidth/2;
var layerPositon = options.type;
var margin = parseInt(options.margin);
var speed = parseInt(options.speed);
var easing = options.easing;
var topMargin = parseInt(options.topMargin);
var minTop = parseInt(options.minTop);
var marginResult = offset + margin;
var settedtop = topMargin + minTop;
$layer.css('z-index', options.zindex);
$layer.css("position","absolute");
if (layerPositon === 'left')
varType = 'right';
function resetXPosition()
{
if (pageAlign === 'center')
{
var $screenSize = $('body').width();
var halfScreenSize = $screenSize/2;
xPosition = halfScreenSize + marginResult;
}
else if (pageAlign === 'left')
{
varType = 'left';
xPosition = pageWidth + margin;
}
$layer.css(varType, xPosition);
}
resetXPosition();
$layer.css('top',topMargin);
$win.resize(resetXPosition);
$win.scroll(function(){
$top = $doc.scrollTop();
if ($top > settedtop)
yPosition = $top + minTop;
else if ($top < topMargin)
yPosition = topMargin;
$layer.animate({"top":yPosition }, {duration:speed, easing:easing, queue:false});
});
};
$.fn.scrollFollower.defaults = {
varType:'left',
pageAlign:'left',
type:'left',
topMargin:0,
minTop:0,
margin:0,
speed:1000,
easing:'linear',
zindex:10
};
})( jQuery );
</script>