Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 12 additions & 8 deletions js/jquery.focuspoint.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -23,7 +23,7 @@
imageW: dim.width,
imageH: dim.height
});
adjustFocus($el);
adjustFocus($el, opt_cb);
});
};

Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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() {
Expand Down
2 changes: 1 addition & 1 deletion js/jquery.focuspoint.min.js

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