Performance of set[XY]Constraint with ticks
- While building an interface which uses a lot of dragdrop/sliders, I've
discovered that the performance quickly become unbearable in IE
(others also suffer the performance losses, not the same as IE, but
notable) when several constraints WITH TICKS are used, especially when
the ticks are substantially smaller then constraints (e.g. a slider
that changes the width of columns in a 600 pixel row, with 5px tick).
After a quick glance at dragdrop.js, it became clear why this happens.
for each DD element that is constrained with ticks, an array AND a
hash of allowable offsets is created. Using an example above, for each
horisontal slider, an array and a hash of 120 elements each are
created in a loop. With every drag that can affect the positions of a
drag element constrained, the constraints are reset and the array and
hash are recreated. That happens very often. The page can hold several
sliders, which affected. The result may vary from temporary freeses to
effectively disabled drag and drop.
Yes, I use YUI 0.11 and a really fast PC width Pentium D2.8 and 512M
RAM. Omitting tick size resolves the problem.
I'm not so keen in YUI dragdrop internals yet, but does it make sense
simply to use last coordinates and a tick size value to enforce ticks
instead of pre-caching all the allowable values?