Make pages.meet carousel go next/prev on animation

This commit is contained in:
Niko 2022-02-14 15:43:22 +01:00
parent 70722428cd
commit eca4c3dba0
2 changed files with 21 additions and 7 deletions

View File

@ -28,6 +28,8 @@ app.carousel = {
elements[j].style = 'display: none';
next.removeAttribute('style');
mod._current = i;
if (mod._onSetEvent !== undefined)
mod._onSetEvent();
return true;
},
};

View File

@ -30,11 +30,7 @@ app.pages.meet = {
var tpl = app.template.get('meet.item_actions');
dom.innerHTML += tpl;
}; _();
// TODO: just for testing
app.pages.meet.carousel.set(2);
dragElement(app.pages.meet.carousel._elements()[app.pages.meet.carousel._current],
{y: false, return2start: true, rotate: true}, function(a1, a2) { console.log(a1); console.log(a2) });
app.pages.meet.carousel.set(0);
});
});
},
@ -47,8 +43,24 @@ app.pages.meet = {
_parent: function() { return document.querySelector('#page-meet #content') },
_elements: function() { return app.pages.meet.carousel._parent().querySelectorAll('.meet.item') },
_size: function() { return app.pages.meet.carousel._elements().length },
set: function(i) {
return app.carousel.set(app.pages.meet.carousel, i);
_onSetEvent: function() { app.pages.meet.carousel.setDragEvent() },
set: function(i) { return app.carousel.set(app.pages.meet.carousel, i) },
next: function() { return app.carousel.next(app.pages.meet.carousel) },
prev: function() { return app.carousel.prev(app.pages.meet.carousel) },
setDragEvent: function() {
const current = app.pages.meet.carousel._elements()[
app.pages.meet.carousel._current];
dragElement(current, { y: false, return2start: true }, function(a1, a2) {
const ix = a1[0];
const fx = a2[0];
if (ix > fx) {
if (ix - fx > 50)
app.pages.meet.carousel.next();
} else {
if (fx - ix > 50)
app.pages.meet.carousel.prev();
}
});
},
},
};