javascript - Performance of Jquery draggable for 1000s of elements vs re-rendering the elements -


i working on app allows image dragged using draggable utility jquery. there numerous overlay divs associated image many components positioned pixel location. numbers in 1000s.

has done performance numbers on dragging these elements vs dragging image re-rendering other elements following drag?

i'm favoring later approach wanted see if has more insight.


i ended going single svg layer jquery draggable utility active $("#zones_imagesvg").draggable( "enable" ); , multiple rect, circles inside. svg layer drags without lag or skips. approach circumvents multiple div layer solution.

<svg id="zones_imagesvg" class="movecursor" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns="http://www.w3.org/2000/svg" height="430" width="549.4444444444445" style="position: relative;"> <image id="zones_image" width="549.4444444444445" height="430" y="0" x="0" xlink:href="./images/testcampus1_hq_floora.jpg"> <circle id="icon_sensor0" class="handle_svgattrcirc" cx="91.63777777777779" cy="287.14444444444445" r="1.9111111111111112" fill="red"> <circle id="icon_sensor1" class="handle_svgattrcirc" cx="272.0466666666667" cy="332.9155555555556" r="1.9111111111111112" fill="red"> <circle id="icon_sensor2" class="handle_svgattrcirc" cx="412.60888888888894" cy="221.40222222222224" r="1.9111111111111112" fill="red"> <circle id="icon_sensor3" class="handle_svgattrcirc" cx="410.3155555555556" cy="103.8688888888889" r="1.9111111111111112" fill="red"> <rect id="idattrrect0" class="handle_svgattrrect" x="512.1777777777778" y="73.38666666666667" height="74" width="88" fill="#3196bd"> <rect id="idattrrect1" class="handle_svgattrrect" x="416.62222222222226" y="54.27555555555556" height="54" width="48" fill="#3196bd"> <rect id="idattrrect2" class="handle_svgattrrect" x="321.0666666666667" y="25.60888888888889" height="24" width="38" fill="#3196bd"> <rect id="idattrrect3" class="handle_svgattrrect" x="129.95555555555558" y="44.720000000000006" height="44" width="44" fill="#dc143c"> <rect id="idattrrect4" class="handle_svgattrrect" x="416.62222222222226" y="35.16444444444445" height="84" width="38" fill="#a1dc14"> </svg> 

a quick sample shows 1000 subitems not seem cause issue. of course, ymmv depending on how complicated subitems get.

jsfiddle

code generate sample div:

$(function () {     $(".dragme").draggable();      var $dragme = $(".dragme.filled");      var maxtop = 250;     var maxleft = 400;      (i = 0; < 1000; i++)     {                 var $newsubitem = $("<div />")             .addclass("subitem");          var randomleft = math.random() * maxleft;         var randomtop = math.random() * maxtop;          $newsubitem.css({             left: randomleft,             top: randomtop         });          $dragme.append($newsubitem);     } }); 

Comments

Popular posts from this blog

java - Spring Data JPA: Why findOne(id) executing delete query internally? -

python - Mongodb How to add addtional information when aggregating? -

java - Incorrect order of records in M-M relationship in hibernate -