GithubHelp home page GithubHelp logo

maxazan / jquery-ui-droppable-iframe Goto Github PK

View Code? Open in Web Editor NEW
17.0 17.0 10.0 0 B

Use your droppable zones inside iframe

Home Page: http://maxazan.github.io/jquery-ui-droppable-iframe/

License: MIT License

JavaScript 5.59% CSS 15.94% HTML 78.46%

jquery-ui-droppable-iframe's People

Contributors

maxazan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

jquery-ui-droppable-iframe's Issues

nested droppable in iframe

this solution works great until I have nested droppables in iframe.

I've to replace ui.droppable._drop method, to prevent resetting droppables' offset attribute, see below:

//修复在iframe中,错误的重置了元素的 offset 的bug
var intersect = $.ui.intersect;
$.widget('ui.droppable', $.ui.droppable, {

    _drop: function( event, custom ) {

        var draggable = custom || $.ui.ddmanager.current,
            childrenIntersection = false;

        // Bail if draggable and droppable are same element
        if ( !draggable || ( draggable.currentItem ||
            draggable.element )[ 0 ] === this.element[ 0 ] ) {
            return false;
        }

        this.element
            .find( ":data(ui-droppable)" )
            .not( ".ui-draggable-dragging" )
            .each( function() {
                var inst = $( this ).droppable( "instance" );
                ///////// !!! 重要修改, 这里如果已经赋值了,就不用再赋值, 解决 iframe 内部droppable元素定位错误的bug !!!!
                if( ! inst.offset ){
                    inst.offset = inst.element.offset();
                }
                ///////////////////////////////
                if (
                    inst.options.greedy &&
                    !inst.options.disabled &&
                    inst.options.scope === draggable.options.scope &&
                    inst.accept.call(
                        inst.element[ 0 ], ( draggable.currentItem || draggable.element )
                    ) &&
                    intersect(
                        draggable,
                        inst,
                        inst.options.tolerance, event
                    )
                ) {
                    childrenIntersection = true;
                    return false; }
            } );
        if ( childrenIntersection ) {
            return false;
        }

        if ( this.accept.call( this.element[ 0 ],
                ( draggable.currentItem || draggable.element ) ) ) {
            this._removeActiveClass();
            this._removeHoverClass();

            this._trigger( "drop", event, this.ui( draggable ) );
            return this.element;
        }

        return false;

    }

} );

Droppable zoomed using CSS scale

My droppable is inside an iframe that is scaled to 0.4 using CSS transform. It seems that jQuery UI is not able to calculate the offset properly when the droppable area is scaled. Any insight on how to adjust for this scenario?

Can you please support sortable as well?

It's a pity that the jquery-ui team doesn't support cross-window dragging [1] and it's great that you fix that for many people who need that!
I wonder how hard it is to make your solution work for sortables as well. I tried different possibilities now but didn't find a well working solution.

This fiddle shows the offset between the mouse pointer and the dragged element without your library included:
http://jsfiddle.net/e2kgbcbz/10

This is with your library included:
http://jsfiddle.net/e2kgbcbz/13

What do you think?

Best,
Sandro

[1] - just as a reference: https://bugs.jqueryui.com/ticket/7925

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.