Catslicer

Developer
Size
2,957 Kb
Views
48,576

How do I make an catslicer?

What is a catslicer? How do you make a catslicer? This script and codes were developed by Theun on 23 July 2022, Saturday.

Catslicer Previews

Catslicer - Script Codes HTML Codes

<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Catslicer</title> <link rel="stylesheet" href="css/style.css">
</head>
<body> <ul class="cat-slice"> <li><img src="http://placekitten.com/401/600"/></li> <li><img src="http://placekitten.com/400/600"/></li> <li><img src="http://placekitten.com/402/600"/></li> <li><img src="http://placekitten.com/403/600"/></li> <li><img src="http://placekitten.com/404/600"/></li>
</ul> <script src='http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script> <script src="js/index.js"></script>
</body>
</html>

Catslicer - Script Codes CSS Codes

.cat-slice { padding: 0; margin: 0; left: 50%; top: 50%;
}
.cat-slice li { list-style-type: none; display: block; height: 600px; width: 400px;
}

Catslicer - Script Codes JS Codes

(function($){	$.fn.extend({	slot: function( params ) {	var defaults = {	horizontal: true,	slots: 20	};	var options = $.extend( defaults, params );	return this.each(function(){	var $context = $(this),	$container = $('<div>'),	$children = $context.children(),	numItems = $children.size(),	horizontal = options.horizontal,	viewports = [],	wrappers = [],	height = $children.height(),	width = $children.width(),	slots = options.slots,	stepA = Math.floor(horizontal ? height / slots : width / slots),	stepB = horizontal ? width : height;	function init() {	var $viewport,	$wrapper,	style,	items;	// Style children and tag with their index	$children.each(function( index ){	style = {};	style[ horizontal ? 'left' : 'top' ] = index * stepB;	style.position = 'absolute';	$(this).data('id', index).css( style );	});	for( var i = 0; i < slots; i++ ) {	// Create a viewport for this row / col	$viewport = $('<div>').addClass('viewport');	// Create an element to hold the items	$wrapper = $context.clone();	// Copy the items	items = $wrapper.children().remove();	// Shuffle them	items = shuffle( items.toArray() );	// Initialise the viewport and wrapper	setupItem( $viewport, $wrapper, i );	// Add the items to the wrapper	$wrapper.append( items );	// Add the wrapper to the viewport	$viewport.append( $wrapper );	// Add the viewport to the container	$container.append( $viewport );	// Store a reference to the wrapper and viewport	viewports.push( $viewport );	wrappers.push( $wrapper );	}	// Append	$context.before( $container ).remove();	$container.addClass( 'slot' );	}	function setupItem( $viewport, $wrapper, index ) {	// Containers for styles	var viewportCSS = {},	wrapperCSS = {};	// Set the cropped viewport dimension	viewportCSS[ horizontal ? 'height' : 'width' ] = stepA;	// Set the full size viewport dimension	viewportCSS[ horizontal ? 'width' : 'height' ] = stepB;	// Offset the viewport	viewportCSS[ horizontal ? 'top' : 'left' ] = stepA * index;	// Position it and kill overflow	viewportCSS.position = 'absolute';	viewportCSS.overflow = 'hidden';	// Offset the wrapper to compensate for the viewport offset	wrapperCSS[ horizontal ? 'top' : 'left' ] = stepA * -index;	wrapperCSS.position = 'relative';	// Apply styles	$viewport.css( viewportCSS );	$wrapper.css( wrapperCSS );	}	function shuffle( arr ) {	var shuffled = [],	copied = arr.concat();	while( copied.length > 0 ) {	shuffled.push( copied.splice( Math.floor(Math.random() * copied.length), 1 )[0] );	}	return shuffled;	}	// Public API	this.shuffle = function() {	var tween,	index,	item;	for( var i = 0; i < wrappers.length; i++ ) {	item = wrappers[i];	index = Math.floor(Math.random() * numItems);	tween = {};	tween[ horizontal ? 'left' : 'top' ] = -index * stepB;	$(item).stop().animate( tween, {	duration: 1200	});	}	};	$(this).bind('goto', function( params ){	console.log( 'goto', params );	});	/*	this.goto = function( params ) {	console.log( 'goto', params );	};	*/	// Initialise component	init();	});	}	});
})(jQuery);
var catSlice = $('.cat-slice').slot({ //horizontal: true, //slots: 3
});
function shuffle() { catSlice.trigger( 'shuffle' );
}
setInterval(shuffle, 2800);
shuffle();
Catslicer - Script Codes
Catslicer - Script Codes
Home Page Home
Developer Theun
Username tjoen
Uploaded July 23, 2022
Rating 3.5
Size 2,957 Kb
Views 48,576
Do you need developer help for Catslicer?

Find the perfect freelance services for your business! Fiverr's mission is to change how the world works together. Fiverr connects businesses with freelancers offering digital services in 500+ categories. Find Developer!

Theun (tjoen) Script Codes
Create amazing blog posts with AI!

Jasper is the AI Content Generator that helps you and your team break through creative blocks to create amazing, original content 10X faster. Discover all the ways the Jasper AI Content Platform can help streamline your creative workflows. Start For Free!