Floating Sidebar Widget - Cố định Widget khi scroll chuột

dinhhai

MasterCorporal
Tham gia
28/07/2015
Bài viết
399
Được Like
198
Bác @PVS cho mình hỏi
Đoạn này ở đâu bác nhỉ?

<div id="sticky">
Code quảng cáo
</div>
Thay sticky bằng id của Sidebar bạn cần dùng. Chúc các bạn thành công.
 

PVS

Super Moderator
Thành viên BQT
Tham gia
28/02/2015
Bài viết
16,734
Được Like
12,680
đoạn đó là thêm vào bạn
 

Dong

Private
Tham gia
20/07/2016
Bài viết
31
Được Like
19
mình làm mãi ko dc mới đăng hỏi, ai biết hướng dẫn chi tiết dùm với
file js mình down về rồi giải nén vào thư mục js hay thư mục Widget Framework trong js ?
widget mình có dạng admin.php?widgets/26/edit thì sửa trong file fixer.js là var summaries = $('#widget-26'); có phải không ạ ? Mình đã làm tất cả như trên rồi mà vẫn không thành công
Xin hỏi là phần update đó là như nào ạ, là phải thay toàn bộ nội dung trong file fixer.js hay là thêm vào cuối của nó ?
Mong các bác giúp cho
 

Dong

Private
Tham gia
20/07/2016
Bài viết
31
Được Like
19
Sửa lần cuối:

dinhhai

MasterCorporal
Tham gia
28/07/2015
Bài viết
399
Được Like
198
Đúng rùi bác ạ, cố định cái quảng cáo
 

phankt

Corporal
Tham gia
23/08/2016
Bài viết
116
Được Like
25
Em tạo một cái widget là bài viết mới thì áp dụng như trên đúng không.
muốn làm 1 cái như seomxh. nhìn code fix.js đoạn code trên không biết cho vào đâu nữa..
Thêm vào hay thay thế toàn bộ.
CODE trong file fix.js thêm vào đâu vậy các bác
Mã:
function sticky()
{

$(document).ready(function() {
        var summaries = $('#widget-13');
        summaries.each(function(i) {
            var summary = $(summaries[i]);
            var next = summaries[i + 1];

            summary.scrollToFixed({
                marginTop:54,
                limit: function() {
                    var limit = 0;
                    if (next) {
                        limit = $(next).offset().top - $(this).outerHeight(true) - 50;
                    } else {
                        limit = $('.footer').offset().top - $(this).outerHeight(true) - 54;
                    }
                    return limit;
                },
                zIndex: 100
            });
        });
        });
$(document).ready(function() {
        var summaries = $('#topmenu');
        summaries.each(function(i) {
            var summary = $(summaries[i]);
            var next = summaries[i + 1];

            summary.scrollToFixed({
                marginTop:0,
                limit: function() {
                    var limit = 0;
                    if (next) {
                        limit = $(next).offset().top - $(this).outerHeight(true) - 50;
                    } else {
                        limit = $('.footer').offset().top - $(this).outerHeight(true) - 40;
                    }
                    return limit;
                },
                zIndex: 9999
            });
        });
        });

}

function detectcode() {
    if (navigator.userAgent.match(/Android/i)
            || navigator.userAgent.match(/webOS/i)
            || navigator.userAgent.match(/iPhone/i)
            || navigator.userAgent.match(/iPad/i)
            || navigator.userAgent.match(/iPod/i)
            || navigator.userAgent.match(/BlackBerry/i)
            || navigator.userAgent.match(/Windows Phone/i)
            || navigator.userAgent.match(/Opera Mini/i)
            || navigator.userAgent.match(/IEMobile/i)
            ) {
        isMobile = true;
    }
    else
    {
        sticky();   
    }
    
};

detectcode();
 
  • Like
Reactions: THB

tuna

Sergeant
Tham gia
30/01/2017
Bài viết
639
Được Like
276
@PVS đoạn
<div id="sticky">
Code quảng cáo
</div>

Thêm vào trong widget hả bác?
 
  • Like
Reactions: THB

tuna

Sergeant
Tham gia
30/01/2017
Bài viết
639
Được Like
276
Ủa cái na
Mã:
<script>
if(screen.width >800){
 
    var $stickyHeight = 447; // chiều cao của banner quảng cáo
    var $padding = 10; // khoảng cách top của banner khi dính
    var $topOffset = 140; // khoảng cách từ top của banner khi bắt đầu dính (tức là khoảng cách tính từ trên xuống đến vị trí đặt banner )
    var $footerHeight = 230; // Định vị điểm dừng của banner, tính từ chân lên
    /* <=!=[=C=D=A=T=A=[ */
    function scrollSticky(){
    var $mai_wid = $('.mainContent').width();
    var $pag_wid=  $('.pageContent').width();
    $mai_wid+=(screen.width-$pag_wid)/2;
    if (screen.width < 1024) $mai_wid+=10;
    if($(window).height() >= $stickyHeight) {
       var aOffset = $('#sticky').offset();
    if($(document).height() - $footerHeight - $padding < $(window).scrollTop() + $stickyHeight) {
           var $top =  $('.mainContainer').height()-$('.sidebar').height()-30;
           $('#sticky').attr('style', 'position:absolute; top:'+$top+'px;left:'+$mai_wid+'px;');
   
   
       }else if($(window).scrollTop() + $padding > $topOffset) {
           $('#sticky').attr('style', 'position:fixed; top:'+$padding+'px;left:'+$mai_wid+'px;');
    }else{
           $('#sticky').attr('style', 'position:relative;');
       }
    }
    }
    $(window).scroll(function(){
    scrollSticky();
    });
    /* ]=]=> */
}
</script>

Thấy hay update thêm vài biến nghịch
Khi trượt tới ô bình luận nó có nhả ra như vnxf ko bác?
 

Hướng dẫn sử dụng

XenForo 1 XenForo 2
Translate by PVS

Dịch vụ XenForo của VNXF

Mr. Tuấn

Mobile/Zalo: 0988 488 096

Telegram: bluekpro

Email: [email protected]

Nhà Tài Trợ

Mút Xốp Không Gian
pallet Thịnh Phát
Top Bottom