Created
August 6, 2019 07:08
-
-
Save M1TKO/d35c75c40313ed79e089e69a4b7ad8db to your computer and use it in GitHub Desktop.
jQuery sortable fix scrolling top when on the bottom of a page
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(".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