diff --git a/js/jquery.focuspoint.js b/js/jquery.focuspoint.js
index a720d74..0b1211c 100755
--- a/js/jquery.focuspoint.js
+++ b/js/jquery.focuspoint.js
@@ -14,7 +14,7 @@
};
//Setup a container instance
- var setupContainer = function($el) {
+ var setupContainer = function($el, opt_cb) {
var imageSrc = $el.find('img').attr('src');
$el.data('imageSrc', imageSrc);
@@ -23,7 +23,7 @@
imageW: dim.width,
imageH: dim.height
});
- adjustFocus($el);
+ adjustFocus($el, opt_cb);
});
};
@@ -74,13 +74,13 @@
};
//Re-adjust the focus
- var adjustFocus = function($el) {
+ var adjustFocus = function($el, opt_cb) {
var imageW = $el.data('imageW');
var imageH = $el.data('imageH');
var imageSrc = $el.data('imageSrc');
if (!imageW && !imageH && !imageSrc) {
- return setupContainer($el); //Setup the container first
+ return setupContainer($el, opt_cb); //Setup the container first
}
var containerW = $el.width();
@@ -122,23 +122,27 @@
top: vShift,
left: hShift
});
+
+ if (opt_cb) {
+ opt_cb();
+ }
};
var $window = $(window);
var focusPoint = function($el, settings) {
var thrAdjustFocus = settings.throttleDuration ?
- throttle(function(){adjustFocus($el);}, settings.throttleDuration)
- : function(){adjustFocus($el);};//Only throttle when desired
+ throttle(function(){adjustFocus($el, settings.onFocus);}, settings.throttleDuration)
+ : function(){adjustFocus($el, settings.onFocus);};//Only throttle when desired
var isListening = false;
- adjustFocus($el); //Focus image in container
+ adjustFocus($el, settings.onFocus); //Focus image in container
//Expose a public API
return {
adjustFocus: function() {
- return adjustFocus($el);
+ return adjustFocus($el, settings.onFocus);
},
windowOn: function() {
diff --git a/js/jquery.focuspoint.min.js b/js/jquery.focuspoint.min.js
index b3a0da9..f43463f 100644
--- a/js/jquery.focuspoint.min.js
+++ b/js/jquery.focuspoint.min.js
@@ -5,4 +5,4 @@
* Copyright (c) 2014 J. Menz; MIT License
* @preserve
*/
-!function($){var t={reCalcOnWindowResize:!0,throttleDuration:17},n=function(t){var n=t.find("img").attr("src");t.data("imageSrc",n),i(n,function(n,i){t.data({imageW:i.width,imageH:i.height}),r(t)})},i=function(t,n){$("").one("load",function(){n(null,{width:this.width,height:this.height})}).attr("src",t)},a=function(t,n){var i=!1;return function(){var a=Array.prototype.slice.call(arguments,0);if(i)return!1;i=!0,setTimeout(function(){i=!1,t.apply(null,a)},n)}},o=function(t,n,i,a,o){var r=Math.floor(n/2),e=(a+1)/2,u=Math.floor(i/t),f=Math.floor(e*u);o&&(f=u-f);var c=f-r,s=u-f,h=n-r;return s0&&u>0&&i>0&&a>0))return!1;var l=i/e,w=a/u;s.css({"max-width":"","max-height":""}),i>e&&a>u&&s.css(l>w?"max-height":"max-width","100%"),l>w?h=o(w,e,i,f):l").one("load",function(){i(null,{width:this.width,height:this.height})}).attr("src",n)},o=function(t,n,i,o,a){var r=Math.floor(n/2),u=(o+1)/2,e=Math.floor(i/t),f=Math.floor(u*e);a&&(f=e-f);var c=f-r,s=e-f,h=n-r;return s0&&c>0&&r>0&&u>0))return!1;var g=r/f,m=u/c;d.css({"max-width":"","max-height":""}),r>f&&u>c&&d.css(g>m?"max-height":"max-width","100%"),g>m?l=o(m,f,r,s):g