Skip to content

Instantly share code, notes, and snippets.

@rich97
Created May 6, 2010 07:34
Show Gist options
  • Save rich97/391895 to your computer and use it in GitHub Desktop.
Save rich97/391895 to your computer and use it in GitHub Desktop.
var loader = {
vpX: 0,
vpY: 0,
img: null,
setViewport: function(elem) {
loader.vpX = elem.width();
loader.vpY = elem.height();
},
callback: function(obj, callback) {
$.each(callback, function(method, params) {
loader[method].apply(obj, params);
});
},
loadImage: function(elem, img, complete) {
var newImg = new Image();
$(newImg)
.load(function () {
$(this).hide();
elem.append(this);
if (complete !== null) {
loader.callback(this, complete);
}
})
.attr('src', img);
},
animateInFg: function(direction, speed) {
// Move the image into view ...
},
animateOutFg: function(direction, speed) {
// Move the image out of view ...
}
}
$(document).ready(function() {
var elems = $('#slider .page');
elems.each(function(index) {
int = index + 1;
loader.setViewport($(this));
loader.loadImage($(this), 'img/mino-small.png', {animateInFg: ['left', 2000]});
$(this).find('img').live('click', function(e) {
e.preventDefault();
loader.callback(this, {animateOutFg: ['right', 1000]});
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment