@@ -185,38 +185,44 @@ test( "#5009: scroll not working with parent's position fixed", function() {
185
185
} ) ;
186
186
} ) ;
187
187
188
- test ( "#9379: Draggable: position bug in scrollable div" , function ( ) {
189
- expect ( 2 ) ;
190
-
191
- $ ( "#qunit-fixture" ) . html ( "<div id='o_9379'><div id='i_9379'></div><div id='d_9379'>a</div></div>" ) ;
192
- $ ( "#i_9379" ) . css ( { position : "absolute" , width : "500px" , height : "500px" } ) ;
193
- $ ( "#o_9379" ) . css ( { position : "absolute" , width : "300px" , height : "300px" } ) ;
194
- $ ( "#d_9379" ) . css ( { width : "10px" , height : "10px" } ) ;
195
-
196
- var moves = 3 ,
197
- startValue = 0 ,
198
- dragDelta = 20 ,
199
- delta = 100 ,
188
+ $ ( [ "hidden" , "auto" , "scroll" ] ) . each ( function ( ) {
189
+ var overflow = this ;
190
+
191
+ // http://bugs.jqueryui.com/ticket/9379 - position bug in scrollable div
192
+ // http://bugs.jqueryui.com/ticket/10147 - Wrong position in a parent with "overflow: hidden"
193
+ test ( "position in scrollable parent with overflow: " + overflow , function ( ) {
194
+ expect ( 2 ) ;
195
+
196
+ $ ( "#qunit-fixture" ) . html ( "<div id='outer'><div id='inner'></div><div id='dragged'>a</div></div>" ) ;
197
+ $ ( "#inner" ) . css ( { position : "absolute" , width : "500px" , height : "500px" } ) ;
198
+ $ ( "#outer" ) . css ( { position : "absolute" , width : "300px" , height : "300px" } ) ;
199
+ $ ( "#dragged" ) . css ( { width : "10px" , height : "10px" } ) ;
200
+
201
+ var moves = 3 ,
202
+ startValue = 0 ,
203
+ dragDelta = 20 ,
204
+ delta = 100 ,
205
+
206
+ // we scroll after each drag event, so subtract 1 from number of moves for expected
207
+ expected = delta + ( ( moves - 1 ) * dragDelta ) ,
208
+ element = $ ( "#dragged" ) . draggable ( {
209
+ drag : function ( ) {
210
+ startValue += dragDelta ;
211
+ $ ( "#outer" ) . scrollTop ( startValue ) . scrollLeft ( startValue ) ;
212
+ } ,
213
+ stop : function ( event , ui ) {
214
+ equal ( ui . position . left , expected , "left position is correct when grandparent is scrolled" ) ;
215
+ equal ( ui . position . top , expected , "top position is correct when grandparent is scrolled" ) ;
216
+ }
217
+ } ) ;
218
+
219
+ $ ( "#outer" ) . css ( "overflow" , overflow ) ;
200
220
201
- // we scroll after each drag event, so subtract 1 from number of moves for expected
202
- expected = delta + ( ( moves - 1 ) * dragDelta ) ,
203
- element = $ ( "#d_9379" ) . draggable ( {
204
- drag : function ( ) {
205
- startValue += dragDelta ;
206
- $ ( "#o_9379" ) . scrollTop ( startValue ) . scrollLeft ( startValue ) ;
207
- } ,
208
- stop : function ( event , ui ) {
209
- equal ( ui . position . left , expected , "left position is correct when grandparent is scrolled" ) ;
210
- equal ( ui . position . top , expected , "top position is correct when grandparent is scrolled" ) ;
211
- }
221
+ element . simulate ( "drag" , {
222
+ dy : delta ,
223
+ dx : delta ,
224
+ moves : moves
212
225
} ) ;
213
-
214
- $ ( "#o_9379" ) . css ( "overflow" , "auto" ) ;
215
-
216
- element . simulate ( "drag" , {
217
- dy : delta ,
218
- dx : delta ,
219
- moves : moves
220
226
} ) ;
221
227
} ) ;
222
228
0 commit comments