').text(post.selftext); li.append(title, body, comments); post.type = 'text'; } const removeLink = $('
').html(``); li.append(removeLink); li.addClass('swipe-delete'); list.append(li); }); }); } $(document).ready(function() { // Initial page load getPosts(); // Use Hammer.js to detect swipe gestures const swipeDelete = new Hammer(document.getElementById('reddit-posts'), { recognizers: [[Hammer.Swipe, { direction: Hammer.DIRECTION_HORIZONTAL }]] }); // Handle tile clicks $('.tile').on('click', function() { const mode = $(this).data('mode'); selectTile(this, this.parentNode); if (mode === 'custom') { editCustomOption(); } else { getPosts(); } }); swipeDelete.on('swipeleft', function(ev) { const target = $(ev.target); if (target.hasClass('swipe-delete')) { target.addClass('swipe-delete-animation'); // Add animation class target.on('transitionend', function() { target.remove(); // Remove the element after the animation is complete }); } }); });