$(function () {
var $pages = $('.pt-page'),
pagesCount = $pages.length,
current = 0,
animating = false,
vectorPage = 'bot-top';
function animate(page) {
if (vectorPage === 'bot')
{
animating = true;
if (page - current > 0) {
$pages.eq(current).addClass('blurA');
} else {
$pages.eq(page).removeClass('blurA');
}
$pages.eq(current).removeClass('pt-page-ontop');
$pages.eq(page).addClass('pt-page-ontop pt-page-current pt-page-moveFromBottom');
current = page;
setTimeout(function () {
animating = false;
}, 1800);
}
if (vectorPage = 'top')
{
animating = true;
if (page - current > 0) {
$pages.eq(current).addClass('blurA');
} else {
$pages.eq(page).removeClass('blurA ');
}
$pages.eq(current).removeClass('pt-page-ontop');
$pages.eq(page).addClass('pt-page-ontop pt-page-current pt-page-moveFromTop');
current = page;
setTimeout(function () {
animating = false;
}, 1800);
}
}
function up() {
if (current > 0) {
animate(current - 1);
}
}
function down() {
if (current < pagesCount - 1) {
animate(current + 1);
}
}
$(document).on("mousewheel DOMMouseScroll", function (e) {
if (animating) return;
if (e.originalEvent.wheelDelta > 0 || e.originalEvent.detail < 0) {
vectorPage = 'top';
up();
} else {
vectorPage = 'bot';
down();
}
});
});
$(document).ready();
var cur = 1;
var next;
var animating = false;
var pagesCount = $pages = $('.pt-page').length;
$(document).on("mousewheel DOMMouseScroll", function(e) {
if (animating) return;
animating = true;
if (e.originalEvent.wheelDelta > 0 || e.originalEvent.detail < 0) {
//up
next = cur - 1;
next = Math.max(Math.min(next, pagesCount), 1);
if (next != cur) {
console.log(cur);
$('.pt-page').removeClass('pt-page-current');
$('.pt-page-' + cur).addClass('pt-page-current').addClass('blurA');
$('.pt-page-' + cur).removeClass('pt-page-ontop').removeClass('pt-page-moveFromTop').removeClass('pt-page-moveFromBottom');
$('.pt-page-' + next).removeClass('blurA');
$('.pt-page-' + next).addClass('pt-page-current').addClass('pt-page-ontop').addClass('pt-page-moveFromTop');
cur--;
}
} else {
//down
next = cur + 1;
next = Math.max(Math.min(next, pagesCount), 1);
if (next != cur) {
console.log(cur);
$('.pt-page').removeClass('pt-page-current');
$('.pt-page-' + cur).addClass('pt-page-current').addClass('blurA');
$('.pt-page-' + cur).removeClass('pt-page-ontop').removeClass('pt-page-moveFromTop').removeClass('pt-page-moveFromBottom');
$('.pt-page-' + next).removeClass('blurA');
$('.pt-page-' + next).addClass('pt-page-current').addClass('pt-page-ontop').addClass('pt-page-moveFromBottom');
cur++;
}
}
setTimeout(function () {
animating = false;
}, 1800);
});
$(document).ready();