mirror of
https://github.com/jquery/jquery-ui.git
synced 2024-11-21 11:04:24 +00:00
Draggable: Added in iframeFix option
This commit is contained in:
parent
7941f7c13f
commit
1ca93b4a6c
56
ui/jquery.ui.draggable.js
vendored
56
ui/jquery.ui.draggable.js
vendored
@ -20,7 +20,8 @@ $.widget( "ui.draggable", {
|
||||
options: {
|
||||
helper: false,
|
||||
scrollSensitivity: 20,
|
||||
scrollSpeed: 20
|
||||
scrollSpeed: 20,
|
||||
iframeFix: false
|
||||
},
|
||||
|
||||
// dragEl: element being dragged (original or helper)
|
||||
@ -33,6 +34,36 @@ $.widget( "ui.draggable", {
|
||||
// overflowOffset: offset of scroll parent
|
||||
// overflow: object containing width and height keys of scroll parent
|
||||
|
||||
_blockFrames: function() {
|
||||
|
||||
var iframes = $('iframe'),
|
||||
widget = this;
|
||||
|
||||
this.iframeBlocks = $('');
|
||||
|
||||
iframes.each( function() {
|
||||
|
||||
var iframe = $(this),
|
||||
width = iframe.outerWidth(),
|
||||
height = iframe.outerHeight(),
|
||||
iframeOffset = iframe.offset(),
|
||||
block = $('<div />');
|
||||
|
||||
block.css({
|
||||
position: 'absolute',
|
||||
width: width+'px',
|
||||
height: height+'px',
|
||||
top: iframeOffset.top+'px',
|
||||
left: iframeOffset.left+'px'
|
||||
})
|
||||
.appendTo( widget.document[0].body );
|
||||
|
||||
widget.iframeBlocks = widget.iframeBlocks.add( block );
|
||||
|
||||
});
|
||||
|
||||
},
|
||||
|
||||
_create: function() {
|
||||
this.scrollParent = this.element.scrollParent();
|
||||
|
||||
@ -131,6 +162,10 @@ $.widget( "ui.draggable", {
|
||||
// The actual dragging element, should always be a jQuery object
|
||||
this.dragEl = this.element;
|
||||
|
||||
if ( this.options.iframeFix === true ) {
|
||||
this._blockFrames();
|
||||
}
|
||||
|
||||
// Helper required
|
||||
if ( this.options.helper ) {
|
||||
// clone
|
||||
@ -238,6 +273,11 @@ $.widget( "ui.draggable", {
|
||||
}
|
||||
|
||||
this.document.unbind( "." + this.widgetName );
|
||||
|
||||
if ( this.options.iframeFix === true ) {
|
||||
this._unblockFrames();
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
// Uses event to determine new position of draggable, before any override from callbacks
|
||||
@ -303,6 +343,20 @@ $.widget( "ui.draggable", {
|
||||
|
||||
return ret;
|
||||
|
||||
},
|
||||
|
||||
_unblockFrames: function() {
|
||||
|
||||
if ( !this.iframeBlocks || !this.iframeBlocks.length ) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.iframeBlocks.each( function() {
|
||||
|
||||
$(this).remove();
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user