Skip to content

imageOutput coordinate interaction bug #161

@rmcminds

Description

@rmcminds

I originally submitted an issue here, but perhaps this is R-specific.

I have an app that uses imageOutput with options 'click' and 'brush' to retrieve coordinates from a photo. The app works great when run directly from R, but once I export it with shinylive, the interactivity with the photo disappears. Not only do the input values not seem to update, the visual box that is normally created when clicking and dragging does not appear in the shinylive version.

Interestingly, the cursor does seem to have the expected '+' shape on initial load, but goes back to the standard arrow once it is moved.

Simple example:

library(shiny)

ui <- fluidPage(

  sidebarLayout(
    
    mainPanel(
      
      imageOutput("current_photo",
                  click = "photo_click",
                  brush = "photo_brush"
      )
      
    ),
    
    sidebarPanel(
      
      verbatimTextOutput("info")
      
    )
  )
)

server <- function(input, output, session) {
  
  output$current_photo <- renderImage({
  
    list(src = 'photo_1_fish.jpg',
         width = '100%')
    
  }, deleteFile = FALSE)
    
  output$info <- renderText({
    
    paste0(
      "click-x: ", input$photo_click$x, '\n',
      "brush-xmin: ", input$photo_brush$xmin
    )
    
  })
}

shinyApp(ui, server)

#shinylive::export("~/test",  "~/ex_coord")

I found in the HTML there is an inherited 'clip' value for the photo containers which seems to be different for shinylive compared to runApp(). I'm able to change that with CSS and register that clicks happen anywhere in the photo, but the click coordinates are still not saved unless they occur in a small box in the upper left corner.

If anything else is needed to reproduce the issue, I'm happy to provide it. I have the buggy shinylive app hosted at https://thecnidaegritty.org/photo_annotator/ and the working source code at
https://github.com/McMinds-Lab/USF_Library_Ogden_Collection_resources/tree/main/shiny_annotation

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions