2013-03-08 164 views
0

Iam构建一个jQuery项目,人们可以在地图上绘图,他们可以将div放在地图上,然后可以移动并调整大小。我想要一个边框更新div的当前宽度/高度,而他们正在调整它的大小。目前它的工作原理,但它只是在它们完成调整大小后才更新,但我希望它在调整大小时进行更新。与调整完成后只更新Jquery可调整大小显示大小,同时调整大小

我当前的代码:

$(item).resizable({ 
      grid: Math.round(gridStand), 
      stop : function(event,ui) { 
       endW = Math.round($(this).outerWidth()/gridStand); 
       endH = Math.round($(this).outerHeight()/gridStand); 
       $(this).attr('w', endW).attr('h', endH) 
       $('.standW').html('<h5>Breedte</h5><h4>'+($(item).attr('w')/2)+'</h4><span>meter</span>'); 
       $('.standH').html('<h5>Diepte</h5><h4>'+($(item).attr('h')/2)+'</h4><span>meter</span>') 
       } 
      }) 
      .draggable({ 
       grid: [ Math.round(gridStand), Math.round(gridStand) ], 
       containment: "#map", 
       scroll: false, 
       stop : function(event,ui) { 
        endX = Math.round($(this).position().left/gridStand); 
        endY = Math.round($(this).position().top/gridStand); 
        $(this).attr('x', endX).attr('y', endY) 
       } 
      }) 

有谁知道如何调整大小时改变这种做法,它更新,而不是只有当你做了调整?

回答

1

在调整大小时触发resize事件,每当调整大小的对象的大小发生变化时。你会想要使用它,而不是stop,它只在调整大小完成后触发一次。

+0

谢谢,它的工作原理!有点不好因为我真的尝试调整大小之前,但我忘了添加它计算的部分。 – Holapress 2013-03-08 09:52:03

相关问题