Problem when reloading an animated GIF in Chrome - Part IIProblem when reloading an animated GIF in ChromeHow do I auto-reload a Chrome extension I'm developing?Proper way to reset a GIF animation with display:none on ChromeAnimated gif only loops once in Chrome and FirefoxChrome browser reload options new featureWhat's the difference between “Normal Reload”, “Hard Reload”, and “Empty Cache and Hard Reload” in Chrome?How can I force a hard reload in Chrome for AndroidBroken response from Raspberry Pi server when GETting stored imagesAnimated gif is not displayed on ChromeNest “Add an Input” Within “Add an Input” in R ShinyProblem when reloading an animated GIF in Chrome
Calculate Landau's function
I was given someone else's visa, stamped in my passport
What XY coordinate system goes with EGM96 when projecting elevation raster in ArcGIS Pro?
Resources to learn about firearms?
Sum and average calculator
Why do motor drives have multiple bus capacitors of small value capacitance instead of a single bus capacitor of large value?
An idiom for “Until you punish the offender, they will not give up offenses”
Ideas behind the 8.Bd3 line in the 4.Ng5 Two Knights Defense
What's the origin of the concept of alternate dimensions/realities?
Using font to highlight a god's speech in dialogue
How did the Altair 8800 front panel load the program counter?
Who declared the Last Alliance to be the "last" and why?
'spazieren' - walking in a silly and affected manner?
Am I required to correct my opponent's assumptions about my morph creatures?
Necessity of tenure for lifetime academic research
Heavy Box Stacking
Is there anything in the universe that cannot be compressed?
apt-file regex: find multiple packages at once using or
Is "prohibition against," a double negative?
New coworker has strange workplace requirements - how should I deal with them?
Ask one verbal question to figure out who is blind and who is mute among three persons
Does the Freedom of Movement spell prevent petrification by the Flesh to Stone spell?
What is the motivation behind designing a control stick that does not move?
How to understand payment due date for a credit card
Problem when reloading an animated GIF in Chrome - Part II
Problem when reloading an animated GIF in ChromeHow do I auto-reload a Chrome extension I'm developing?Proper way to reset a GIF animation with display:none on ChromeAnimated gif only loops once in Chrome and FirefoxChrome browser reload options new featureWhat's the difference between “Normal Reload”, “Hard Reload”, and “Empty Cache and Hard Reload” in Chrome?How can I force a hard reload in Chrome for AndroidBroken response from Raspberry Pi server when GETting stored imagesAnimated gif is not displayed on ChromeNest “Add an Input” Within “Add an Input” in R ShinyProblem when reloading an animated GIF in Chrome
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
Continuing from Mark's suggestion here I am now using uiOutput and renderUI.
The code below displays an animated gif ("anione"). When the "Again" button is pressed it resets Chrome with Javascript in ways that I don't fully understand and then simulates my larger program by overwriting the original animated gif with another animated gif ("anitwo").
However, "anitwo" is not displayed, "anione" is displayed. I can view the local file and see that it was written and view it successfully by opening it in Chrome. How do I view a different file of the same name?
I realize that I am inconsistent in my use of "www/tmp/ani.gif" and "tmp/ani.gif" and understand that shiny looks for files in "www". Yet, without these inconsistencies I get file not found errors.
ani.gif and ani2.gif are here.
library(shiny)
library(shinyjs)
library(magick)
jsCode <- '
shinyjs.reset_anim = function()
var div_elem = document.getElementById("anim_plot");
var img_elem = div_elem.getElementsByTagName("img")[0];
var src_value = img_elem.getAttribute("src");
img_elem.setAttribute("src", "");
img_elem.setAttribute("src", src_value);
'
# Define UI ----
ui <- fluidPage(useShinyjs(),
extendShinyjs(text = jsCode),
uiOutput('anim_plot'),
fluidRow(
column(3,
actionButton("do_again", "Again")
)
)
)
# Define server logic ----
server <- function(input, output)
output$anim_plot <- renderUI(
img(src = 'tmp/ani.gif',
width = '900')
)
observeEvent(input$do_again,
print("Again")
js$reset_anim()
# When Again clicked, simulate the creation of a new animated gif by reading in a file and
# over writing the old one. Try displaying this new animated gif.
img2 <- image_read("www/tmp/ani2.gif")
image_write(img2, path = "www/tmp/ani.gif")
output$anim_plot <- renderUI(
img(src = 'tmp/ani.gif',
width = '900')
)
)
shinyApp(ui = ui, server = server)
javascript r
add a comment |
Continuing from Mark's suggestion here I am now using uiOutput and renderUI.
The code below displays an animated gif ("anione"). When the "Again" button is pressed it resets Chrome with Javascript in ways that I don't fully understand and then simulates my larger program by overwriting the original animated gif with another animated gif ("anitwo").
However, "anitwo" is not displayed, "anione" is displayed. I can view the local file and see that it was written and view it successfully by opening it in Chrome. How do I view a different file of the same name?
I realize that I am inconsistent in my use of "www/tmp/ani.gif" and "tmp/ani.gif" and understand that shiny looks for files in "www". Yet, without these inconsistencies I get file not found errors.
ani.gif and ani2.gif are here.
library(shiny)
library(shinyjs)
library(magick)
jsCode <- '
shinyjs.reset_anim = function()
var div_elem = document.getElementById("anim_plot");
var img_elem = div_elem.getElementsByTagName("img")[0];
var src_value = img_elem.getAttribute("src");
img_elem.setAttribute("src", "");
img_elem.setAttribute("src", src_value);
'
# Define UI ----
ui <- fluidPage(useShinyjs(),
extendShinyjs(text = jsCode),
uiOutput('anim_plot'),
fluidRow(
column(3,
actionButton("do_again", "Again")
)
)
)
# Define server logic ----
server <- function(input, output)
output$anim_plot <- renderUI(
img(src = 'tmp/ani.gif',
width = '900')
)
observeEvent(input$do_again,
print("Again")
js$reset_anim()
# When Again clicked, simulate the creation of a new animated gif by reading in a file and
# over writing the old one. Try displaying this new animated gif.
img2 <- image_read("www/tmp/ani2.gif")
image_write(img2, path = "www/tmp/ani.gif")
output$anim_plot <- renderUI(
img(src = 'tmp/ani.gif',
width = '900')
)
)
shinyApp(ui = ui, server = server)
javascript r
I see that Stephane who often answers my own questions has posted a nice answer. I am curious how you make GIFs in your app by the way, as I might have a use for that in my own program that i'm building.
– Mark
Mar 28 at 11:57
The hard work is done by Thomas Lin Pedersen's transformr package: github.com/thomasp85/transformr. If you can get whatever shapes you wish to morph into a simple feature object (cran.r-project.org/web/packages/sf/vignettes/sf1.html) then transformr can generate an animated gif for you.
– ixodid
Mar 29 at 0:55
Ah that probably wont be suitable for making a gif of plots or pngs there of
– Mark
Mar 30 at 18:43
add a comment |
Continuing from Mark's suggestion here I am now using uiOutput and renderUI.
The code below displays an animated gif ("anione"). When the "Again" button is pressed it resets Chrome with Javascript in ways that I don't fully understand and then simulates my larger program by overwriting the original animated gif with another animated gif ("anitwo").
However, "anitwo" is not displayed, "anione" is displayed. I can view the local file and see that it was written and view it successfully by opening it in Chrome. How do I view a different file of the same name?
I realize that I am inconsistent in my use of "www/tmp/ani.gif" and "tmp/ani.gif" and understand that shiny looks for files in "www". Yet, without these inconsistencies I get file not found errors.
ani.gif and ani2.gif are here.
library(shiny)
library(shinyjs)
library(magick)
jsCode <- '
shinyjs.reset_anim = function()
var div_elem = document.getElementById("anim_plot");
var img_elem = div_elem.getElementsByTagName("img")[0];
var src_value = img_elem.getAttribute("src");
img_elem.setAttribute("src", "");
img_elem.setAttribute("src", src_value);
'
# Define UI ----
ui <- fluidPage(useShinyjs(),
extendShinyjs(text = jsCode),
uiOutput('anim_plot'),
fluidRow(
column(3,
actionButton("do_again", "Again")
)
)
)
# Define server logic ----
server <- function(input, output)
output$anim_plot <- renderUI(
img(src = 'tmp/ani.gif',
width = '900')
)
observeEvent(input$do_again,
print("Again")
js$reset_anim()
# When Again clicked, simulate the creation of a new animated gif by reading in a file and
# over writing the old one. Try displaying this new animated gif.
img2 <- image_read("www/tmp/ani2.gif")
image_write(img2, path = "www/tmp/ani.gif")
output$anim_plot <- renderUI(
img(src = 'tmp/ani.gif',
width = '900')
)
)
shinyApp(ui = ui, server = server)
javascript r
Continuing from Mark's suggestion here I am now using uiOutput and renderUI.
The code below displays an animated gif ("anione"). When the "Again" button is pressed it resets Chrome with Javascript in ways that I don't fully understand and then simulates my larger program by overwriting the original animated gif with another animated gif ("anitwo").
However, "anitwo" is not displayed, "anione" is displayed. I can view the local file and see that it was written and view it successfully by opening it in Chrome. How do I view a different file of the same name?
I realize that I am inconsistent in my use of "www/tmp/ani.gif" and "tmp/ani.gif" and understand that shiny looks for files in "www". Yet, without these inconsistencies I get file not found errors.
ani.gif and ani2.gif are here.
library(shiny)
library(shinyjs)
library(magick)
jsCode <- '
shinyjs.reset_anim = function()
var div_elem = document.getElementById("anim_plot");
var img_elem = div_elem.getElementsByTagName("img")[0];
var src_value = img_elem.getAttribute("src");
img_elem.setAttribute("src", "");
img_elem.setAttribute("src", src_value);
'
# Define UI ----
ui <- fluidPage(useShinyjs(),
extendShinyjs(text = jsCode),
uiOutput('anim_plot'),
fluidRow(
column(3,
actionButton("do_again", "Again")
)
)
)
# Define server logic ----
server <- function(input, output)
output$anim_plot <- renderUI(
img(src = 'tmp/ani.gif',
width = '900')
)
observeEvent(input$do_again,
print("Again")
js$reset_anim()
# When Again clicked, simulate the creation of a new animated gif by reading in a file and
# over writing the old one. Try displaying this new animated gif.
img2 <- image_read("www/tmp/ani2.gif")
image_write(img2, path = "www/tmp/ani.gif")
output$anim_plot <- renderUI(
img(src = 'tmp/ani.gif',
width = '900')
)
)
shinyApp(ui = ui, server = server)
javascript r
javascript r
asked Mar 27 at 23:35
ixodidixodid
4294 silver badges16 bronze badges
4294 silver badges16 bronze badges
I see that Stephane who often answers my own questions has posted a nice answer. I am curious how you make GIFs in your app by the way, as I might have a use for that in my own program that i'm building.
– Mark
Mar 28 at 11:57
The hard work is done by Thomas Lin Pedersen's transformr package: github.com/thomasp85/transformr. If you can get whatever shapes you wish to morph into a simple feature object (cran.r-project.org/web/packages/sf/vignettes/sf1.html) then transformr can generate an animated gif for you.
– ixodid
Mar 29 at 0:55
Ah that probably wont be suitable for making a gif of plots or pngs there of
– Mark
Mar 30 at 18:43
add a comment |
I see that Stephane who often answers my own questions has posted a nice answer. I am curious how you make GIFs in your app by the way, as I might have a use for that in my own program that i'm building.
– Mark
Mar 28 at 11:57
The hard work is done by Thomas Lin Pedersen's transformr package: github.com/thomasp85/transformr. If you can get whatever shapes you wish to morph into a simple feature object (cran.r-project.org/web/packages/sf/vignettes/sf1.html) then transformr can generate an animated gif for you.
– ixodid
Mar 29 at 0:55
Ah that probably wont be suitable for making a gif of plots or pngs there of
– Mark
Mar 30 at 18:43
I see that Stephane who often answers my own questions has posted a nice answer. I am curious how you make GIFs in your app by the way, as I might have a use for that in my own program that i'm building.
– Mark
Mar 28 at 11:57
I see that Stephane who often answers my own questions has posted a nice answer. I am curious how you make GIFs in your app by the way, as I might have a use for that in my own program that i'm building.
– Mark
Mar 28 at 11:57
The hard work is done by Thomas Lin Pedersen's transformr package: github.com/thomasp85/transformr. If you can get whatever shapes you wish to morph into a simple feature object (cran.r-project.org/web/packages/sf/vignettes/sf1.html) then transformr can generate an animated gif for you.
– ixodid
Mar 29 at 0:55
The hard work is done by Thomas Lin Pedersen's transformr package: github.com/thomasp85/transformr. If you can get whatever shapes you wish to morph into a simple feature object (cran.r-project.org/web/packages/sf/vignettes/sf1.html) then transformr can generate an animated gif for you.
– ixodid
Mar 29 at 0:55
Ah that probably wont be suitable for making a gif of plots or pngs there of
– Mark
Mar 30 at 18:43
Ah that probably wont be suitable for making a gif of plots or pngs there of
– Mark
Mar 30 at 18:43
add a comment |
1 Answer
1
active
oldest
votes
Can't you simply do
library(shiny)
# Define UI ----
ui <- fluidPage(
uiOutput('anim_plot'),
fluidRow(
column(3,
actionButton("do_again", "Again")
)
)
)
# Define server logic ----
server <- function(input, output)
gif <- reactiveVal("ani.gif")
observeEvent(input$do_again,
gif("ani2.gif")
)
output$anim_plot <- renderUI(
img(src = gif(), width = "256")
)
shinyApp(ui = ui, server = server)

very elegant solution to not need javascript at all I would say Stéphane
– Mark
Mar 28 at 11:55
I like the no Javascript. However, it does not work for me. I think the problem is that in my R script that does the letter morphing there is no ani2.gif. The script morphs symbols into a word that the user types in. The resulting animated gif is always stored as ani.gif. That is why in my example I am always displaying ani.gif. ani2.gif is just a stand-in for the next animated gif that gets created and is saved as ani.gif.
– ixodid
Mar 29 at 0:48
Is there a way to manually tell the "reactive value" object, "gif" that it has changed?
– ixodid
Mar 29 at 1:00
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55388079%2fproblem-when-reloading-an-animated-gif-in-chrome-part-ii%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Can't you simply do
library(shiny)
# Define UI ----
ui <- fluidPage(
uiOutput('anim_plot'),
fluidRow(
column(3,
actionButton("do_again", "Again")
)
)
)
# Define server logic ----
server <- function(input, output)
gif <- reactiveVal("ani.gif")
observeEvent(input$do_again,
gif("ani2.gif")
)
output$anim_plot <- renderUI(
img(src = gif(), width = "256")
)
shinyApp(ui = ui, server = server)

very elegant solution to not need javascript at all I would say Stéphane
– Mark
Mar 28 at 11:55
I like the no Javascript. However, it does not work for me. I think the problem is that in my R script that does the letter morphing there is no ani2.gif. The script morphs symbols into a word that the user types in. The resulting animated gif is always stored as ani.gif. That is why in my example I am always displaying ani.gif. ani2.gif is just a stand-in for the next animated gif that gets created and is saved as ani.gif.
– ixodid
Mar 29 at 0:48
Is there a way to manually tell the "reactive value" object, "gif" that it has changed?
– ixodid
Mar 29 at 1:00
add a comment |
Can't you simply do
library(shiny)
# Define UI ----
ui <- fluidPage(
uiOutput('anim_plot'),
fluidRow(
column(3,
actionButton("do_again", "Again")
)
)
)
# Define server logic ----
server <- function(input, output)
gif <- reactiveVal("ani.gif")
observeEvent(input$do_again,
gif("ani2.gif")
)
output$anim_plot <- renderUI(
img(src = gif(), width = "256")
)
shinyApp(ui = ui, server = server)

