Giter Site home page Giter Site logo

ctrl-freaks / freezeframe.js Goto Github PK

View Code? Open in Web Editor NEW
1.4K 25.0 110.0 21.54 MB

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.

Home Page: http://ctrl-freaks.github.io/freezeframe.js/

License: MIT License

CSS 0.83% JavaScript 22.04% HTML 6.71% Vue 9.01% Shell 0.59% TypeScript 41.98% SCSS 10.21% EJS 8.64%
javascript typescript gifs react freezeframe vue-freezeframe react-freezeframe vue

freezeframe.js's People

Contributors

chrisantonellis avatar codemilli avatar dependabot[bot] avatar dohnutt avatar kgaut avatar mitsunee avatar mritterhoff avatar nickforddev avatar pweigand avatar shedali avatar vsaarinen avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

freezeframe.js's Issues

Doesn't work with floated images

Everything works fine when I use freezeframe with non-floated images, but the moment I use float: left or float: right (on the parent element) I can't click the image anymore. Any suggestions?

Style forced to width 100%

The ff-container ff-responsive ff-ready ff-inactive element has width: 100% by default, instead of allowing the image's default size.

Start Image Fails to load IOS Chrome

The start image doesn't seem to load on an IPad in Chrome. It looks like it is loading but then it loads a blank white image with the play button.

It works on desktop chrome and android chrome just fine. This leads me to believe the problem is within the IPad version of Chrome but I'm not sure.

photo1

graceful degradation for unsupported browsers

add option for a fallback image per group / image, console warn message that freezeframe didn't run do to an unsupported browser, show the feature that is missing in case the user wants to try to include a shim

warning and error in examples/index.html due to no elements with class "my_class_4"

In index.html, due to the call to $('.my_class_4').freezeframe(); we get this warning:

freezeframe.js:17 โœจ freezeframe.js โœจ : unable to run setup(), no images captured

and this error:

freezeframe.js:340 Uncaught TypeError: ff.setup(...).attach is not a function

Should there be a 4th example, or should that call be removed?

Additionally, would it be possible to report the selector in the warning message to help with debugging?

First touch doesn't work

On a touch device, the first touch of a GIF doesn't work properly.

When you touch a GIF for the first time, it starts playing for a split-second, then stops. The 'ff-canvas-ready' class is never removed, and the 'ff-canvas-active' class is never added.

Subsequent touches work fine though, starting and stopping the animation as expected.

Any idea why the first touch doesn't work properly?

Update check for whether an image is a gif (allow animated png and inline base64)

Because the validateFilename method only checks file name/extension, it will incorrectly trigger the "Image is not a gif" when a base64 image is provided (e.g. src="data:image/gif;base64,..."). Also, it's now possible for png's to be animated too, so the extension check for "gif" I believe needs to be updated to do a more in-depth check (if/when possible).

Personally I would be happy with an option to disable warnings since freezeframe is working as expected.

Passing a non-image element is not handled gracefully

Problem:

Currently if a selector is passed that returns a NodeList partially made up of images, and partially made up of non-image elements, an error is raised that prevents further processing.

Expected behavior:

Perhaps during element normalization we can check element type, and if it is a non-image, search for children that are images. At the very least the exception should be caught.

Applying freezeframe class to headers?

Hello, I really like this code and I was wondering if there was a way to apply the class to a header background gif instead of an image tag? In addition I applied the background itself using CSS, and tried applying the class to the header without luck. If you're able to shed some light on the issue either by suggesting how to modify the script or other measures, that'd be really awesome :)

Getting It To Work With Amazon S3

How can I get this to work with amazon s3? The image loads but it's just a normal gif. It works normally without implementing Amazons3. The url of the images are like this s3.amazonaws.com/bucket-name/image.jpg. To my understanding in order to get the play button and still frame you convert the image to dataUrl.

This is what I have implemented in my browser policy

BrowserPolicy.framing.disallow();
BrowserPolicy.content.disallowInlineScripts();
BrowserPolicy.content.disallowEval();
BrowserPolicy.content.allowInlineStyles();
BrowserPolicy.content.allowFontDataUrl();
BrowserPolicy.content.allowDataUrlForAll();
BrowserPolicy.content.allowOriginForAll('http://localhost:3000');

var trusted = [
    '*.amazonaws.com',
];

_.each(trusted, function(origin) {
    origin = "https://" + origin;
    BrowserPolicy.content.allowOriginForAll(origin);
});

I don't know what else to put. I'm not sure if this script is capable with amazon s3. Can anybody help me?

Re-initialize script when props change

Hi, I am using the react component and i just want to know if how can i reinitialize the script when the src props or image is change without reloading the page, for now if you can see the screenshot the old image is still exists and it's creating a nested div from freezeframe script.

2020-06-23 210438

Overlay icon on images

How do I give clue to users that the image is animated? An overlay icon which will disappear when hovered or clicked would be very nice enhancement.

bower support

great thing !

would be very nice if it could be downloaded via bower

Is there a way to querySelect all images with file types ending in .gif?

