             height: viewport.height
             width: viewport.width
 
-          $pageDisplay.attr
-            height: viewport.height
-            width: viewport.width
-
           $textLayerDiv = $('<div/>').addClass('display-text').css(
             height: viewport.height + 'px'
             width: viewport.width + 'px'
           ).appendTo $pageDisplay
 
-          $pageDisplay.css
-            position: 'relative'
-
           $closestTextDiv = null
           closestDistance = Number.MAX_VALUE;
 

    Meteor.subscribe 'annotations-by-publication', Session.get 'currentPublicationId'
    Meteor.subscribe 'comments-by-publication', Session.get 'currentPublicationId'

Deps.autorun ->
  publication = Publications.findOne Session.get 'currentPublicationId'

  return unless publication

  unless Session.equals 'currentPublicationSlug', publication.slug
    Meteor.Router.to Meteor.Router.publicationPath publication._id, publication.slug
    return

  # Maybe we don't yet have whole publication object available
  try
    unless publication.url()
      return
  catch e
    return

  PDFJS.getDocument(publication.url()).then (pdf) ->
    for pageNumber in [1..pdf.numPages]
      $canvas = $('<canvas/>').addClass('display-canvas')


            closestDistance = Number.MAX_VALUE;
            $textLayerDiv.children().each ->
              position = $(this).data 'position'

              distXLeft = relX - position.left
              distXRight = relX - (position.left + position.width)
              distXCenter = relX - (position.left + position.width/2.0)

              distYTop = relY - position.top
              distYBottom = relY - (position.top + position.height)
              distYCenter = relY - (position.top + position.height/2.0)


              distX = if Math.abs(distXLeft) < Math.abs(distXRight) then distXLeft else distXRight
              if relX > position.left and relX < position.left + position.width
                distX = 0

              distY = if Math.abs(distYTop) < Math.abs(distYBottom) then distYTop else distYBottom
              if relY > position.top and relY < position.top + position.height
                distY = 0
              # distY = if Math.abs(distY) < Math.abs(distYCenter) then distY else distYCenter

