jQuery Draggable IFrameFix

两盒软妹~` 提交于 2019-12-05 02:36:53

Solved it.

I created my own overlay over my iframe and when I start dragging I display it and hide it when I stop. This way the iframe doensn't mess with the dragging.

Yes, you can put a div over the iframe, i use this function:

div.draggable{ 
    cancel: '.noDraggable',
    scroll: false,
            appendTo: 'body',
            zIndex: 9999,
            cursor: "move",
            distance: 10,
            iframeFix: true,

            start: function(){
            var iframe = $(this).find("iframe");
                if(iframe.length > 0){
                div(iframe.parent(), "img/blank.gif", "transparent");  
                }
            },


            stop: function(){
                $(this).find(".capaCargando").remove();
            }

});

And this is the function

function capaCargando(div, img, color){
                                if(div.length > 0){
                                    //div.find('.capaCargando').remove();
                                    //aLaConsola(div.find('.capaCargando').length);
                                    if(img == undefined){
                                        img = 'img/uispoty/loadBusqueda.gif';
                                    }

                                    if(color == undefined){
                                        color = '#666';
                                    }

                                    var w = div.width(),
                                    h = div.height(),
                                    html = "<div class='capaCargando'>"+
                                    "<div class='bgCapaCargando' style='background-color:"+color+"'></div>"+
                                    "<div class='iconoCapaCargando' style='background-image:url("+img+")'></div>"+
                                    "</div>";
                                    div.prepend(html);
                                    var capa = div.find(".capaCargando");
                                    capa.find(".bgCapaCargando, .iconoCapaCargando").width(w).height(h);
                                }
                           }

You need study this code because i use this for my project, with clases and other things, but sure you understand the concept.

Brian Dillingham

Here is some code to illustrate the correct answer given by jeroenjoosen located here


CSS

.frameOverlay {
     height: 100%;
     width: 100%;
     background: rgba(34, 34, 34, 0.5); // transparent is an option or a color
     position: absolute;
     top: 0;
     left: 0;
     display: none;
}



HTML

<div class="frameOverlay"></div> <!--place anywhere within the body -->



Jquery

<script>
      $(function() {
        $( "#draggable" ).draggable({
            start: function() {
                $('.frameOverlay').fadeIn('fast');
            },
            stop: function() {
                $('.frameOverlay').fadeOut('fast');
            }
        });
      });
</script>



易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!