As I understand you have to specify a freeze-frame class on that img gif tag.

Is there a way to simply querySelect all gifs and have freeze-frame apply the 1st scenario (animate on hover)?

e.g. using this css selector or some variant

$('img[src$=".gif"]')

The reason why I can't add a class is because I'm trying to see if I can use freezeframe.js on a .md file type, e.g. I usually just do this

![](https://i.imgur.com/XYt5jKm.gif)

Responsiveness

GIFs freeze and play as advertised. But they're not responsive.

is jquery dependency necessary?

lets talk the pros / cons of having jquery as a dependency, and what freezeframe could gain by removing jquery. good idea / bad idea?

base64 images are not compressed

Try to use FileOptimizer or tools like OptiPNG for save ~50% of image size on .ff-overlay and ff-loading-icon background-image and tools like svgomg on svg

Total up to 10% size reduction

gif as background img?

I have a gif that is the background of a div element. Ive tried adding the freezeframe class to the div but it doesnt seem to work. Any ideas?

Error when used with Gatsby: error "window" is not available during server side rendering.

The project isn't open source ๐Ÿ˜ž but here's a relevant snippet from a build:

5:22:47 PM: error "window" is not available during server side rendering.
5:22:47 PM: 
5:22:47 PM: > 1 | !function(t,n){"object"==typeof exports&&"object"==typeof module?module.exports=n():"function"==typeof define&&define.amd?define([],n):"object"==typeof exports?exports.Freezeframe=n():t.Freezeframe=n()}(window,(function(){return function(t){var n={};function e(r){if(n[r])return n[r].exports;var i=n[r]={i:r,l:!1,exports:{}};return
...

Visually, the top of the request
gatsby-log.txt

Browser support list

Hi all,

Is there a list of supported browsers?
If it depends on the support of the dependencies, please let me know which ones I should check (jQuery, I'm guessing). Otherwise, what browsers do you officially support and will keep supporting in the future?

Thank you

only works with self-hosted or CORS-enabled images

This might save someone else's time. A canvas that uses foreign-domain images is considered tainted and the same-origin policy will prevent certain methods from working. Canvas.toDataUrl() is one of those methods; it will throw an exception and the script will perpetually appear to be loading the gifs.

Consider copying the gifs to your own server first, or opt for another solution.

Text link overlay

Is it possible to have an tag positioned absolutely over the image and trigger the aimation on hover of the . I have a div position relative with the image and in it. I've tried the following but it doesn't seem to work for me.
var ff = new freezeframe('.my_class');
$('a').hover(function(){
ff.trigger();
});

[ReactFreezeframe] Jest import issue - Cannot use import statement outside a module

While running jest tests are failing because of this error, does anyone has the same issue?

SyntaxError: Cannot use import statement outside a module

  1 | import React, { Component, Fragment } from 'react';
> 2 | import ReactFreezeframe from 'react-freezeframe';
    | ^
  3 | import PropTypes from 'prop-types';
  4 | import classnames from 'classnames';

Start GIF animation once loaded into the browser

An option for this would be nice. I essentially plan to use it like the way Twitter is using it these days - play the GIF animation once it is loaded in the browser and have the user to stop it by clicking on it.

Freezing on a current frame

Is there a way to actually freeze a gif on a current frame, instead of stoping and going back to the first frame?

ECONFLICT Unable to find suitable version for jquery

When I use:

$ bower install freezeframe.js --save

The following appear:

bower freezeframe.js#*      not-cached https://github.com/ctrl-freaks/freezeframe.js.git#*
bower freezeframe.js#*         resolve https://github.com/ctrl-freaks/freezeframe.js.git#*
bower freezeframe.js#*        checkout master
bower freezeframe.js#*        resolved https://github.com/ctrl-freaks/freezeframe.js.git#f75ad95236
bower jquery#^2.2.3             cached https://github.com/jquery/jquery-dist.git#2.2.4
bower jquery#^2.2.3           validate 2.2.4 against https://github.com/jquery/jquery-dist.git#^2.2.3
bower imagesloaded-packaged#^3.1.4           cached https://github.com/alisamar/imagesloaded-packaged.git#3.1.4
bower imagesloaded-packaged#^3.1.4         validate 3.1.4 against https://github.com/alisamar/imagesloaded-packaged.git#^3.1.4
bower jquery#1.9.1 - 2                       cached https://github.com/jquery/jquery-dist.git#2.2.4
bower jquery#1.9.1 - 2                     validate 2.2.4 against https://github.com/jquery/jquery-dist.git#1.9.1 - 2
bower jquery#~2.1.1                          cached https://github.com/jquery/jquery-dist.git#2.1.4
bower jquery#~2.1.1                        validate 2.1.4 against https://github.com/jquery/jquery-dist.git#~2.1.1
bower jquery#>=1.7                           cached https://github.com/jquery/jquery-dist.git#3.1.0
bower jquery#>=1.7                         validate 3.1.0 against https://github.com/jquery/jquery-dist.git#>=1.7
bower jquery#>= 1.7.2                        cached https://github.com/jquery/jquery-dist.git#3.1.0
bower jquery#>= 1.7.2                      validate 3.1.0 against https://github.com/jquery/jquery-dist.git#>= 1.7.2
bower jquery#>= 1.9.1                        cached https://github.com/jquery/jquery-dist.git#3.1.0
bower jquery#>= 1.9.1                      validate 3.1.0 against https://github.com/jquery/jquery-dist.git#>= 1.9.1
bower                                     ECONFLICT Unable to find suitable version for jquery

I get an error. This is my bower.json:

{
  "name": "modular-admin-html",
  "version": "1.0.1",
  "devDependencies": {},
  "dependencies": {
    "animate.css": "~3.4.0",
    "bootstrap": "v4.0.0-alpha.2",
    "font-awesome": "~4.3.0",
    "jquery": "^2.2.3",
    "jquery-validation": "~1.14.0",
    "metisMenu": "~2.0.3",
    "nprogress": "~0.2.0",
    "responsive-bootstrap-toolkit": "~2.5.0",
    "tether": "~1.1.1",
    "tinycolor": "~1.2.1",
    "Sortable": "~1.4.2",
    "bootstrap-tagsinput": "^0.8.0",
    "typeahead.js": "^0.11.1"
  },  
}

I try use

"resolutions": {
    "jquery": "^2.2.3"
  }

But have the same error.

Once animation is played, keep final frame and remove freezeframe.

Hello, so I'm working on a project using this that has graphs that animate and then stop on the last frame rather than looping. I know I could time it exactly and extract the last frame with .selector, but I thought it'd just be easier if you could just disable freezeframe on a particular gif after it's activated. Currently I'm doing this by just removing the classes added by freezeframe after it's animated, but it'd be cool if there was a feature that you could specify how many times the animation ran (ie "num_loops" , "1") and then just show the final frame.

Toggle documentation

  • Both vue-freezeframe and react-freezeframe are lacking documentation abut their methods.
  • freezeframe is also missing a public toggle method.

Doesn't work with my exported transparent gif from photoshop

I really love your work, but for some reason the plugin doesn't work for me, I take one of the images that you used in the examples and works fine, but with my gif doesn't, the gif doesn't stop/play, it just keeping playing in loop forever, I don't know if there is something in my exporting configuration in photoshop but i use:

Photoshop Export conf

<img class="freezeframe freezeframe-responsive sec-1-img" src="test2.gif">
third = new freezeframe('.sec-1-img').capture().setup();
$('.btn-img').click(function(e){
  e.preventDefault();
  third.trigger();
});

I was following the third example, and i have this behavior with the transparent gif and never stop/play
transparent bg bug

anyway to autoplay the GIFs?

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)

Userscript/browser addon version of this code

Hello, is it possible to make it as userscript or browser addon and inject on a pages?

I have a website with annoying gifs on it. I can't remove them, since they are not AD, but I want to have a cheaper and less consumed and animated page, so that I can run this script on a page and it will set all gif images to static and animate only when hover on it.

freezeframe is not working with image inside Bootstrap4 tab-pane (only in tab-pane active)

Hello.
My goal is to implement some tabs with images inside each tab (each image with freezeframe functionality).
I've tried to use freezeframe with image that is placed inside Bootstrap4 tab-pane. My code is the following:

<div>
    <ul class="nav nav-pills text-warning">
        <li class="nav-item">
            <a class="nav-link active" href="#tab-first" data-toggle="tab">First Tab</a>
        </li>
        <li class="nav-item">
            <a class="nav-link" href="#tab-second" data-toggle="tab">SecondTab</a>
        </li>
    </ul>

    <div class="tab-content">
        <div class="tab-pane active" id="tab-first">
            <div style="overflow: auto;  max-height: 650px;">
                <img class="freezeframeWithOverlay" src="http://static1.squarespace.com/static/51c748abe4b0c275d0aa86bf/55f96e21e4b0f86680e762dc/56aa551b8b38d446e39e933b/1454003533097/.gif" />

                <script>
                    new Freezeframe('.freezeframeWithOverlay', {
                        overlay: true
                    });
                </script>
            </div>
        </div>
        <div class="tab-pane" id="tab-second">
            <div style="overflow: auto;  max-height: 650px;">
                <img class="freezeframeWithOverlay" src="http://static1.squarespace.com/static/51c748abe4b0c275d0aa86bf/56141631e4b0095d43132f02/5614164be4b0652b31fbd0a5/1444744817955/parislove9801.gif" />
                <script>
                    new Freezeframe('.freezeframeWithOverlay', {
                        overlay: true
                    });
                </script>
            </div>
        </div>
    </div>
</div>

The result is that for image on the First Tab freezeframe is working correctly, but for First Tab only overlay icon is drawn (no image).
JSFiddle link

P. S. Same code is working correctly whrn images are not placed inside tab-pane.

Is that by design or a bug? Or maybe I'm missing something?
Thank you in advance.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.