Я хотел бы создать перетаскиваемый объект пользовательского интерфейса с insertUI()
.Подобный объект был создан благодаря actionButton()
и работает нормально.Однако перетаскиваемое свойство было удалено.
Я попытался добавить какой-то фрагмент кода, например tags$script('$(".draggable").draggable();')
ИЛИ tags$script('$(".dragelement").on("dragstart",function(e){e.originalEvent.dataTransfer.setData("Text",e.target.id);});')
.
Однако, это больше не работает.У кого-нибудь есть идея?
Следующий пример взят из http://shiny.rstudio.com/gallery/absolutely-positioned-panels.html.
library(shiny)
library(markdown)
### Ui.R
ui <- fluidPage(
actionButton("add", "Add UI"),
absolutePanel(
bottom = 20,
right = 20,
width = 300,
draggable = TRUE,
wellPanel(
HTML(
markdownToHTML(
fragment.only=TRUE,
text=c(
"This is an absolutePanel that uses `bottom` and `right` attributes.
It also has `draggable = TRUE`, so you can drag it to move it around the page.
The slight transparency is due to `style = 'opacity: 0.92'`.
You can put anything in absolutePanel, including inputs and outputs:"
)
)
),
sliderInput("n", "", min=3, max=20, value=5),
plotOutput("plot2", height="200px")
)
)
)
###Server.R
server <- function(input, output, session) {
observeEvent(input$add, {
insertUI(
selector = "#add",
where = "afterEnd",
ui =
tagList(
absolutePanel(
top = 80,
right = 20,
width = 300,
draggable = TRUE,
wellPanel(
HTML(
markdownToHTML(
fragment.only=TRUE,
text=c(
"This is an absolutePanel that uses `bottom` and `right` attributes.
It also has `draggable = TRUE`, so you can drag it to move it around the page.
The slight transparency is due to `style = 'opacity: 0.92'`.
You can put anything in absolutePanel, including inputs and outputs:"
)
)
)
)
)
)
)
})
}