Created
May 6, 2010 07:34
-
-
Save rich97/391895 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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