ctrl-freaks / freezeframe.js

freezeframe.js is a library that pauses animated .gifs and enables them to animate on mouse hover / mouse click / touch event, or with trigger / release functions.
http://ctrl-freaks.github.io/freezeframe.js/
MIT License
1.41k stars 111 forks source link

anyway to autoplay the GIFs? #77

Closed mas-iota closed 4 years ago

mas-iota commented 4 years ago

I am using vue-freezeframe, I cannot find an option to autoplay GIF, I tried to call the component's start function, it does autoplay then after re-scaling it gets paused. Please see below GIF

ezgif com-video-to-gif (1)

maxrottersman commented 4 years ago

I'm having a similar problem. My GIF won't start on page load. The Stop Start buttons from the example code work fine. I've tried all variations of:

//manual.toggle(); //manual.stop(); manual.start(); document.querySelector('.start').click();

Page here: https://maxdatabook.com/staticpages/docaa_example01.html

mas-iota commented 4 years ago

@maxrottersman I gave up using the autoplay, however, I think what interrupts the autoplay is the responsive: true option. When it gets scaled to width: 100% interruption occurs. Try to disable the responsive option and see if it gets fixed, then do a workaround to make it scale 100% width.

here's what I ended up with: https://trends.jawab.app/Mahmoud-8o/post/5f60d859357c0

maxrottersman commented 4 years ago

Thanks! Yes, when I set responsive: false it runs on page load, but then I can't get the buttons to work, even if I try to set responsive back to true multiple ways. I'm no js expert.

nickforddev commented 4 years ago

I'm wondering what you are hoping to accomplish here. If you are looking to autoplay the gif, and then allow the user to pause it on click, that is a new feature that will have to be considered in the core library, mainly because the default control mechanism is hover, which doesn't really fit an autoplay model.

maxrottersman commented 4 years ago

I don't look a gift-horse in the mouth ;) Yes, I want it to start as autoplay and then have some way for a person to "freeze" the frame so they can look at it more closely. My animated GIFs are charts. If they have to hit a button to start, I'd just as soon create HTML movies or JS slide shows. Anyway, I've moved on. But if the developer creates this feature I'll revisit.

mas-iota commented 4 years ago

@nickforddesign Nothing much, except for (I will write the same issue again):

  1. GIF is getting paused after programmatically playing it.
  2. As @maxrottersman has mentioned, setting responsive to false disables controls somehow.

It's up to you not to add such a feature, but I think it's important to fix issues found in the "core library" cheers

nickforddev commented 4 years ago

An important limitation of this library is that it is not able to actually "pause" a gif on a frame other than the first frame. This is due to browser security in regards to CORS and while not all gifs are hosted on a different domain than your own, it is an important enough use-case for us to keep it simple.

If this limitation is a deal breaker for you, I will probably close the issue. If not, let me know and I can add an autoplay feature that allows for clicking to "pause" gif (albeit on the first frame).

maxrottersman commented 4 years ago

Thanks for the update! I would need it to pause on the frame they're looking at. It seems yes, you should close this issue, but I hope you put these issues in your documentation or that example page. Maybe say you can't have a GIF auto-start and then pause it. But you can use your great library to play and pause them if one likes. Here's the piece I wrote on creating animated GIFs in Excel, though I pulled back and mostly cover creating stand alone GIFs.

https://medium.com/@maxrottersman/animated-chart-gifs-excel-creator-104894d15d01?source=friends_link&sk=ac149e406a4f090d681b76c004555a6d

Again, thanks for the library! It may still come in handy for me one day!

mas-iota commented 4 years ago

No problem getting back to the first frame in my case. Thanks for the efforts!

nickforddev commented 4 years ago

Fair enough, I will add more clarification to the documentation! Maybe at some point if I have time I can create a special version of Freezeframe intended for gifs that you host on your own domain, which would allow for actual frame parsing and pausing on a specific frame.

I've added a ticket to update the docs: https://github.com/ctrl-freaks/freezeframe.js/projects/1#card-47483175

Thanks! Lmk if there's anything else we can do to help.