javascript - Drag-and-drop from div with scrollbars - overflow-y scroll VS overflow-x visible -


i've set jquery drag-and-drop div div , works fine.

however, source div exceeds screen's height needed add vertical scrollbar it. here's run trouble infamous overflow-y issue.

the div needs have overflow-x: visible in order dragged elements visible moved target div. but, when add overflow-y: scroll or overflow-y: auto source div, overflow-x doesn't work anymore.

i have been w3 , few stackoverflow questions, , realise not bug intended behavior (although why intended beyond me). however, haven't found solution works me.

i've tried adding wrapper div source div answers suggested, , doing following:

.wrapper {     width: 100px;     position: absolute;     top: 4vw;     left: 0;     bottom: 4vw;     overflow-y: auto; }  .source {     position: relative;     overflow: visible;     z-index: 2; }  <div class="wrapper">     <div class="source">         <!-- draggable elements go here -->     </div> </div>  <div class="target">     <!-- draggable elements drop here --> </div> 

but, despite source div's overflow being ok now, wrapper still hides horizontal overflow. suppose increase width of wrapper full screen , make background invisible , make else on screen have higher z-index in order not behind wrapper, seems ridiculously bad solution such simple issue.

can me here?

if css solution isn't practical, can offer piece of javascript might resolve problem?

code sample: jsfiddle

please check following. if want drag elements , "drop" them on battle positions, may want use helper: "clone" in combination appendto: "body" or other selector items dropped. i've added containment: 'window' , scroll: false (not sure if last 1 want).

function make_draggable(elem){     $(elem).draggable({         revert: "invalid",         cursor: "move",         helper: 'clone',         appendto: 'body',                     containment: 'window',         scroll: false,     }); } 

there's been few css fixes styles still apply on draggable clones , body covers full area (since child positionated absolute, need force body cover full height/width)

https://jsfiddle.net/9ush466w/6/

edit: adding custom class , removing on original element can show feedback user. https://jsfiddle.net/9ush466w/8/


Comments

Popular posts from this blog

Spring Boot + JPA + Hibernate: Unable to locate persister -

go - Golang: panic: runtime error: invalid memory address or nil pointer dereference using bufio.Scanner -

c - double free or corruption (fasttop) -