Skip to content

Instantly share code, notes, and snippets.

@M1TKO
Created August 6, 2019 07:08
Show Gist options
  • Save M1TKO/d35c75c40313ed79e089e69a4b7ad8db to your computer and use it in GitHub Desktop.
Save M1TKO/d35c75c40313ed79e089e69a4b7ad8db to your computer and use it in GitHub Desktop.
jQuery sortable fix scrolling top when on the bottom of a page
$(".layers-container").sortable({
placeholder: "layer-empty",
containment: "parent",
tolerance: "pointer",
cursor: "grabbing",
})
.disableSelection();
var instance = $(".layers-container").data("ui-sortable");
instance.__createHelper = instance._createHelper;
instance._createHelper = function(event) {
this.scrollTop = this.element.scrollParent().scrollTop();
console.log("_createHelper", this.element.scrollParent()[0], this.scrollTop);
return this.__createHelper(event);
};
instance.__createPlaceholder = instance._createPlaceholder;
instance._createPlaceholder = function() {
this.__createPlaceholder();
console.log("_createPlaceholder", this.element.scrollParent()[0], this.scrollTop);
this.element.scrollParent().scrollTop(this.scrollTop);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment