-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Fix #9335: over & out events does not consistently fire. #1170
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -258,11 +258,112 @@ test( "over", function() { | |
| equal( overCount, 1, "over fires only once" ); | ||
| }); | ||
|
|
||
| test( "#9335: draggable over connected sortable fires over event", function() { | ||
| expect( 3 ); | ||
|
|
||
| var hash, | ||
| overCount = 0, | ||
| item = $( "<div></div>" ).text( "6" ).insertAfter( "#sortable" ); | ||
|
|
||
| item.draggable({ | ||
| connectToSortable: "#sortable" | ||
| }); | ||
| $( ".connectWith" ).sortable({ | ||
| connectWith: ".connectWith", | ||
| over: function( e, ui ) { | ||
| hash = ui; | ||
| overCount++; | ||
| } | ||
| }); | ||
|
|
||
| item.simulate( "drag", { | ||
| dy: -20 | ||
| }); | ||
|
|
||
| ok( hash, "over event triggered" ); | ||
| ok( !hash.sender, "UI should not include: sender" ); | ||
| equal( overCount, 1, "over fires only once" ); | ||
| }); | ||
|
|
||
| test( "#9335: over fires with connected sortable", function() { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm confused. What's the difference between this and the previous test?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. One is testing that the 'over' event fires when an outside item is brought over the list, the other tests that the event is fired when you pick up an element already present in the list. |
||
| expect( 3 ); | ||
|
|
||
| var hash, | ||
| overCount = 0; | ||
|
|
||
| $( ".connectWith" ).sortable({ | ||
| connectWith: ".connectWith" | ||
| }); | ||
| $( "#sortable2" ).on("sortover", function(e, ui) { | ||
| hash = ui; | ||
| overCount++; | ||
| }); | ||
| $( "#sortable" ).find( "li:eq(0)" ).simulate( "drag", { | ||
| dy: 102 | ||
| }); | ||
|
|
||
| ok( hash, "over event triggered" ); | ||
| equal( hash.sender[0], $(" #sortable" )[0], "UI includes: sender" ); | ||
| equal( overCount, 1, "over fires only once" ); | ||
| }); | ||
|
|
||
| /* | ||
| test("out", function() { | ||
| ok(false, "missing test - untested code is broken code."); | ||
| }); | ||
| */ | ||
|
|
||
| test( "#9335: out fires with connected sortable", function() { | ||
| expect( 2 ); | ||
|
|
||
| var hash, | ||
| outCount = 0; | ||
|
|
||
| $( ".connectWith" ).sortable({ | ||
| connectWith: ".connectWith" | ||
| }); | ||
| $( "#sortable" ).on( "sortout", function( e, ui ) { | ||
| hash = ui; | ||
| outCount++; | ||
| }); | ||
| $( "#sortable" ).find( "li:last" ).simulate( "drag", { | ||
| dy: 40 | ||
| }); | ||
|
|
||
| ok( hash, "out event triggered" ); | ||
| equal( outCount, 1, "out fires only once" ); | ||
| }); | ||
|
|
||
| test( "#9335: out & over & out & over", function() { | ||
| expect( 2 ); | ||
|
|
||
| var outCount = 0, | ||
| overCount = 0; | ||
|
|
||
| $( ".connectWith" ).sortable({ | ||
| connectWith: ".connectWith", | ||
| over: function() { | ||
| overCount++; | ||
| }, | ||
| out: function( e, ui ) { | ||
| // We don't care about the events that trigger when an item has dropped. | ||
| // Thus, we check for the presence of the helper. | ||
| if ( !ui.helper ) { | ||
| outCount++; | ||
| } | ||
| } | ||
| }); | ||
| $( "#sortable" ).find( "li:last" ).simulate( "drag", { | ||
| dy: 40 | ||
| }).simulate( "drag", { | ||
| dy: -40 | ||
| }); | ||
|
|
||
| equal( outCount, 2, "out fires twice" ); | ||
| equal( overCount, 4, "over fires four times" ); | ||
| }); | ||
|
|
||
| /* | ||
| test("activate", function() { | ||
| ok(false, "missing test - untested code is broken code."); | ||
| }); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
e-->eventThat change needs to happen a few times in this file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Every test uses that notation, not only the ones I added. There should be a separate commit changing every occurence if needed.