html - Make Cursor position in center for ui.helper in jquery-ui draggable method -


i want cursor in center ui.helper of draggable .

i doing this

$(".soclass").draggable({            cursor: "move",           helper: 'clone',           revert: "invalid",           tolerance: "fit",           start: function(event, ui){               $(this).draggable("option", "cursorat", {             left: math.floor(ui.helper.width() / 2),             top: math.floor(ui.helper.height() / 2)           });              }        }); 

using i cursor in center after first drop. how can center align cursor right first drop.

jsfiddle

you can access offset.click property of draggable instance, pretty setting cursor @ option problem setting option, describe it'll applied next time trigger start event. using property can set on current event. this:

start: function(event, ui){     $(this).draggable('instance').offset.click = {     left: math.floor(ui.helper.width() / 2),     top: math.floor(ui.helper.height() / 2) };  

https://jsfiddle.net/38fay00b/


Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -