Skip to content

Conversation

@wjt
Copy link
Contributor

@wjt wjt commented Apr 30, 2015

See GH issue #520.

This is problematic because it will break mouseover events on the
highlight's parent, but it does make the page not freeze when you mouse
in and out of a chunk of text with hundreds of annotations. See
http://willthompson.co.uk/misc/annotator-freeze-on-mouseout/ for an
example without this patch.

One alternative would be to use a single span.annotation-hl with
multiple annotation-ids where currently they would be nested. ie,
transform this:

<span class="annotation-hl" data-annotation-id="123">
  <span class="annotator-hl" data-annotation-id="456">
    ...
      Foo
    ...
  </span>
</span>

into this:

<span class="annotation-hl" data-annotation-id="123 456 ...">
  Foo
</span>

Another alternative would be to stick with the current structure but
make the .done() callback inside _onHighlightMouseover smarter about not
repeating itself.

@tilgovi
Copy link
Member

tilgovi commented Apr 30, 2015

Good find. I wonder how much effort it would be to change the highlighter to coalesce spans.

@wjt
Copy link
Contributor Author

wjt commented Apr 30, 2015

I've actually ended up looking at the span-creation stuff anyway (for performance when annotating a range of every cell in a 5000-row table – perhaps pathological but that's where I find myself) so maybe I'll take a look…

@tilgovi
Copy link
Member

tilgovi commented Apr 30, 2015

🍰 thanks

@wjt wjt mentioned this pull request May 1, 2015
@BigBlueHat
Copy link
Contributor

@wjt is this still needed given your work on #523? Not sure how close to a fix you got with that later PR.

Thanks!

wjt added 3 commits May 22, 2015 12:20
The knowledge of .data('annotation') seems a bit more reasonable than
the knowledge that the plugin calls .map() on its highlights property.
This seems to have been introduced when translating from coffeescript
@mousedown to JavaScript.
1fc7024 changed this test from `which == 1` to `which > 1` with the
explanation:

> Also incorporating a change in the button check, from
>
>     e.which != 1
>
> to
>
>     e.which > 1
>
> which seems to be necessary for IE8 support (see openannotation#436).

(I'm offline so can't check openannotation#436, but) this seems wrong: the only button
we care about is the primary button, used to select text, and the commit
and the message disagree anyway!
@wjt
Copy link
Contributor Author

wjt commented May 25, 2015

@BigBlueHat this is orthogonal to #523 unfortunately.

I've an alternative patch which doesn't break other mouseover handlers in the document, plus some other fixes I noticed along the way – just a mo…

@wjt wjt force-pushed the many-overlapping-annotations branch from d3bac5d to f69bb50 Compare May 25, 2015 11:00
@tilgovi
Copy link
Member

tilgovi commented Jun 17, 2015

@wjt bump

@wjt
Copy link
Contributor Author

wjt commented Jun 19, 2015

Sorry, should have been explicit that I had pushed the “alternative patch”!

Calling $(this).parent() repeatedly is a bit sad I guess. The other approach I could see is comparing this to event.target, but that would fail if there is other markup inside the innermost annotator-hl.

@tilgovi
Copy link
Member

tilgovi commented Jun 19, 2015 via email

wjt added 2 commits June 19, 2015 09:13
See GH issue openannotation#520.

If you have a chunk of text with hundreds of annotations at the same
spot, the markup looks like this:

```html
<span class="annotation-hl">
  <span class="annotator-hl">
    ...
      Foo
    ...
  </span>
</span>
```

Mousing over the text fires this event once per `<span>`; so `.load()`
would be called once per `<span>`, each time with the full set of
annotations. `.load()` is surprisingly expensive --
`Widget.checkOrientation` seems costly -- and so in my test case with
150 annotations on the same block of text, the browser would freeze for
~10 seconds.

(I tried changing the highlighter to use a single `<span>` for all
annotations covering a piece of text, but it's surprisingly fiddly to
get right if you have annotations which intersect but are not
identical.)
@wjt wjt force-pushed the many-overlapping-annotations branch from 28583f6 to b5211bf Compare June 19, 2015 08:27
@wjt
Copy link
Contributor Author

wjt commented Jun 19, 2015

Fair enough – I guess that if something is meddling with the contents of the highlighter's elements after they are created, there may be bigger problems. Here's a version which checks event.target.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this part is necessary since the event is delegated.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Never mind. Brain failure.

tilgovi added a commit that referenced this pull request Jul 2, 2015
viewer: don't repeatedly show overlapping annotations
@tilgovi tilgovi merged commit 2f40f38 into openannotation:master Jul 2, 2015
@tilgovi
Copy link
Member

tilgovi commented Jul 2, 2015

Thanks! Sorry that took me so long.

@wjt
Copy link
Contributor Author

wjt commented Jul 2, 2015

No prob, thanks for merging!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants