/* Codificación UTF-8 */ /* FUNCIONES: * - checkVisible(elm, evalType) * - floatBar(barra) */ //function checkVisible( elm, evalType ) { $.fn.checkVisible = function(options) { var defaults = $.extend({ elm: '', evalType: '' },options); evalType = defaults.evalType || "visible"; elm = defaults.elm; if( typeof $(elm).offset() !== 'undefined' ) { var vpH = $(window).height(), // Viewport Height st = $(window).scrollTop(), // Scroll Top y = $(elm).offset().top, elementHeight = $(elm).height(); if (evalType === "visible") return ((y < (vpH + st)) && (y > (st - elementHeight))); if (evalType === "above") return ((y < (vpH + st))); } } $.fn.floatBar = function(options) { var defaults = $.extend({ barra: 'topBarPrimary', panel: 'P_lis' },options); $(window).bind("scroll", function() { var elem1 = $('#'+defaults.panel); var elem2 = $('#'+defaults.barra); elem2.removeClass('barraFlotante'); if( !$(window).checkVisible({ elm: elem2, evalType: 'visible'}) ) { elem2.addClass('barraFlotante'); } if( !$(window).checkVisible({ elm: elem1, evalType: 'visible'}) ) { elem2.removeClass('barraFlotante'); } }); }