JavaScript preprocessors can help make authoring JavaScript easier and more convenient. For instance, CoffeeScript can help prevent easy-to-make mistakes and offer a cleaner syntax and Babel can bring ECMAScript 6 features to browsers that only support ECMAScript 5.
Any URL's added here will be added as <script>
s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.
You can apply a script from anywhere on the web to your Pen. Just put a URL to it here and we'll add it, in the order you have them, before the JavaScript in the Pen itself.
If the script you link to has the file extension of a preprocessor, we'll attempt to process it before applying.
You can also link to another Pen here, and we'll pull the JavaScript from that Pen and include it. If it's using a matching preprocessor, we'll combine the code before preprocessing, so you can use the linked Pen as a true dependency.
HTML Settings
Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.
<div class="container">
<div class=titleBox>
<h1>My WCC submissions</h1>
<h2>#weeklyCodingChallenge</h2>
</div>
<div class="portfolio-wrapper">
<div class="portfolio-item js">
<img src="https://oi431.photobucket.com/albums/qq33/deppkyo/edited-image_zpsmb6owsak.png" alt="week 1">
<div class="portfolio-info"><p>Week #1: sign up form</p><a href="https://codepen.io/augs0/full/jJvEGY">See project</a>
</div>
</div>
<div class="portfolio-item js">
<img src="https://oi431.photobucket.com/albums/qq33/deppkyo/weektwo_zpsg4ja1rfu.png" alt="week 2">
<div class="portfolio-info"><p>Week #2: image slider</p><a href="https://codepen.io/augs0/full/YgRWrY">See project</a>
</div>
</div>
<div class="portfolio-item js">
<img src="https://oi431.photobucket.com/albums/qq33/deppkyo/weekthree_zpsl1acvgsm.png" alt="week 3">
<div class="portfolio-info"><p>Week #3: custom navigation</p><a href="https://codepen.io/augs0/full/zbydxo">See project</a>
</div>
</div>
<div class="portfolio-item no-js">
<img src="https://oi431.photobucket.com/albums/qq33/deppkyo/weekfour_zpslcwdwisw.png" alt="week 4">
<div class="portfolio-info"><p>Week #4: loading animation</p><a href="https://codepen.io/augs0/full/RdmeaQ">See project</a>
</div>
</div>
<div class="portfolio-item js">
<img src="https://oi431.photobucket.com/albums/qq33/deppkyo/weekfive_zpshvxx6hxx.png" alt="week 5">
<div class="portfolio-info"><p>Week #5: colouring app</p><a href="https://codepen.io/augs0/full/jRWoKW">See project</a>
</div>
</div>
<div class="portfolio-item no-js">
<img src="https://oi431.photobucket.com/albums/qq33/deppkyo/weeksix_zpszoypxnvy.png" alt="week 6">
<div class="portfolio-info"><p>Week #6: UI button kit</p><a href="https://codepen.io/augs0/full/XQpJoB">See project</a>
</div>
</div>
<div class="buttonBox">
<button class="see-all ripple">See all projects</button>
<button class="js-only ripple">See projects using JS</button>
</div>
</div>
@import url('https://fonts.googleapis.com/css?family=Rock+Salt');
*{
box-sizing:border-box;
}
html, body{
margin:0;
padding:0;
}
body{
background:black;
color:white;
font-family: 'Rock Salt', cursive;
}
.titleBox{
position: absolute;
bottom: 0;
right: 10px;
}
.portfolio-wrapper{
display:flex;
flex-wrap:wrap;
top: 0;
position: absolute;
}
.portfolio-item{
position: relative;
width: 20%;
height: 210px;
overflow: hidden;
border: white solid 2px;
border-radius: 40%;
margin:10px;
}
.portfolio-item img{
object-fit: center;
height:100%;
width:100%;
}
.portfolio-item a{
font-size:0.8rem;
background:white;
color:black;
border-radius:20px;
text-decoration:none;
padding:5px;
}
.portfolio-item:hover
.portfolio-info{
width:100%;
opacity:1;
}
.portfolio-info{
background-color: black;
display: flex;
justify-content: center;
align-items: center;
flex-direction: column;
position: absolute;
top: 0;
left: 0;
opacity: 0;
width: 0;
height: 100%;
padding:20px;
transition: opacity 100ms ease-in-out;
transition: width 100ms ease-in-out;
}
.ripple{
position:relative;
overflow:hidden; /*hides the larger part of circle when created*/
font-family:'Rock Salt', cursive;
font-size: 0.7rem;
border-radius:10%;
width:180px;
background:transparent;
color:white;
outline:none;
}
.ripple .circle {
position: absolute;
border-radius: 50%;
background-color: white;
width: 100px;
height: 100px;
transform: translate(-50%, -50%) scale(0); /*centres the circle at the point of click*/
animation: scale 0.5s ease-out; /*makes the circle grow larger*/
}
.hide{
display:none;
}
@keyframes scale {
to {
transform: translate(-50%, -50%) scale(4);
opacity: 0; /*grows then 'disappears' through opacity*/
}
}
@media (max-width:768px)
{
.titleBox{
position: fixed;
writing-mode: vertical-lr;
font-size: 0.4rem;
bottom: 10px;
right: -10px;
}
.portfolio-item{
width:80%;
}
}
const seeAllBtn = document.querySelector('.see-all');
const jsOnlyBtn = document.querySelector('.js-only');
const allJs = document.querySelectorAll('.js');
const nonJs = document.querySelectorAll('.no-js')
function showAll(){
for(var i = 0; i < nonJs.length; i++) {
nonJs[i].classList.remove('hide');
nonJs[i].classList.add('show');
}
}
function showJsOnly(){
for(var i = 0; i < nonJs.length; i++) {
nonJs[i].classList.add('hide');
}
}
seeAllBtn.addEventListener('click', showAll);
jsOnlyBtn.addEventListener('click', showJsOnly)
//ripple effect on buttons
const buttons = document.querySelectorAll('.ripple');
buttons.forEach(button => {
button.addEventListener('click', function(e) {
//location of click
let x = e.clientX;
let y = e.clientY;
//get top and left of the element to calculate where the circle should appear in relation to the element
let buttonTop = e.target.offsetTop;
let buttonLeft = e.target.offsetLeft;
//calculates where the circle should appear by minusing the elements measurements from where the user clicked
let xInside = x - buttonLeft;
let yInside = y - buttonTop;
//actually creates the circle. the top and left positions are calculated by using the calculations above i.e. minusing elements' measurements from click location. finally, the shape is appended to the button
let circle = document.createElement('span');
circle.classList.add('circle');
circle.style.top = yInside + 'px';
circle.style.left = xInside + 'px';
this.appendChild(circle);
setTimeout(() => {
circle.remove();
}, 500); //necessary so that we don't end up with multiple circles as they otherwise stay appended to the button
});
});
Also see: Tab Triggers