Wie kann ich das Problem mit Auswahl in JQuery Horizontal Scrolling Div beheben?
Posted: 25 Jan 2025, 10:24
JQuery Horizontal Scrolling Div> Inneren Auswählen
Problem: Wählen Sie nicht öffnen (weil das Ereignis von MouseDown in MouseDown zurückgeben)
Wenn Löschen von Falsch FALSE - Wählen Sie beim Ziehen aus.
Ich muss klicken und ziehen. Scrollen Sie wie Berührungsgeräte: Wenn Sie auf Klicken auf auswählen - Wählen Sie das Öffnen aus. Wenn Sie einziehen, wählen Sie nicht öffnen. Hilfe bei der Behebung. Br />
Problem: Wählen Sie nicht öffnen (weil das Ereignis von MouseDown in MouseDown zurückgeben)
Wenn Löschen von Falsch FALSE - Wählen Sie beim Ziehen aus.
Ich muss klicken und ziehen. Scrollen Sie wie Berührungsgeräte: Wenn Sie auf Klicken auf auswählen - Wählen Sie das Öffnen aus. Wenn Sie einziehen, wählen Sie nicht öffnen. Hilfe bei der Behebung. Br />
Code: Select all
$('.scroll-container').mousedown(function (e) {
$(this)
.data('down', true)
.data('x', e.clientX)
.data('scrollLeft', this.scrollLeft)
return false; // prevent default behavior
}).mousemove(function (e) {
if ($(this).data('down') == true) {
this.scrollLeft = $(this).data('scrollLeft') + $(this).data('x') - e.clientX;
$(this).addClass('dragging');
}
}).mouseup(function (e) {
$(this)
.data('down', false)
.removeClass('dragging');
});
// in case mouse slides off the block,
// to avid sticking to it
$(document).mouseup(function (e) {
$('.scroll-container')
.data('down', false)
.removeClass('dragging');
});< /code>
.scroll-container {
overflow-x: auto;
padding: 10px;
width: 800px;
cursor: grab;
}
.dragging {
cursor: grabbing;
}
.list {
display: flex;
gap: 20px;
width: max-content;
}
.button {
font-family: arial, helvetica, serif;
background: #ccc;
width: fit-content;
padding: 15px;
border-radius: 1 0 p x ; < b r / > } < / c o d e > < b r / > < p r e c l a s s = " s n i p p e t - c o d e - h t m l l a n g - h t m l P r e t t y p r i n t - o v e r r i d e " > < c o d e > & l t ; d i v c l a s s = " s c r o l l - c o n t a i n e r " & g t ; < b r / > & l t ; d i v c l a s s = " l i s t " & g t ; < b r / > & l t ; d i v c l a s s = " b u t t o n " & g t ; < b r / > & l t ; d i v c l a s s = " b u t t o n _ _ t i t l e " & g t ; S t a t u s & l t ; / d i v & g t ; < b r / > & l t ; d i v c l a s s = " b u t t o n _ _ s e l e c t " & g t ; < b r / > & l t ; s e l e c t c l a s s = " u i _ _ b u t t o n - s e l e c t " r e q u i r e d & g t ; < b r / > & l t ; o p t i o n v a l u e = " 1 " s e l e c t e d & g t ; C o n f i r m e d & l t ; / o p t i o n & g t ; < b r / > & l t ; o p t i o n v a l u e = " 3 " & g t ; R e q u i r e s A t t e n t i o n & l t ; / o p t i o n & g t ; < b r / > & l t ; o p t i o n v a l u e = " 4 " & g t ; D e n i e d & l t ; / o p t i o n & g t ; < b r / > & l t ; / s e l e c t & g t ; < b r / > & l t ; / d i v & g t ; < b r / > & l t ; / d i v & g t ; < b r / > & l t ; d i v c l a s s = " b u t t o n " & g t ; < b r / > & l t ; d i v c l a s s = " b u t t o n _ _ t i t l e " & g t ; S t a t u s & l t ; / d i v & g t ; < b r / > & l t ; d i v c l a s s = " b u t t o n _ _ s e l e c t " & g t ; < b r / > & l t ; s e l e c t c l a s s = " u i _ _ b u t t o n - s e l e c t " r e q u i r e d & g t ; < b r / > & l t ; o p t i o n v a l u e = " 1 " s e l e c t e d & g t ; C o n f i r m e d & l t ; / o p t i o n & g t ; < b r / > & l t ; o p t i o n v a l u e = " 3 " & g t ; R e q u i r e s A t t e n t i o n & l t ; / o p t i o n & g t ; < b r / > & l t ; o p t i o n v a l u e = " 4 " & g t ; D e n i e d & l t ; / o p t i o n & g t ; < b r / > & l t ; / select>
Status
Confirmed
Requires Attention
Denied
Status
Confirmed
Requires Attention
Denied
Status
Confirmed
Requires Attention
Denied
Статус
Confirmed
Requires Attention
Denied
Статус
Confirmed
Requires Attention
Denied
Статус
Confirmed
Requires Attention
Denied
Статус
Confirmed
Requires Attention
Denied
Статус
Confirmed
Requires Attention
Denied
Статус
Confirmed
Requires Attention
Denied