Custom Animation Menu Css/ Jquery
I have this code snippet and wanted to know if there is any possibility to modify it, in order to obtain after hover translation, keeping in place or moving a few more pixels to th
Solution 1:
after hover translation, keeping in place or moving a few more pixels to the right on click event, until another menu botton will be clicked.
Added .toggleClass()
, .hasClass()
, .not()
, .siblings()
, .hover()
to jsfiddle https://jsfiddle.net/kjhtswp9/ originally created by @CY5 , maintaining hover translation effect
$(function () {
$('nav ul li').click(function (e) {
//Set the aesthetics (similar to :hover)
$('nav ul li')
.not(".clicked").removeClass('hovered')
.filter(this).addClass("clicked hovered")
.siblings().toggleClass("clicked hovered", false);
}).hover(function () {
$(this).addClass("hovered")
}, function () {
$(this).not(".clicked").removeClass("hovered")
});
var pageSize = 4,
$links = $(".pagedMenu li"),
count = $links.length,
numPages = Math.ceil(count / pageSize),
curPage = 1;
showPage(curPage);
functionshowPage(whichPage) {
var previousLinks = (whichPage - 1) * pageSize,
nextLinks = (previousLinks + pageSize);
$links.show();
$links.slice(0, previousLinks).hide();
$links.slice(nextLinks).hide();
showPrevNext();
}
functionshowPrevNext() {
if ((numPages > 0) && (curPage < numPages)) {
$("#nextPage").removeClass('hidden');
$("#msg").text("(" + curPage + " of " + numPages + ")");
} else {
$("#nextPage").addClass('hidden');
}
if ((numPages > 0) && (curPage > 1)) {
$("#prevPage").removeClass('hidden');
$("#msg").text("(" + curPage + " of " + numPages + ")");
} else {
$("#prevPage").addClass('hidden');
}
}
$("#nextPage").on("click", function () {
showPage(++curPage);
});
$("#prevPage").on("click", function () {
showPage(--curPage);
});
});
.hidden {
display: none;
}
body {
font: normal 1.0em Arial, sans-serif;
}
nav.pagedMenu {
color: red;
font-size: 2.0em;
line-height: 1.0em;
width: 8em;
position: fixed;
top: 50px;
}
nav.pagedMenuul {
list-style: none;
margin: 0;
padding: 0;
}
nav.pagedMenuulli {
height: 1.0em;
padding: 0.15em;
position: relative;
border-top-right-radius: 0em;
border-bottom-right-radius: 0em;
-webkit-transition: -webkit-transform 220ms, background-color 200ms, color 500ms;
transition: transform 220ms, background-color 200ms, color 500ms;
}
nav.pagedMenuulli.hovered {
-webkit-transform: translateX(1.5em);
transform: translateX(1.5em);
}
navulli:hovera {
transition: color, 1200ms;
color: red;
}
nav.pagedMenuullispan {
display: block;
font-family: Arial;
position: absolute;
font-size: 1em;
line-height: 1.25em;
height: 1.0em;
top: 0;
bottom: 0;
margin: auto;
right: 0.01em;
color: #F8F6FF;
}
a {
color: gold;
transition: color, 1200ms;
text-decoration: none;
}
#pagination,
#prevPage,
#nextPage {
font-size: 1.0em;
color: gold;
line-height: 1.0em;
padding-top: 250px;
padding-left: 5px;
}
<scriptsrc="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script><navclass="pagedMenu"><ulstyle="font-size: 28px;"><liclass=""style="margin-bottom: 5px;"><ahref="#">Link 1</a></li><liclass=""style="margin-bottom: 5px;"><ahref="#">Link 2</a></li><liclass=""style="margin-bottom: 5px;"><ahref="#">Link 3</a></li><liclass=""style="margin-bottom: 5px;"><ahref="#">Link 4</a></li><liclass=""style="margin-bottom: 5px;"><ahref="#">Link 5</a></li><liclass=""style="margin-bottom: 5px;"><ahref="#">Link 6</a></li><liclass=""style="margin-bottom: 5px;"><ahref="#">Link 7</a></li><liclass=""style="margin-bottom: 5px;"><ahref="#">Link 8</a></li><liclass=""style="margin-bottom: 5px;"><ahref="#">Link 9</a></li><liclass=""style="margin-bottom: 5px;"><ahref="#">Link 10</a></li><liclass=""style="margin-bottom: 5px;"><ahref="#">Link 11</a></li><liclass=""style="margin-bottom: 5px;"><ahref="#">Link 12</a></li></ul></nav><divid="pagination"><ahref="#"id="prevPage"class="hidden">Previous</a> <ahref="#"id="nextPage"class="hidden">Next</a><spanid="msg"></span></div>
jsfiddle http://jsfiddle.net/kjhtswp9/3
Post a Comment for "Custom Animation Menu Css/ Jquery"