diff --git a/web/src/app/js/carousel.js b/web/src/app/js/carousel.js index 8369db2..b2d8eab 100644 --- a/web/src/app/js/carousel.js +++ b/web/src/app/js/carousel.js @@ -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; }, }; diff --git a/web/src/app/js/pages/meet.js b/web/src/app/js/pages/meet.js index d084686..88a8d86 100644 --- a/web/src/app/js/pages/meet.js +++ b/web/src/app/js/pages/meet.js @@ -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(); + } + }); }, }, };