very elegant solution to not need javascript at all I would say Stéphane
– Mark
Mar 28 at 11:55
I like the no Javascript. However, it does not work for me. I think the problem is that in my R script that does the letter morphing there is no ani2.gif. The script morphs symbols into a word that the user types in. The resulting animated gif is always stored as ani.gif. That is why in my example I am always displaying ani.gif. ani2.gif is just a stand-in for the next animated gif that gets created and is saved as ani.gif.
– ixodid
Mar 29 at 0:48
Is there a way to manually tell the "reactive value" object, "gif" that it has changed?
– ixodid
Mar 29 at 1:00
add a comment |
Can't you simply do
library(shiny)
# Define UI ----
ui <- fluidPage(
uiOutput('anim_plot'),
fluidRow(
column(3,
actionButton("do_again", "Again")
)
)
)
# Define server logic ----
server <- function(input, output)
gif <- reactiveVal("ani.gif")
observeEvent(input$do_again,
gif("ani2.gif")
)
output$anim_plot <- renderUI(
img(src = gif(), width = "256")
)
shinyApp(ui = ui, server = server)

Can't you simply do
library(shiny)
# Define UI ----
ui <- fluidPage(
uiOutput('anim_plot'),
fluidRow(
column(3,
actionButton("do_again", "Again")
)
)
)
# Define server logic ----
server <- function(input, output)
gif <- reactiveVal("ani.gif")
observeEvent(input$do_again,
gif("ani2.gif")
)
output$anim_plot <- renderUI(
img(src = gif(), width = "256")
)
shinyApp(ui = ui, server = server)

