Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drag example #14

Open
iyermobile opened this issue Dec 2, 2023 · 0 comments
Open

Drag example #14

iyermobile opened this issue Dec 2, 2023 · 0 comments

Comments

@iyermobile
Copy link

library(shiny)
library(dragulaR)
library(shinyBS)

makeElement <- function(data, name)
{
div(style = "

display: flex;
flex-direction: column;
justify-content: space-between;

max-width: 100%;
padding: 35px;
margin: 10px;
border: 2px solid rgba(255, 255, 255, .5);
border-radius: 20px;
background-color: rgba(255, 255, 255, 0.5);
box-shadow: 0 0 10px 1px rgba(0, 0, 0, 0.5);

backdrop-filter: blur(15px);",
drag = name,
div(class = "active-title-row", id = name, onmousedown = paste0("hideTooltip('", name, "')"), name),
bsTooltip(id = name, title = "Hover",
placement = "top", trigger = "hover"))
}

ui <- fluidPage(
setBackgroundImage(src = "https://source.unsplash.com/E8Ufcyxz514/2400x1823", shinydashboard = FALSE),
tags$script(HTML(
"function hideTooltip(id) {
var $id = $('#' + id)
$id.tooltip('hide');
}"
)),

titlePanel("Drag and drop elements with dragulaR"),

fluidRow(style = "margin: 15px;",
column(3,
h3("Drag from here:"),
div(id = "Available", style = "min-height: 600px;",
lapply(colnames(mtcars), makeElement, data = mtcars)
)
),
column(3,
h3("Drop here:"),
div(id = "Model", style = "min-height: 600px;")
)
),
dragulaOutput("dragula")

)

server <- function(input, output) {

output$dragula <- renderDragula({
dragula(c("Available", "Model"))
})

}

shinyApp(ui = ui, server = server)

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

No branches or pull requests

1 participant