Mootools - How to get droppables css stats?
Hiya guys heres my question:
im using mootools and im using this demo-> Drag.Move!
everything works fine but i want to drop the item and modify the draggable items css position to that of the droppable item, just cant get the droppagble items stats i dont know how :S here is where the code goes of when i drop the item:
onDrop: function(element, droppable){
if (droppable) droppable.setStyle('background', '#C17878');
}
thats how to set them but i want something like this:
onDrop: function(element, droppable){
if (droppable) {
element.left = droppable.left;
element.top = droppable.top;
}
}
any help would be great!
ty in advance!
-Thaiscorpion.
SOLVED:
onDrop: function(element, droppable){
开发者_JAVA百科 if (droppable)
{
var snap_left = droppable.getStyle('left');
var snap_top = droppable.getStyle('top');
element.setStyle('left', snap_left );
element.setStyle('top', snap_top );
}
}
this worked for me in the end! hope it helps someone else!
You probably could do it in one line, with getStyles/setStyles instead of getStyle/setStyle.
onDrop: function(element, droppable){
if (droppable) element.setStyles(droppable.getStyles('left', 'top'));
}
精彩评论