页脚不会从上隐藏的div设置动态高度

时间:2015-03-20 12:40:11

标签: jquery css

我尝试过下面的代码来计算页脚偏移量(.footer)和隐藏的场地详细信息#venue-detail顶部偏移量,但它仅适用于我的屏幕,我希望每个屏幕都计算高度和设置列表 - 集装箱高度。

 var $last_venue_items = Array();
        var last_venue_selected = -1;
        var venue_details_pos_top = 0;

        function   setup_grid_venues() {

            $('.search-venue-item').each(function (index, element) {

                setup_grid_data(index, element);
                $(element).click(function (e) {

                    $('.footer').css({'margin-top': '1px'});
                    //count col position of venue.
                    var venue_details_col = $(this).data('col-pos');
                    var $last_no_margin_venue = $(element);
                    for (i = 1; i <= grid_col_total - venue_details_col; i++) {
                        $last_no_margin_venue = $last_no_margin_venue.next();

                    }
                    var $current_venue_items = [$last_no_margin_venue.next()];
                    for (i = 0; i < grid_col_total - 1; i++) {
                        $current_venue_items.push($current_venue_items[ i ].next());
                    }
                    for (i in $last_venue_items) {
                        $last_venue_items[ i ].css('margin-top', 0);
                    }
                    if (last_venue_selected != index) {

                        for (i in $current_venue_items) {
                            $current_venue_items[ i ].css('margin-top', 350);

                        }
                    }
                    if (last_venue_selected == index) {
                        $venue_detail.css('top', venue_details_pos_top).hide();
                        last_venue_selected = -1;
                    } else {

                        venue_details_pos_top = $(this).offset().top + $(this).height() - 6;

                        $venue_detail.css('top', venue_details_pos_top).show();

                        var venue_detail_notch_class = 'notch notch-' + venue_details_col + '-' + grid_col_total;

                        $('.notch').removeAttr('class').addClass('venue_detail_notch_class');
                        setTimeout(function () {

                            for (i in $current_venue_items) {
                                $current_venue_items[ i ].css('margin-top', 350);
                            }
                        }, 10)
                        last_venue_selected = index;
                        $('html,body').animate({scrollTop: venue_details_pos_top - 120}, 350);
                    }

                    $('.list-container').css('height', 'auto');

                    var footer_offset = $('.footer').offset().top - 26;
                    var detail_offset = $('#venue-detail').offset().top + 102;
                    if (footer_offset == detail_offset || footer_offset == detail_offset - 101 || footer_offset == detail_offset + 15 || footer_offset == detail_offset - 15 ) {

                        var total_height = $('.list-container').height() + 390;
                        $('.list-container').css('height', total_height);
                     }
                    else
                    {
                        $('.list-container').css('height', 'auto');
                    }

                    $last_venue_items = $current_venue_items;

                    var id = $(this).attr('id');
                    var cat_id = $(this).data('id');
                    getDetalis(id, venue_detail_notch_class, cat_id);
                    $("abbr.timeago").timeago();
                });

            });

        }

0 个答案:

没有答案