JSFiddle - React, Tailwind, and code Playground
by generatorx5678
HTML
<div class="arrow up_arrow">UP</div>
<div class="content">
<div class="hovers">
<div class="top hover"></div>
<div class="bottom hover"></div>
</div>
<img src="http://lorempixel.com/400/300/cats/1" />
<img src="http://lorempixel.com/400/300/cats/2" />
<img src="http://lorempixel.com/400/300/cats/3" />
</div>
<div class="arrow down_arrow">DOWN</div>
CSS
.content{
width:400px;
height:300px;
overflow:hidden;
border:1px solid #999;
}
.content img{display:block;}
.arrow{
display:inline-block;
padding:5px 15px;
background:#eee;
border-radius:3px;
margin:3px 0;
cursor:pointer;
border:1px solid #ddd;
}
.hovers {
position: absolute;
width: 402px;
height: 302px;
background-color: black;
opacity: 0.3;
}
.hovers .top {
position: relative;
top: 0%;
background-color: red;
height: 50px;
}
.hovers .bottom {
position: relative;
bottom: -67%;
background-color: blue;
height: 50px;
}
JavaScript
var gallery = $('.content'),
height = gallery.height(),
topHover = $('.top'),
bottomHover = $('.bototm');
console.log(topHover)
console.log(bottomHover)
$('.hover').on('mouseover', function(){
var up = $(this).is('.top');
if (up) {
gallery.animate({'scrollTop': '-=' + height});
console.log(height)
} else {
gallery.animate({'scrollTop': '+=' + height});
console.log(height)
}
});
$('.arrow').on('click', function(){
var up = $(this).is('.up_arrow');
if (up) {
gallery.animate({'scrollTop': '-=' + height});
console.log(height)
} else {
gallery.animate({'scrollTop': '+=' + height});
console.log(height)
}
});