{"id":6676,"date":"2014-04-21T12:51:27","date_gmt":"2014-04-21T12:51:27","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/04\/21\/jquery-ui-sortable-scroll-helper-element-offset-firefox-issue-collection-of-common-programming-errors-2\/"},"modified":"2014-04-21T12:51:27","modified_gmt":"2014-04-21T12:51:27","slug":"jquery-ui-sortable-scroll-helper-element-offset-firefox-issue-collection-of-common-programming-errors-2","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/04\/21\/jquery-ui-sortable-scroll-helper-element-offset-firefox-issue-collection-of-common-programming-errors-2\/","title":{"rendered":"jQuery UI sortable scroll helper element offset Firefox issue-Collection of common programming errors"},"content":{"rendered":"<p>I managed to figure out a fix for this:<\/p>\n<pre><code>$( \"items\" ).sortable({\nstart: function (event, ui) {\n if( ui.helper !== undefined )\n  ui.helper.css('position','absolute').css('margin-top', $(window).scrollTop() );\n},\nbeforeStop: function (event, ui) {\n if( ui.offset !== undefined )\n  ui.helper.css('margin-top', 0);\n},\nplaceholder: 'placeholder-class'\n});\n<\/code><\/pre>\n<p>Basically, you need to listen for the sortable&#8217;s &#8220;start&#8221; event to add the browser&#8217;s current scrollTop() value to the helper&#8217;s position, and then you need to listen for the sortable&#8217;s &#8220;beforeStop&#8221; event, to remove that offset before the item is officially placed back into the list at its new position.<\/p>\n<p>Hope that&#8217;s helpful to someone!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I managed to figure out a fix for this: $( &#8220;items&#8221; ).sortable({ start: function (event, ui) { if( ui.helper !== undefined ) ui.helper.css(&#8216;position&#8217;,&#8217;absolute&#8217;).css(&#8216;margin-top&#8217;, $(window).scrollTop() ); }, beforeStop: function (event, ui) { if( ui.offset !== undefined ) ui.helper.css(&#8216;margin-top&#8217;, 0); }, placeholder: &#8216;placeholder-class&#8217; }); Basically, you need to listen for the sortable&#8217;s &#8220;start&#8221; event to add the [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-6676","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/6676","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=6676"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/6676\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=6676"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=6676"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=6676"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}