Velocity.js cards layout

Developer
Size
5,151 Kb
Views
40,480

How do I make an velocity.js cards layout?

Velocity.js + cards/boxes, animation and cats.v1.1: Changed delay to use Velocity's inbuilt delay function.. What is a velocity.js cards layout? How do you make a velocity.js cards layout? This script and codes were developed by Tommie Hansen on 21 August 2022, Sunday.

Velocity.js cards layout Previews

Velocity.js cards layout - Script Codes HTML Codes

<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Velocity.js cards layout</title> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/meyer-reset/2.0/reset.min.css"> <link rel='stylesheet prefetch' href='http://fonts.googleapis.com/css?family=Open+Sans'>
<link rel='stylesheet prefetch' href='http://maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css'> <link rel="stylesheet" href="css/style.css">
</head>
<body> <h1>Velocity.js <i>cards and boxes</i></h1>
<pre>Test of animation performance etc <i class="fa fa-question-circle" title="4 first runs animation X, others run animation Y etc. Purely a test for demo purposes.&#10;Please note that CodePen has a negative impact on performance."></i></pre>
<div id="a"><i class="fa fa-plus">&nbsp; ADD 10 BOXES</i><i onclick="init(true);" class="fa fa-refresh">&nbsp; RE-RUN ANIM</i><i onclick="window.location=window.location" class="fa fa-refresh">&nbsp; RELOAD PEN</i></div>
<div id="load"><img src="http://preloaders.net/preloaders/496/Flip%20Flop.gif"><br>2 second fake load</div>
<div id="boxes"> <div class="box"> <img class="full" width="300" height="200" src="http://placeimg.com/20/20/animals/1//1/"> <div class="boxInner"> <h2>Cats are animals</h2> <p class="intro">It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p> </div> <div class="boxFoot"> <!-- let's complexify things --> <div><i class="fa fa-clock-o"></i> 2 days ago <em>by</em> Evil Human</em></div> <div class="right"><span><i class="fa fa-heart"></i> 12</span> <span><i class="fa fa-thumbs-down" title=""></i> 3</span></div> </div> </div> <div class="box"> <img class="full" width="300" height="200" src="http://placeimg.com/20/20/animals/1/"> <div class="boxInner"> <h2>Humans are not cats</h2> <p class="intro">When an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged.</p> </div> <div class="boxFoot"> <!-- let's complexify things --> <div><i class="fa fa-clock-o"></i> 2 days ago <em>by</em> Evil Human</em></div> <div class="right"><span><i class="fa fa-heart"></i> 19</span> <span><i class="fa fa-thumbs-down"></i> 17</span></div> </div> </div> <div class="box"> <img class="full" width="300" height="200" src="http://placeimg.com/20/20/animals/1/"> <div class="boxInner"> <h2>Cats are not dogs</h2> <p class="intro">When an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged.</p> </div> <div class="boxFoot"> <!-- let's complexify things --> <div><i class="fa fa-clock-o"></i> 2 days ago <em>by</em> Evil Human</em></div> <div class="right"><span><i class="fa fa-heart"></i> 19</span> <span><i class="fa fa-thumbs-down"></i> 17</span></div> </div> </div> <div class="box"> <img class="full" width="300" height="200" src="http://placeimg.com/20/20/animals/1/"> <div class="boxInner"> <h2>Cats are animals</h2> <p class="intro">It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p> </div> <div class="boxFoot"> <!-- let's complexify things --> <div><i class="fa fa-clock-o"></i> 2 days ago <em>by</em> Evil Human</em></div> <div class="right"><span><i class="fa fa-heart"></i> 12</span> <span><i class="fa fa-thumbs-down"></i> 3</span></div> </div> </div> <div class="box"> <img class="full" width="300" height="200" src="http://placeimg.com/20/20/animals/1/"> <div class="boxInner"> <h2>Humans are not cats</h2> <p class="intro">When an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged.</p> </div> <div class="boxFoot"> <!-- let's complexify things --> <div><i class="fa fa-clock-o"></i> 2 days ago <em>by</em> Evil Human</em></div> <div class="right"><span><i class="fa fa-heart"></i> 19</span> <span><i class="fa fa-thumbs-down"></i> 17</span></div> </div> </div> <div class="box"> <img class="full" width="300" height="200" src="http://placeimg.com/20/20/animals/1/"> <div class="boxInner"> <h2>Cats are not dogs</h2> <p class="intro">When an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged.</p> </div> <div class="boxFoot"> <!-- let's complexify things --> <div><i class="fa fa-clock-o"></i> 2 days ago <em>by</em> Evil Human</em></div> <div class="right"><span><i class="fa fa-heart"></i> 19</span> <span><i class="fa fa-thumbs-down"></i> 17</span></div> </div> </div> <div class="box"> <img class="full" width="300" height="200" src="http://placeimg.com/20/20/animals/1/"> <div class="boxInner"> <h2>Cats are animals</h2> <p class="intro">It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p> </div> <div class="boxFoot"> <!-- let's complexify things --> <div><i class="fa fa-clock-o"></i> 2 days ago <em>by</em> Evil Human</em></div> <div class="right"><span><i class="fa fa-heart"></i> 12</span> <span><i class="fa fa-thumbs-down"></i> 3</span></div> </div> </div> <div class="box"> <img class="full" width="300" height="200" src="http://placeimg.com/20/20/animals/1/"> <div class="boxInner"> <h2>Humans are not cats</h2> <p class="intro">When an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged.</p> </div> <div class="boxFoot"> <!-- let's complexify things --> <div><i class="fa fa-clock-o"></i> 2 days ago <em>by</em> Evil Human</em></div> <div class="right"><span><i class="fa fa-heart"></i> 19</span> <span><i class="fa fa-thumbs-down"></i> 17</span></div> </div> </div> <div class="box"> <img class="full" width="300" height="200" src="http://placeimg.com/20/20/animals/1/"> <div class="boxInner"> <h2>Cats are not dogs</h2> <p class="intro">When an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged.</p> </div> <div class="boxFoot"> <!-- let's complexify things --> <div><i class="fa fa-clock-o"></i> 2 days ago <em>by</em> Evil Human</em></div> <div class="right"><span><i class="fa fa-heart"></i> 19</span> <span><i class="fa fa-thumbs-down"></i> 17</span></div> </div> </div> <div class="box"> <img class="full" width="300" height="200" src="http://placeimg.com/20/20/animals/1/"> <div class="boxInner"> <h2>The end of the world</h2> <p class="intro">When an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged.</p> </div> <div class="boxFoot"> <!-- let's complexify things --> <div><i class="fa fa-clock-o"></i> 2 days ago <em>by</em> Evil Human</em></div> <div class="right"><span><i class="fa fa-heart"></i> 19</span> <span><i class="fa fa-thumbs-down"></i> 17</span></div> </div> </div>
</div><!-- /#boxes --> <script src='http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script>
<script src='http://cdn.jsdelivr.net/velocity/1.1.0/velocity.min.js'></script>
<script src='http://cdn.jsdelivr.net/velocity/1.1.0/velocity.ui.min.js'></script> <script src="js/index.js"></script>
</body>
</html>

Velocity.js cards layout - Script Codes CSS Codes

/* + Reset.css */
/* + Open Sans @ Google Fonts */
/* + FontAwesome */
/* --------------------------------------
NOTE: Only @ Chrome, others may fail
--------------------------------------*/
/* defaults */
html,body { min-height:100%; }
body { font-family:"Open Sans", helvetica,arial,sans-serif; font-size:13px; line-height: 160%; font-weight: 300; color: #444; background: #eee; }
*,*:before,*:after { box-sizing: border-box; } img { display:block; } i { font-style:normal; } em { font-style:italic; }
/* Refresh, add boxes etc */
#a { position:absolute; top:20px; right:20px; display: block; background: #eee; color:#aaa; -webkit-user-select: none; user-select: none; } #a i { cursor: pointer; font-size:11px; padding:8px 10px; border:1px dotted #ccc; transition:all .12s; margin-left:-1px; }
#a .fa { font-family: "FontAwesome", "Open Sans", sans-serif; } #a i:hover { color: #fff; background: hotpink; border:1px solid hotpink; }
#a .fa:last-child { background:#d00; border-color:#d00; color:#fff; }
#a .fa:last-child:hover { background: #a00; border-color: #a00; }
pre i { cursor:help; display:inline-block; margin: 0 0 0 3px; }
pre i:hover { color:#222; }
/* ----- end defaults ---- */
/* START OPACITY */
.box, #load { opacity:0; }
#boxes, .box, #load { transform: translate3d(0,0,0); } /* reomves larger paints */
/* Loader (fake) */
#load { text-align:center; z-index:10; background:#eee; position:absolute; top:50%; left:50%; height:60px; width:120px; overflow:hidden; margin-left:-60px; margin-top:-30px; font-size:11px; text-transform:uppercase; color:#aaa; }
#load img { display:inline-block; text-align:center; }
/* Main layout */
#boxes, h1, pre { width: 660px; margin: 40px auto; text-align:center; position: relative; }
pre { display:block; margin-top:-25px; text-transform: uppercase; color:#aaa; font-size:11px; letter-spacing:.5px; }
/* #boxes, h1 { width: 1340px; } /* 4x width */
/* Headers */
h1,h2 { font-size: 21px; line-height:100%; font-weight:300; }
h1 { font-size: 24px; font-weight: 700; border-bottom:1px solid #ccc; }
h1 i { font-weight: 300; }
/* Paddings / Margins */
h1 { padding: 20px 0; }
h2 { margin: 0 0 12px; }
.box { margin: 18px 14px; } /* inline-block adds +4px margin */
.boxInner { padding:20px; }
.boxFoot { padding: 10px 20px; }
.box img.full { margin:-1px; margin-bottom: 5px; } /* no faux image resize, tnx */
/* Boxes */
.box { width: 300px; height: 460px; display:inline-block; *display:inline; text-align:left; vertical-align:top; position:relative; border:1px solid #ddd; border-bottom-width:2px; background: #fff;
}
.boxInner { padding: 20px; }
.boxFoot { position:absolute; bottom:0; left:0; width:100%; background: #efc; color: #9b7; font-size:11px;
}
/* Box footer */
.boxFoot div { display:inline-block; *display: inline; }
.boxFoot em { font-family:georgia, serif; font-size:10px; }
.boxFoot .right { float:right; cursor: pointer; }
.right span { padding: 3px; transition: color .2s ease; }
.right span:last-child { margin-right:-3px; }
.right span:hover { color:#666; }

Velocity.js cards layout - Script Codes JS Codes

/* + jquery.js */
/* + velocity.js */
/* + velocity.ui.js */
// flickUpIN
$.Velocity.RegisterUI("transition.flickUpIn", { defaultDuration: 500,	calls: [	[ { opacity: [1, 0], translateY: [0, 100], rotateZ: [0, 3], translateZ: 0 } ]	]
});
// moveIn
$.Velocity.RegisterUI("transition.moveIn", { defaultDuration: 500,	calls: [	[ { opacity: [1, 0], translateY: [0, 50], translateZ: 0 } ]	]
});
// Selections
var boxes = $('#boxes');
var box = boxes.find('.box');
var loader = $('#load'); // needs to get 'truly' hidden due to animated gif, else PERF-lag (don't use display:false on it)
var boxFirst = box.slice(0,10);
// Set defaults
var aniDuration = 500; // animation duration
var aniStag = 120; // stag X ms
var loaderDelay = 2000; // fake loader duration
var firstNum = 4; // do specific animation with 4 first boxes (often heavier ones)
var Firsts = box.slice(0,firstNum); // set it
var Lasts = box.slice(firstNum); // do less heavy animations on all above var firstNum
// FlyIn velocity transition
function flyIn(e,inOut,wait){	//var animIn = 'transition.slideUp' + 'In';	var animIn = 'transition.move' + 'In';	var animLight = 'fadeIn';	var animOut = 'transition.slideRight' + 'Out';	if(inOut=='in'){	e.velocity(animIn, { stagger: aniStag, duration: aniDuration, display: false, ease: 'easeOutSine', delay: wait });	}	else if(inOut=='lightIn') { e.velocity(animLight, { delay: wait, duration: aniDuration, display: false });	}	else { e.velocity(animOut, { delay: wait, stagger: aniStag, duration: aniDuration, display: false });	}
}
// INIT + FAKE LOADER
function init(isClick){ // for use with "RE-RUN ANIM" button if(isClick) { box = boxes.find('.box'); // need to re-select boxes if boxes has been added box.css('opacity',0); $(window).scrollTop(0); // just for demo purposes... init(); } else { // Run loading graphic loader.velocity("transition.slideDownIn", { delay: 100, duration: 500 }); // Hide loading graphic + run fuction go() when complete loader.velocity("transition.slideUpOut", { delay: loaderDelay, duration: 500, complete: function(){ go(); } }); }
}
init(); // run! on first load
function go(){	flyIn(Firsts,'in',250); // run animation on "Firsts"	flyIn(Lasts,'lightIn',250*firstNum); // Start light animation X times after var Firsts
}
// UNRELATED TO ANIMATION
// Add more boxes
$('.fa-plus').click(function(){ var max = 10; var t = $(this); boxFirst.clone().appendTo(boxes); box = boxes.find('.box'); // re-select curDivs = box.length; var stagOff = ''; if(curDivs > 40) { aniStag = 0; stagOff = ', 40+ = stag off'; } t.html('&nbsp; Add ' + max + ' more (current = ' + curDivs + stagOff + ')');
})
// Don't load same image for every image
var img = box.find('img');
//var uri = 'http://placeimg.com/300/200/nature/';
var uri = 'http://lorempixel.com/300/200/nature/'
var l = img.length;
var comb;
for(var i = 0; i < l; i++) {	var num = i+1;	// get 1-XX	img[i].src = uri+num;
}
Velocity.js cards layout - Script Codes
Velocity.js cards layout - Script Codes
Home Page Home
Developer Tommie Hansen
Username tommiehansen
Uploaded August 21, 2022
Rating 4.5
Size 5,151 Kb
Views 40,480
Do you need developer help for Velocity.js cards layout?

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!

Tommie Hansen (tommiehansen) Script Codes
Create amazing art & images 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!