updateZoomMove: Update zoomMove

Description Usage Arguments Value See Also Examples

View source: R/api.R

Description

Add a zoom animation on an existing NGLVieweR object.

Usage

1
updateZoomMove(NGLVieweR_proxy, center, zoom, duration = 0, z_offSet = 0)

Arguments

NGLVieweR_proxy

A NGLVieweR object.

center

Target distance of selected atoms/residues. See the section "selection-language" in the official NGL.js manual.

zoom

Target zoom of selected atoms/residues. See the section "selection-language" in the official NGL.js manual.

duration

Optional animation time in milliseconds (default = 0).

z_offSet

Optional zoom offset value (default = 0).

Value

API call containing NGLVieweR id and list of message parameters.

See Also

Other animations: setRock(), setSpin(), updateRock(), updateSpin(), zoomMove()

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
## Not run: 
NGLVieweR_proxy("structure") %>% updateZoomMove(center = "200",
                                               zoom = "200",
                                               z_offSet = 80,
                                               duration = 2000)

## End(Not run)

if (interactive()) {
library(shiny)

ui = fluidPage(
  titlePanel("Viewer with API inputs"),
  sidebarLayout(
    sidebarPanel(
      textInput("center", "Center", "200"),
      textInput("zoom", "Zoom", "200"),
      numericInput("zoomOffset", "Zoom offset", 80,0,100),
      numericInput("duration", "Duration", 2000,0,2000),
      actionButton("zoom", "Zoom"),
      actionButton("reset", "Reset")
    ),
    mainPanel(
      NGLVieweROutput("structure")
    )
  )
)
server = function(input, output) {
  output$structure <- renderNGLVieweR({
    NGLVieweR("7CID") %>%
      addRepresentation("cartoon",
      param = list(name = "cartoon", color="red")) %>%
      addRepresentation("ball+stick",
      param = list(name = "ball+stick", sele="200"))
  })

observeEvent(input$zoom, {
  NGLVieweR_proxy("structure") %>%
    updateZoomMove(
      center = isolate(input$center),
      zoom = isolate(input$zoom),
      z_offSet = isolate(input$zoomOffset),
      duration = isolate(input$duration)
    )
})

observeEvent(input$reset, {
  NGLVieweR_proxy("structure") %>%
    updateZoomMove(
      center = "*",
      zoom = "*",
      z_offSet = 0,
      duration = 1000
    )
})
}
shinyApp(ui, server)
}

NGLVieweR documentation built on June 1, 2021, 9:08 a.m.