Skip to content
Permalink
Browse files

demos: added opacity, revert and scroll demos

draggable: fixed positioning issue with relative positioned elements relative to the body during scroll
  • Loading branch information
Paul Bakaus
Paul Bakaus committed Dec 30, 2008
1 parent e9bb4f5 commit c4b7f1f9f062c64ce65970ae1c6edea4ec592a35
@@ -16,6 +16,9 @@
<dd><a href="grid.html">Grid</a></dd>
<dd><a href="handle.html">Handle</a></dd>
<dd><a href="helper.html">Helper</a></dd>
<dd><a href="opacity.html">Opacity</a></dd>
<dd><a href="revert.html">Revert</a></dd>
<dd><a href="scroll.html">Scroll</a></dd>
</dl>

</body>
@@ -0,0 +1,31 @@
<!doctype html>
<html lang="en">
<head>
<title>jQuery UI Draggable - Opacity</title>
<link type="text/css" href="../demos.css" rel="stylesheet" />
<link type="text/css" href="../../themes/default/ui.all.css" rel="stylesheet" />
<script type="text/javascript" src="../../jquery-1.2.6.js"></script>
<script type="text/javascript" src="../../ui/ui.core.js"></script>
<script type="text/javascript" src="../../ui/ui.draggable.js"></script>
<style type="text/css">
.ui-widget-content { width: 100px; height: 100px; padding: 0.5em; float: left; margin: 5px; }
</style>
<script type="text/javascript">
$(function() {
$("#draggable").draggable({ opacity: 0.5 });
$("#draggable2").draggable({ opacity: 0.5, helper: 'clone' });
});
</script>
</head>
<body>

<div id="draggable" class="ui-widget-content">
<p>Opacity set to 0.5</p>
</div>

<div id="draggable2" class="ui-widget-content">
<p>Opacity set to 0.5, using 'clone' as helper</p>
</div>

</body>
</html>
@@ -0,0 +1,31 @@
<!doctype html>
<html lang="en">
<head>
<title>jQuery UI Draggable - Revert</title>
<link type="text/css" href="../demos.css" rel="stylesheet" />
<link type="text/css" href="../../themes/default/ui.all.css" rel="stylesheet" />
<script type="text/javascript" src="../../jquery-1.2.6.js"></script>
<script type="text/javascript" src="../../ui/ui.core.js"></script>
<script type="text/javascript" src="../../ui/ui.draggable.js"></script>
<style type="text/css">
.ui-widget-content { width: 100px; height: 100px; padding: 0.5em; float: left; margin: 5px; }
</style>
<script type="text/javascript">
$(function() {
$("#draggable").draggable({ revert: true });
$("#draggable2").draggable({ revert: true, helper: 'clone' });
});
</script>
</head>
<body>

<div id="draggable" class="ui-widget-content">
<p>Revert the original</p>
</div>

<div id="draggable2" class="ui-widget-content">
<p>Revert the helper</p>
</div>

</body>
</html>
@@ -0,0 +1,38 @@
<!doctype html>
<html lang="en">
<head>
<title>jQuery UI Draggable - Scroll</title>
<link type="text/css" href="../demos.css" rel="stylesheet" />
<link type="text/css" href="../../themes/default/ui.all.css" rel="stylesheet" />
<script type="text/javascript" src="../../jquery-1.2.6.js"></script>
<script type="text/javascript" src="../../ui/ui.core.js"></script>
<script type="text/javascript" src="../../ui/ui.draggable.js"></script>
<style type="text/css">
.ui-widget-content { width: 100px; height: 100px; padding: 0.5em; float: left; margin: 5px; }
</style>
<script type="text/javascript">
$(function() {
$("#draggable").draggable({ scroll: true });
$("#draggable2").draggable({ scroll: true, scrollSensitivity: 100 });
$("#draggable3").draggable({ scroll: true, scrollSpeed: 100 });
});
</script>
</head>
<body>

<div id="draggable" class="ui-widget-content">
<p>Scroll set to true, default settings</p>
</div>

<div id="draggable2" class="ui-widget-content">
<p>scrollSensitivity set to 100</p>
</div>

<div id="draggable3" class="ui-widget-content">
<p>scrollSpeed set to 100</p>
</div>

<div style='height: 5000px; width: 1px;'></div>

</body>
</html>
@@ -47,6 +47,10 @@
</head>
<body>

<div class='draggable' style='z-index: 1000;'>Simple draggable</div>
<br clear='both' />


<div class='container' style="overflow:scroll;">
<div class='draggable'>(Broken in IE)</div>
<div class='enlarge'></div>
@@ -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();
}


}
});

0 comments on commit c4b7f1f

Please sign in to comment.
You can’t perform that action at this time.