answered Mar 28 at 9:08
Stéphane LaurentStéphane Laurent
21.7k9 gold badges59 silver badges109 bronze badges
21.7k9 gold badges59 silver badges109 bronze badges
very elegant solution to not need javascript at all I would say Stéphane
– Mark
Mar 28 at 11:55
I like the no Javascript. However, it does not work for me. I think the problem is that in my R script that does the letter morphing there is no ani2.gif. The script morphs symbols into a word that the user types in. The resulting animated gif is always stored as ani.gif. That is why in my example I am always displaying ani.gif. ani2.gif is just a stand-in for the next animated gif that gets created and is saved as ani.gif.
– ixodid
Mar 29 at 0:48
Is there a way to manually tell the "reactive value" object, "gif" that it has changed?
– ixodid
Mar 29 at 1:00
add a comment |
very elegant solution to not need javascript at all I would say Stéphane
– Mark
Mar 28 at 11:55
I like the no Javascript. However, it does not work for me. I think the problem is that in my R script that does the letter morphing there is no ani2.gif. The script morphs symbols into a word that the user types in. The resulting animated gif is always stored as ani.gif. That is why in my example I am always displaying ani.gif. ani2.gif is just a stand-in for the next animated gif that gets created and is saved as ani.gif.
– ixodid
Mar 29 at 0:48
Is there a way to manually tell the "reactive value" object, "gif" that it has changed?
– ixodid
Mar 29 at 1:00
very elegant solution to not need javascript at all I would say Stéphane
– Mark
Mar 28 at 11:55
very elegant solution to not need javascript at all I would say Stéphane
– Mark
Mar 28 at 11:55
I like the no Javascript. However, it does not work for me. I think the problem is that in my R script that does the letter morphing there is no ani2.gif. The script morphs symbols into a word that the user types in. The resulting animated gif is always stored as ani.gif. That is why in my example I am always displaying ani.gif. ani2.gif is just a stand-in for the next animated gif that gets created and is saved as ani.gif.
– ixodid
Mar 29 at 0:48
I like the no Javascript. However, it does not work for me. I think the problem is that in my R script that does the letter morphing there is no ani2.gif. The script morphs symbols into a word that the user types in. The resulting animated gif is always stored as ani.gif. That is why in my example I am always displaying ani.gif. ani2.gif is just a stand-in for the next animated gif that gets created and is saved as ani.gif.
– ixodid
Mar 29 at 0:48
Is there a way to manually tell the "reactive value" object, "gif" that it has changed?
– ixodid
Mar 29 at 1:00
Is there a way to manually tell the "reactive value" object, "gif" that it has changed?
– ixodid
Mar 29 at 1:00
add a comment |
Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.
Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55388079%2fproblem-when-reloading-an-animated-gif-in-chrome-part-ii%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
I see that Stephane who often answers my own questions has posted a nice answer. I am curious how you make GIFs in your app by the way, as I might have a use for that in my own program that i'm building.
– Mark
Mar 28 at 11:57
The hard work is done by Thomas Lin Pedersen's transformr package: github.com/thomasp85/transformr. If you can get whatever shapes you wish to morph into a simple feature object (cran.r-project.org/web/packages/sf/vignettes/sf1.html) then transformr can generate an animated gif for you.
– ixodid
Mar 29 at 0:55
Ah that probably wont be suitable for making a gif of plots or pngs there of
– Mark
Mar 30 at 18:43