0

First of all I'd like to say - I don't want someone to do my coding. I'm just looking for tips/pointers/suggestion.

Background:

I'm using jQuery and jQueryUI drag/drop

  1. I have a droppable div with dimensions 500px x 500px. This is #div-droppable.

  2. I have a draggable div with same dimensions as #div-droppable. Let us call it #div-draggable.

  3. There are a lot of draggable products from #div-draggable that are possible to drag to #div-droppable.

  4. Each product in #div-draggable has dimension 50px x 50px.

Example: I have dragged 50 products from #div-draggable to #div-droppable, and they are now absolutely positioned within the #div-droppable.

Now I want to save the content in #div-droppable to a third DIV called #div-draft. The #div-draft has the dimension 250px * 250px. I want the products located in #div-droppable being stored related to the #div-draft.

My thoughts:

If one dragged product is absolutely positioned within the #div-droppable with left: 50px and top:100px, the same product in #div-draft would be positioned with left:25px and top:50px (because #div-draft is half the size of #div-droppable). Also the size of each product would be half the size (25px * 25px)

I could do some calculation (as described above) of all products in #div-droppable and put each product in #div-draft

My question: Is there any other way/smarter way/better way of doing this? I'm basically looking to clone a certain divs (#div-droppable) content into another div (#div-draft) but I want the content to be resized relatively to the size of #div-draft.

4

1 に答える 1

1

もちろん、これをどのように行うかはコンテンツによって異なりますが、画像を使用しないことを前提としています。これが簡単な場合は、CSS を使用して画像のサイズを変更するだけです。.css()jQuery のメソッドを使用する関数を作成しない限り、コンテンツのグループを複製することはできません。CSS または jQuery ですべてを再計算する必要があります。

参照: http://api.jquery.com/css/

于 2013-07-08T23:06:00.337 に答える