jQuery UI sortable scroll helper element offset Firefox issue

前端 未结 15 2344
故里飘歌
故里飘歌 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 22:47

    To summarize your efforts and provide a completed solution. The following seemed to work for Chrome 40+ and Firefox 30+

    var isFirefox = /firefox/.test(navigator.userAgent.toLowerCase());
    $('#target').sortable({
        connectWith: '#target-holder .elements',
        handle: ".element-header",
        start: function(ev, ui) {
            if( isFirefox ) {
                ui.item.css('margin-top', $(window).scrollTop() );
            }
        },
        sort: function(ev, ui) {
            if( isFirefox) {
                ui.helper.css({'top' : ui.position.top - $(window).scrollTop() + 'px'});
            } else {
                ui.helper.css({'top' : ui.position.top + $(window).scrollTop() + 'px'});
            }
        },
        beforeStop: function (ev, ui) {
            if( isFirefox ) {
                ui.item.css('margin-top', 0 );
            }
        }
    });
    

提交回复
热议问题