Skip to content

Commit

Permalink
working on private method scoping
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisantonellis committed Feb 7, 2016
1 parent d26ab70 commit ac3f4e2
Show file tree
Hide file tree
Showing 6 changed files with 78 additions and 61 deletions.
37 changes: 19 additions & 18 deletions build/js/freezeframe.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@

var freezeframe = (function($) {

var images;
var options;
var is_touch_device;
var images, options, is_touch_device;

//////////////////////////////////////////////////////////////////////////////
// //
Expand All @@ -13,18 +11,22 @@ var freezeframe = (function($) {

// decorated console.log warn message
var warn = function(_message) {
console.warn('freezeframe.js : ' + _message)
console.warn('✨ freezeframe.js ✨ : ' + _message);
}

// does the freezeframe instance have captured images ?
var has_images = function() {
return images.length == 0 ? false : true;
}

// filter captured images by selector
var filter = function(_this, _selector) {
var images = _this.images,
filtered_images
var filter = function(_selector) {
var filtered_images;

if(_selector != undefined && images.length > 1) {
filtered_images = images.filter( $(_selector) );
if (filtered_images.length == 0) {
warn("no images found for selector " + _selector)
warn("no images found for selector '" + _selector + "'")
return false;
}
} else {
Expand All @@ -34,11 +36,6 @@ var freezeframe = (function($) {
return filtered_images;
}

// does the freezeframe instance have captured images ?
var has_images = function(_this) {
return _this.images.length == 0 ? false : true;
}

//////////////////////////////////////////////////////////////////////////////
// //
// Constructor //
Expand Down Expand Up @@ -124,7 +121,7 @@ var freezeframe = (function($) {
setup_required = this.images.not('.ff-setup'),
container_classnames = ['ff-container'];

if(!has_images(ff)) {
if(!has_images.call(ff)) {
warn("unable to run setup(), no images captured")
return false;
} else if(setup_required.length == 0) {
Expand Down Expand Up @@ -205,12 +202,12 @@ var freezeframe = (function($) {
click_timeout,
images;

if(!has_images(ff)) {
if(!has_images.call(ff)) {
warn("unable to run attach(), no images captured")
return false;
}

filter(ff, _selector).each(function(e) {
filter.call(ff).each(function(e) {

var $image = $(this);
var $canvas = $(this).siblings('canvas');
Expand Down Expand Up @@ -283,7 +280,9 @@ var freezeframe = (function($) {
// save references in a better way

freezeframe.prototype.trigger = function(_selector) {
filter(_selector).each(function(e) {
var ff = this;

filter.call(ff).each(function(e) {
$(this).attr('src', $(this)[0].src);
$(this).siblings('canvas').removeClass('ff-canvas-ready').addClass('ff-canvas-active');
});
Expand All @@ -299,7 +298,9 @@ var freezeframe = (function($) {
// save references in a better way

freezeframe.prototype.release = function(_selector) {
filter(_selector).each(function(e) {
var ff = this;

filter.call(ff).each(function(e) {
$(this).siblings('canvas').removeClass('ff-canvas-active').addClass('ff-canvas-ready');
});
}
Expand Down
1 change: 0 additions & 1 deletion build/js/freezeframe.min.js

This file was deleted.

37 changes: 19 additions & 18 deletions build/js/freezeframe.pkgd.js
Original file line number Diff line number Diff line change
Expand Up @@ -10063,9 +10063,7 @@ return ImagesLoaded;

var freezeframe = (function($) {

var images;
var options;
var is_touch_device;
var images, options, is_touch_device;

//////////////////////////////////////////////////////////////////////////////
// //
Expand All @@ -10075,18 +10073,22 @@ var freezeframe = (function($) {

// decorated console.log warn message
var warn = function(_message) {
console.warn('freezeframe.js : ' + _message)
console.warn('✨ freezeframe.js ✨ : ' + _message);
}

// does the freezeframe instance have captured images ?
var has_images = function() {
return images.length == 0 ? false : true;
}

// filter captured images by selector
var filter = function(_this, _selector) {
var images = _this.images,
filtered_images
var filter = function(_selector) {
var filtered_images;

if(_selector != undefined && images.length > 1) {
filtered_images = images.filter( $(_selector) );
if (filtered_images.length == 0) {
warn("no images found for selector " + _selector)
warn("no images found for selector '" + _selector + "'")
return false;
}
} else {
Expand All @@ -10096,11 +10098,6 @@ var freezeframe = (function($) {
return filtered_images;
}

// does the freezeframe instance have captured images ?
var has_images = function(_this) {
return _this.images.length == 0 ? false : true;
}

//////////////////////////////////////////////////////////////////////////////
// //
// Constructor //
Expand Down Expand Up @@ -10186,7 +10183,7 @@ var freezeframe = (function($) {
setup_required = this.images.not('.ff-setup'),
container_classnames = ['ff-container'];

if(!has_images(ff)) {
if(!has_images.call(ff)) {
warn("unable to run setup(), no images captured")
return false;
} else if(setup_required.length == 0) {
Expand Down Expand Up @@ -10267,12 +10264,12 @@ var freezeframe = (function($) {
click_timeout,
images;

if(!has_images(ff)) {
if(!has_images.call(ff)) {
warn("unable to run attach(), no images captured")
return false;
}

filter(ff, _selector).each(function(e) {
filter.call(ff).each(function(e) {

var $image = $(this);
var $canvas = $(this).siblings('canvas');
Expand Down Expand Up @@ -10345,7 +10342,9 @@ var freezeframe = (function($) {
// save references in a better way

freezeframe.prototype.trigger = function(_selector) {
filter(_selector).each(function(e) {
var ff = this;

filter.call(ff).each(function(e) {
$(this).attr('src', $(this)[0].src);
$(this).siblings('canvas').removeClass('ff-canvas-ready').addClass('ff-canvas-active');
});
Expand All @@ -10361,7 +10360,9 @@ var freezeframe = (function($) {
// save references in a better way

freezeframe.prototype.release = function(_selector) {
filter(_selector).each(function(e) {
var ff = this;

filter.call(ff).each(function(e) {
$(this).siblings('canvas').removeClass('ff-canvas-active').addClass('ff-canvas-ready');
});
}
Expand Down
3 changes: 0 additions & 3 deletions build/js/freezeframe.pkgd.min.js

This file was deleted.

37 changes: 19 additions & 18 deletions src/js/freezeframe.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@

var freezeframe = (function($) {

var images;
var options;
var is_touch_device;
var images, options, is_touch_device;

//////////////////////////////////////////////////////////////////////////////
// //
Expand All @@ -13,18 +11,22 @@ var freezeframe = (function($) {

// decorated console.log warn message
var warn = function(_message) {
console.warn('freezeframe.js : ' + _message)
console.warn('✨ freezeframe.js ✨ : ' + _message);
}

// does the freezeframe instance have captured images ?
var has_images = function() {
return images.length == 0 ? false : true;
}

// filter captured images by selector
var filter = function(_this, _selector) {
var images = _this.images,
filtered_images
var filter = function(_selector) {
var filtered_images;

if(_selector != undefined && images.length > 1) {
filtered_images = images.filter( $(_selector) );
if (filtered_images.length == 0) {
warn("no images found for selector " + _selector)
warn("no images found for selector '" + _selector + "'")
return false;
}
} else {
Expand All @@ -34,11 +36,6 @@ var freezeframe = (function($) {
return filtered_images;
}

// does the freezeframe instance have captured images ?
var has_images = function(_this) {
return _this.images.length == 0 ? false : true;
}

//////////////////////////////////////////////////////////////////////////////
// //
// Constructor //
Expand Down Expand Up @@ -124,7 +121,7 @@ var freezeframe = (function($) {
setup_required = this.images.not('.ff-setup'),
container_classnames = ['ff-container'];

if(!has_images(ff)) {
if(!has_images.call(ff)) {
warn("unable to run setup(), no images captured")
return false;
} else if(setup_required.length == 0) {
Expand Down Expand Up @@ -205,12 +202,12 @@ var freezeframe = (function($) {
click_timeout,
images;

if(!has_images(ff)) {
if(!has_images.call(ff)) {
warn("unable to run attach(), no images captured")
return false;
}

filter(ff, _selector).each(function(e) {
filter.call(ff).each(function(e) {

var $image = $(this);
var $canvas = $(this).siblings('canvas');
Expand Down Expand Up @@ -283,7 +280,9 @@ var freezeframe = (function($) {
// save references in a better way

freezeframe.prototype.trigger = function(_selector) {
filter(_selector).each(function(e) {
var ff = this;

filter.call(ff).each(function(e) {
$(this).attr('src', $(this)[0].src);
$(this).siblings('canvas').removeClass('ff-canvas-ready').addClass('ff-canvas-active');
});
Expand All @@ -299,7 +298,9 @@ var freezeframe = (function($) {
// save references in a better way

freezeframe.prototype.release = function(_selector) {
filter(_selector).each(function(e) {
var ff = this;

filter.call(ff).each(function(e) {
$(this).siblings('canvas').removeClass('ff-canvas-active').addClass('ff-canvas-ready');
});
}
Expand Down
24 changes: 21 additions & 3 deletions tests/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<style type="text/css">
body {
text-align: center;
max-width: 800px;
max-width: 1000px;
margin: 0px auto;
padding: 20px;
}
Expand All @@ -30,23 +30,41 @@

<script type="text/javascript">
$(function() {
gifs = new freezeframe().freeze();
first_two = new freezeframe().capture()
})
</script>

</head>

<body>

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

<p>natural</p>

<img class="freezeframe" src="http://49.media.tumblr.com/05dd38679f733525f02483d192f16db9/tumblr_nla0aiN4cl1qhcd6po1_500.gif" />

<p>responsive</p>

<img class="freezeframe freezeframe-responsive" src="http://45.media.tumblr.com/d07e2e7dbffc7da8e40ac31508929230/tumblr_nla0b4xBxW1qhcd6po1_500.gif" />

<p>mr. gifs by <a href="http://www.mrgif.com/">mr. gif</a>

<hr>

<p>xtras</p>

<img class="freezeframe" src="http://static1.squarespace.com/static/51c748abe4b0c275d0aa86bf/55f96e21e4b0f86680e762dc/56aa551b8b38d446e39e933b/1454003533097/.gif" />

<hr>

<img class="freezeframe" src="http://static1.squarespace.com/static/51c748abe4b0c275d0aa86bf/56141631e4b0095d43132f02/5614164be4b018c0454fd619/1444744841735/pool980.gif" />

<hr>

<img class="some_other_class freezeframe-responsive" src="http://static1.squarespace.com/static/51c748abe4b0c275d0aa86bf/56141631e4b0095d43132f02/5614164be4b0652b31fbd0a5/1444744817955/parislove9801.gif" />

<p>cinemagraphs by <a href="http://www.cinemagraph.com/">cinemagraph.com</a>

</body>
</html>

0 comments on commit ac3f4e2

Please sign in to comment.