started sliding cod

main
psychobunny 10 years ago
parent 8392838bd2
commit 995504e364

@ -122,9 +122,49 @@ $(document).ready(function() {
function setupPaginator() { function setupPaginator() {
function appendPageNumber(ev, data) { function appendPageNumber(ev, data) {
var el = data.after ? data.after : data.before, var el = data.after ? data.after : data.before,
page = Math.ceil((el.attr('data-index') - 1) / config.postsPerPage); page = Math.ceil((el.attr('data-index') - 1) / config.postsPerPage),
handle = $('<div class="page-number pointer">' + page + '</div>');
el.append(handle);
handle.tooltip({
title: 'Slide to paginate',
placement: 'left'
});
var dragging = false, originalY = 0;
handle.on('mousedown', function(ev) {
dragging = true;
originalY = ev.screenY;
});
$('body').on('mouseup', function() {
dragging = false;
//handle.css('margin-top', '0px');
});
$('body').on('mousemove', function(ev) {
if (!dragging) {
return;
}
//handle.css('margin-top', (originalY - ev.screenY) + 'px');
var distance = originalY - ev.screenY,
toPage = page - parseInt(distance / 50, 10);
if (toPage > ajaxify.data.pageCount) {
toPage = ajaxify.data.pageCount;
}
if (toPage < 0) {
toPage = 0;
}
handle.html(toPage);
});
el.append('<div class="page-number">' + page + '</div>');
} }
$(window).on('action:posts.loading', appendPageNumber); $(window).on('action:posts.loading', appendPageNumber);

@ -11,5 +11,7 @@
border-radius: 50%; border-radius: 50%;
color: white; color: white;
font-size: 11px; font-size: 11px;
.user-select(none);
} }
} }
Loading…
Cancel
Save