Skip to content

Commit

Permalink
added support for Infinity as a value for animation_play_duration
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisantonellis committed Feb 12, 2016
1 parent 5e872d9 commit 83908de
Show file tree
Hide file tree
Showing 7 changed files with 67 additions and 18 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,9 @@ var ff = new freezeframe({

* **animation_play_duration** *integer*
Default: ```5000```
The number of milliseconds a .gif will animate for when triggered by click / touch event.
The number of milliseconds a .gif will animate for when triggered by click /
touch event.
Use ```Infinity``` to make the .gif play *forever.*

* **non_touch_device_trigger_event** *string*
Default: ```"hover"``` Options: ```"hover", "click"```
Expand Down
17 changes: 13 additions & 4 deletions build/js/freezeframe.js
Original file line number Diff line number Diff line change
Expand Up @@ -243,18 +243,27 @@ var freezeframe = (function($) {
if($image.hasClass('ff-image-ready')) {

if(clicked) {
clearTimeout(click_timeout);

if(ff.options.animation_play_duration != Infinity) {
clearTimeout(click_timeout);
}

$canvas.removeClass('ff-canvas-active').addClass('ff-canvas-ready');

} else {

$image.attr('src', $image[0].src);
$canvas.removeClass('ff-canvas-ready').addClass('ff-canvas-active');

click_timeout = setTimeout(function() {
$canvas.removeClass('ff-canvas-active').addClass('ff-canvas-ready');
}, ff.options.animation_play_duration);
if(ff.options.animation_play_duration != Infinity) {
click_timeout = setTimeout(function() {
$canvas.removeClass('ff-canvas-active').addClass('ff-canvas-ready');
}, ff.options.animation_play_duration);
}

}


}

})();
Expand Down
2 changes: 1 addition & 1 deletion build/js/freezeframe.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 13 additions & 4 deletions build/js/freezeframe.pkgd.js
Original file line number Diff line number Diff line change
Expand Up @@ -10305,18 +10305,27 @@ var freezeframe = (function($) {
if($image.hasClass('ff-image-ready')) {

if(clicked) {
clearTimeout(click_timeout);

if(ff.options.animation_play_duration != Infinity) {
clearTimeout(click_timeout);
}

$canvas.removeClass('ff-canvas-active').addClass('ff-canvas-ready');

} else {

$image.attr('src', $image[0].src);
$canvas.removeClass('ff-canvas-ready').addClass('ff-canvas-active');

click_timeout = setTimeout(function() {
$canvas.removeClass('ff-canvas-active').addClass('ff-canvas-ready');
}, ff.options.animation_play_duration);
if(ff.options.animation_play_duration != Infinity) {
click_timeout = setTimeout(function() {
$canvas.removeClass('ff-canvas-active').addClass('ff-canvas-ready');
}, ff.options.animation_play_duration);
}

}


}

})();
Expand Down
6 changes: 3 additions & 3 deletions build/js/freezeframe.pkgd.min.js

Large diffs are not rendered by default.

22 changes: 21 additions & 1 deletion tests/index.html → examples/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,14 @@
font-weight: 700;
}

.image {
max-width: 400px;
}

pre {
float: right;
}

</style>

<script type="text/javascript">
Expand All @@ -40,6 +48,7 @@

second = new freezeframe({
'selector': '.my_class_2',
'animation_play_duration': Infinity,
'non_touch_device_trigger_event': 'click'
}).freeze();

Expand All @@ -66,8 +75,19 @@

<p class="bold">freezeframe.js</p>



<p>natural width<br />animate on hover</p>
<img class="my_class_1" src="http://static1.squarespace.com/static/51c748abe4b0c275d0aa86bf/55f96e21e4b0f86680e762dc/56aa551b8b38d446e39e933b/1454003533097/.gif" />
<div class="image">
<img class="my_class_1" src="http://static1.squarespace.com/static/51c748abe4b0c275d0aa86bf/55f96e21e4b0f86680e762dc/56aa551b8b38d446e39e933b/1454003533097/.gif" />
</div>

<pre>
$('.start').click(function(e) {
e.preventDefault();
third.trigger();
});
</pre>

<p>responsive<br />start / stop on click</p>
<img class="my_class_2 freezeframe-responsive" src="http://static1.squarespace.com/static/51c748abe4b0c275d0aa86bf/56141631e4b0095d43132f02/5614164be4b018c0454fd619/1444744841735/pool980.gif" />
Expand Down
17 changes: 13 additions & 4 deletions src/js/freezeframe.js
Original file line number Diff line number Diff line change
Expand Up @@ -243,18 +243,27 @@ var freezeframe = (function($) {
if($image.hasClass('ff-image-ready')) {

if(clicked) {
clearTimeout(click_timeout);

if(ff.options.animation_play_duration != Infinity) {
clearTimeout(click_timeout);
}

$canvas.removeClass('ff-canvas-active').addClass('ff-canvas-ready');

} else {

$image.attr('src', $image[0].src);
$canvas.removeClass('ff-canvas-ready').addClass('ff-canvas-active');

click_timeout = setTimeout(function() {
$canvas.removeClass('ff-canvas-active').addClass('ff-canvas-ready');
}, ff.options.animation_play_duration);
if(ff.options.animation_play_duration != Infinity) {
click_timeout = setTimeout(function() {
$canvas.removeClass('ff-canvas-active').addClass('ff-canvas-ready');
}, ff.options.animation_play_duration);
}

}


}

})();
Expand Down

0 comments on commit 83908de

Please sign in to comment.