javascript - Rangy: Can I improve the performance when restoring multiple character ranges for highlighting? -
i using rangy help text highlighting functionality in website. in short, user can select text, highlight text (via button click), , user can create multiple highlights way.
the highlights saved database, , @ point in future user can re-load highlights.
however, have performance issue when using restorecharacterranges
part of "textrange" module. performance issue becomes much more noticeable when there more highlights load.
currently, using code similar below (just point out, works how want, isn't fast enough):
function loadhighlight(start, end){ var selectionranges = []; selectionranges.push({ "characterrange": { "start": start, "end": end } }); var selection = rangy.getselection(); selection.restorecharacterranges(myelement, selectionranges); highlighter.highlightselection(highlightclass, selection); }
with code illustration above, performance issue occurs during selection.restorecharacterranges
call. takes 0.6 seconds run in test.
now, when loading multiple highlights, expectedly 0.6 sec nail each one, , can add together up.
is there can load multiple highlights more efficiently? maybe 1 phone call restorecharacterranges
?
i have attempted force multiple selections selectionranges
array, seems have undesired effects when highlightselection
phone call made (i.e. highlights first)
you utilize serialize()
, deserialize()
(demo) methods of highlighter this. added more performant way of serializing ranges highlighter removes dependency on textrange module, have admit desperately slow lot of tasks.
javascript rangy
No comments:
Post a Comment