Skip to content

Commit c29b282

Browse files
committed
! Fix items moving back and forth if video dragged to a certain position
1 parent 1f656a0 commit c29b282

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/renderer/views/Playlist/Playlist.vue

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@
9292
:is-video-dragging="isVideoDragging()"
9393
@drag-video="setDraggedVideo"
9494
@drag-video-end="onDragVideoEnd"
95-
@move-dragged-video="moveDraggedVideoTemporarily"
95+
@move-dragged-video="moveDraggedVideoTemporarilyThrottled"
9696
@move-video-up="moveVideoUp"
9797
@move-video-down="moveVideoDown"
9898
@remove-from-playlist="removeVideoFromPlaylist"
@@ -125,7 +125,7 @@
125125
:is-video-dragging="isVideoDragging()"
126126
@drag-video="setDraggedVideo"
127127
@drag-video-end="onDragVideoEnd"
128-
@move-dragged-video="moveDraggedVideoTemporarily"
128+
@move-dragged-video="moveDraggedVideoTemporarilyThrottled"
129129
@move-video-up="moveVideoUp"
130130
@move-video-down="moveVideoDown"
131131
@remove-from-playlist="removeVideoFromPlaylist"
@@ -200,6 +200,7 @@ import {
200200
getIconForSortPreference,
201201
showToast,
202202
deepCopy,
203+
throttle,
203204
} from '../../helpers/utils'
204205
import { invidiousGetPlaylistInfo, youtubeImageUrlToInvidious } from '../../helpers/api/invidious'
205206
import { getSortedPlaylistItems, videoDurationPresent, videoDurationWithFallback, SORT_BY_VALUES } from '../../helpers/playlists'
@@ -837,6 +838,10 @@ function moveDraggedVideoTemporarily({ videoId, playlistItemId }, { videoId: dro
837838
tempShownPlaylistItems.value = playlistItems_
838839
}
839840
841+
// Only fire once per 100ms to prevent items moving up and down repeatedly during transition
842+
// 100ms is manually tested value (50ms won't work)
843+
const moveDraggedVideoTemporarilyThrottled = throttle(moveDraggedVideoTemporarily, 100)
844+
840845
/**
841846
* @param {string} videoId
842847
* @param {string} playlistItemId

0 commit comments

Comments
 (0)