jQuery UI sortable scroll helper element offset Firefox issue

前端 未结 15 2275
故里飘歌
故里飘歌 2020-12-07 22:32

I have a problem with a jQuery UI 1.7.2 sortable list in Firefox 3.6, IE7-8 work fine. When I\'m scrolled down a bit, the helper element seems to have an offset of the same

相关标签:
15条回答
  • 2020-12-07 23:01

    If you want to prevent browser sniffing, the CSS only solution is to set the ul or a container style to overflow: auto. If you look at the source through firebug, it's the way jQuery does it in their example.

    0 讨论(0)
  • 2020-12-07 23:02

    I "fixed" this using newer jQuery/jQuery UI versions.

    • jQuery 1.8.0
    • jQuery UI 1.8.23
    0 讨论(0)
  • 2020-12-07 23:03

    I also had this problem and fixed it with the following code:

    var wscrolltop = 0;
    $sortable_elements.sortable({ 
        start: function(event, ui) {
            wscrolltop = $(window).scrollTop();
        },
        sort: function(event, ui) {                   
            ui.helper.css({'top' : ui.position.top + wscrolltop + 'px'});
        }
    });
    

    I discovered, that there still is a problem if you scroll with your sortable-element. Maybe somebody has a solution for this?

    UPDATE: The fix is:

    $sortable_elements.sortable({ 
        connectWith: '#personal-favs ul.fitems',
        sort: function(event, ui) {  
            ui.helper.css({'top' : ui.position.top + $(window).scrollTop() + 'px'});
        }
    });
    

    But still - if you're leaving the list, the sort-event seems to stop.

    0 讨论(0)
提交回复
热议问题