Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // eaSlyder ver. 0.2
- (function($) {
- $.fn.eaSlyder = function(options) {
- var $images = this.find('img'), total = $images.length, cur = 0, silderWidth = this.width();
- var settings = {
- 'duration':4000,
- 'method':'fade'
- };
- if (typeof options === 'object') var settings = $.extend(settings, options);
- else if (options) duration = options || 4000;
- this.css({'overflow': 'hidden','position': 'relative'});
- $images.css('height',this.height()+'px');
- switch (settings['method']) {
- case 'fade':
- $images.each(function(index) {
- if (index) $(this).hide();
- });
- setInterval(function() {
- $images.eq(cur).fadeOut(function() {
- cur = (cur == total -1) ? 0 : cur+1;
- $images.eq(cur).fadeIn();
- });
- }, settings['duration']);
- break;
- case 'moveLeft':
- $images.each(function(index) {
- if (index) $(this).css({'position':'absolute','opacity':'0'});
- else $(this).css({'position':'absolute','left':'0'});
- });
- setInterval(function() {
- var silderWidth = $images.eq(cur).parent().width();
- $images.eq(cur).animate({
- opacity: 0,
- left: '-='+(silderWidth/2)
- },1000);
- cur = (cur == total-1) ? 0 : cur+1;
- $images.eq(cur).css('left',($images.eq(cur).width())+'px').animate({
- opacity: 1,
- left: (silderWidth/2-$images.eq(cur).width()/2)+'px'
- },1000);
- }, settings['duration']);
- break;
- }
- return this;
- }
- })(jQuery);
- $(document).ready(function() {
- $('#fade').eaSlyder({'method':'moveLeft'});
- });
Advertisement
Add Comment
Please, Sign In to add comment