From c4b7f1f9f062c64ce65970ae1c6edea4ec592a35 Mon Sep 17 00:00:00 2001 From: Paul Bakaus Date: Tue, 30 Dec 2008 10:05:51 +0000 Subject: demos: added opacity, revert and scroll demos draggable: fixed positioning issue with relative positioned elements relative to the body during scroll --- demos/draggable/index.html | 3 +++ demos/draggable/opacity.html | 31 +++++++++++++++++++++++++++++++ demos/draggable/revert.html | 31 +++++++++++++++++++++++++++++++ demos/draggable/scroll.html | 38 ++++++++++++++++++++++++++++++++++++++ tests/visual/draggable.scroll.html | 4 ++++ ui/ui.draggable.js | 12 +++++++++++- 6 files changed, 118 insertions(+), 1 deletion(-) create mode 100644 demos/draggable/opacity.html create mode 100644 demos/draggable/revert.html create mode 100644 demos/draggable/scroll.html diff --git a/demos/draggable/index.html b/demos/draggable/index.html index 8655800f3..dbc2405e9 100644 --- a/demos/draggable/index.html +++ b/demos/draggable/index.html @@ -16,6 +16,9 @@
Grid
Handle
Helper
+
Opacity
+
Revert
+
Scroll
diff --git a/demos/draggable/opacity.html b/demos/draggable/opacity.html new file mode 100644 index 000000000..0848f494d --- /dev/null +++ b/demos/draggable/opacity.html @@ -0,0 +1,31 @@ + + + + jQuery UI Draggable - Opacity + + + + + + + + + + +
+

Opacity set to 0.5

+
+ +
+

Opacity set to 0.5, using 'clone' as helper

+
+ + + diff --git a/demos/draggable/revert.html b/demos/draggable/revert.html new file mode 100644 index 000000000..065d85231 --- /dev/null +++ b/demos/draggable/revert.html @@ -0,0 +1,31 @@ + + + + jQuery UI Draggable - Revert + + + + + + + + + + +
+

Revert the original

+
+ +
+

Revert the helper

+
+ + + diff --git a/demos/draggable/scroll.html b/demos/draggable/scroll.html new file mode 100644 index 000000000..e27fa10e6 --- /dev/null +++ b/demos/draggable/scroll.html @@ -0,0 +1,38 @@ + + + + jQuery UI Draggable - Scroll + + + + + + + + + + +
+

Scroll set to true, default settings

+
+ +
+

scrollSensitivity set to 100

+
+ +
+

scrollSpeed set to 100

+
+ +
+ + + diff --git a/tests/visual/draggable.scroll.html b/tests/visual/draggable.scroll.html index ce788dbae..f384d415f 100644 --- a/tests/visual/draggable.scroll.html +++ b/tests/visual/draggable.scroll.html @@ -47,6 +47,10 @@ +
Simple draggable
+
+ +
(Broken in IE)
diff --git a/ui/ui.draggable.js b/ui/ui.draggable.js index f667c3b36..e6ccc2280 100644 --- a/ui/ui.draggable.js +++ b/ui/ui.draggable.js @@ -588,13 +588,23 @@ $.ui.plugin.add("draggable", "scroll", { - //This is a special case where we need to modify a offset calculated on start, since the following happened: + // This is a special case where we need to modify a offset calculated on start, since the following happened: // 1. The position of the helper is absolute, so it's position is calculated based on the next positioned parent // 2. The actual offset parent is a child of the scroll parent, and the scroll parent isn't the document, which means that // the scroll is included in the initial calculation of the offset of the parent, and never recalculated upon drag if(scrolled !== false && i.cssPosition == 'absolute' && i.scrollParent[0] != document && $.ui.contains(i.scrollParent[0], i.offsetParent[0])) { i.offset.parent = i._getParentOffset(); + } + + // This is another very weird special case that only happens for relative elements: + // 1. If the css position is relative + // 2. and the scroll parent is the document or similar to the offset parent + // we have to refresh the relative offset during the scroll so there are no jumps + if(scrolled !== false && i.cssPosition == 'relative' && !(i.scrollParent[0] != document && i.scrollParent[0] != i.offsetParent[0])) { + i.offset.relative = i._getRelativeOffset(); + } + } }); -- cgit v1.2.3