Commit 21ac1366 by Matjaz Gregoric

Fix item positioning on grab.

We were invoking grabItem too early. grabItem redraws the element
already absolutely positioned, which messes with offset measuring.
It was causing items to "jump" to the left a few pixels after grabbed.
parent 760a7d6a
...@@ -1384,7 +1384,6 @@ function DragAndDropBlock(runtime, element, configuration) { ...@@ -1384,7 +1384,6 @@ function DragAndDropBlock(runtime, element, configuration) {
var item_id = $item.data('value'); var item_id = $item.data('value');
var item = getItemById(item_id); var item = getItemById(item_id);
var $document = $(document); var $document = $(document);
grabItem($item, 'mouse');
publishEvent({ publishEvent({
event_type: 'edx.drag_and_drop_v2.item.picked_up', event_type: 'edx.drag_and_drop_v2.item.picked_up',
item_id: item_id item_id: item_id
...@@ -1392,7 +1391,6 @@ function DragAndDropBlock(runtime, element, configuration) { ...@@ -1392,7 +1391,6 @@ function DragAndDropBlock(runtime, element, configuration) {
var max_left = $container.innerWidth() - $item.outerWidth(); var max_left = $container.innerWidth() - $item.outerWidth();
var max_top = $container.innerHeight() - $item.outerHeight(); var max_top = $container.innerHeight() - $item.outerHeight();
var item_size = {width: $item.width(), height: $item.height()};
// We need to get the item position relative to the $container. // We need to get the item position relative to the $container.
var item_offset = $item.offset(); var item_offset = $item.offset();
var container_offset = $container.offset(); var container_offset = $container.offset();
...@@ -1400,8 +1398,9 @@ function DragAndDropBlock(runtime, element, configuration) { ...@@ -1400,8 +1398,9 @@ function DragAndDropBlock(runtime, element, configuration) {
left: item_offset.left - container_offset.left, left: item_offset.left - container_offset.left,
top: item_offset.top - container_offset.top top: item_offset.top - container_offset.top
}; };
item.drag_position = original_position; item.drag_position = original_position;
applyState(); grabItem($item, 'mouse');
// Animate the item back to its original position in the bank. // Animate the item back to its original position in the bank.
var revertDrag = function() { var revertDrag = function() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment