mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-24 23:48:13 -05:00
Fixed gallery image changing order randomly when dropped on itself (#1081)
no issue - clear the cached `insertIndex` when hiding the drop position indicator - update the gallery card's `_isDropAllowed` function to return `false` if the `droppabeIndex` (`insertIndex`) doesn't exist
This commit is contained in:
parent
a565abf5bb
commit
9ed6ea0f1e
2 changed files with 5 additions and 2 deletions
|
@ -487,8 +487,8 @@ export default Component.extend({
|
|||
// we don't allow an image to be dropped where it would end up in the
|
||||
// same position within the gallery
|
||||
_isDropAllowed(draggableIndex, droppableIndex, position = '') {
|
||||
// can't drop on itself
|
||||
if (draggableIndex === droppableIndex) {
|
||||
// can't drop on itself or when droppableIndex doesn't exist
|
||||
if (draggableIndex === droppableIndex || typeof droppableIndex === 'undefined') {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -409,6 +409,9 @@ export default Service.extend({
|
|||
// make sure the indicator isn't shown due to a running timeout
|
||||
run.cancel(this._dropIndicatorTimeout);
|
||||
|
||||
// clear droppable insert index
|
||||
delete this.draggableInfo.insertIndex;
|
||||
|
||||
// reset all transforms
|
||||
this._transformedDroppables.forEach((elem) => {
|
||||
elem.style.transform = '';
|
||||
|
|
Loading…
Add table
Reference in a new issue