Swipeout is an extension of list view that allows you to swipe over list elements to reveal hidden menu with available actions, like swipe-to-delete.
Let's look on layout structure of swipeout element in your list views:
<divclass="list-block"><ul><!-- Additional "swipeout" class on li --><liclass="swipeout"><!-- Usual list element wrapped with "swipeout-content" --><divclass="swipeout-content"><!-- Your list element here --><divclass="item-content"><divclass="item-media">...</div><divclass="item-inner">...</div></div></div><!-- Swipeout actions left --><divclass="swipeout-actions-left"><!-- Swipeout actions links/buttons --><ahref="#">Action 1</a><ahref="#">Action 2</a></div><!-- Swipeout actions right --><divclass="swipeout-actions-right"><!-- Swipeout actions links/buttons --><ahref="#">Action 1</a><aclass="swipeout-close"href="#">Action 2</a></div></li>
...
</ul></div>
Where:
swipeout-content - wrapper for your list element. This container will move during swipe over the list item
swipeout-actions-left - container with left swipeout action buttons/links
swipeout-actions-right - container with right swipeout action buttons/links
swipeout-close - additional class on swipeout link that will close swipeout element when you click this link
Close And Delete
Add .swipeout-close to action link to close swipeout.
Add .swipeout-delete to action link to close swipeout. You can also add data-confirm="confirm message" and data-confirm-title="confirm title" to show a confirm dialog when user click the delete button.
<liclass="swipeout"><divclass="swipeout-content"><divclass="item-content"><divclass="item-inner"><divclass="item-title">Swipe me left!</div><divclass="item-after">666</div></div></div></div><divclass="swipeout-actions-right"><aclass="bg-success">Action 1</a><!-- close --><aclass="swipeout-close"href="#">Close</a></div></li><liclass="swipeout"><divclass="swipeout-content"><divclass="item-content"><divclass="item-inner"><divclass="item-title">Remove me after confirm!</div></div></div></div><divclass="swipeout-actions-right"><!-- delete with confirm --><aclass="bg-danger swipeout-delete"href="#"data-confirm="Are you sure want to delete me?"data-confirm-title="Confirm Delete">Delete</a><ahref="#">Action 2</a></div></li>
JavaScript
Swipeouts also has rich JavaScript API that allows you to control swipeout elements. Let's look on appropriate App's properties and methods:
$.swipeoutOpen(el, direction, callback) - reveal swipeout actions on specified element
el - HTMLElement or string (with CSS Selector) of list (<li>) element with "swipeout" class. Required
direction - string (could be "left" or "right") swipeout actions to open. Should be specified if item has both left and right swipeout actions. Optional
callback - function - callback function will be executed after swipeout element completes its opening animation
$.swipeoutClose(el, callback) - close swipeout actions on specified element
el - HTMLElement or string (with CSS Selector) of list (<li>) element with "swipeout" class. Required
callback - function - callback function will be executed after swipeout element completes its closing animation
$.swipeoutDelete(el, callback) - delete specified swipeout element
el - HTMLElement or string (with CSS Selector) of list (<li>) element with "swipeout" class. Required
callback - function - callback function will be executed after swipeout element completes its delete animation right before it will be removed from DOM
Swipeout Events
Swipeout elements have the following events:
Event
Target
Description
swipeout
Swipeout Element<li class="swipeout">
Event will be triggered while you move swipeout element. event.detail.progress contains current opened progress percentage
open
Swipeout Element<li class="swipeout">
Event will be triggered when swipeout element starts its opening animation
opened
Swipeout Element<li class="swipeout">
Event will be triggered after swipeout element completes its opening animation
close
Swipeout Element<li class="swipeout">
Event will be triggered when swipeout element starts its closing animation
closed
Swipeout Element<li class="swipeout">
Event will be triggered after swipeout element completes its closing animation
delete
Swipeout Element<li class="swipeout">
Event will be triggered after swipeout element starts its delete animation
deleted
Swipeout Element<li class="swipeout">
Event will be triggered after swipeout element completes its delete animation right before it will be removed from DOM
$('.swipeout').on('swipeout',function(e){console.log('Item opened on: '+e.detail.progress+'%');});
i18n
English is the default language of Light7. You can include i18n/cn.js after light7.js to change the language to Chinese:
<script src='js/i18n/cn.js'></script>
Right click the demo on right side to see how it's writen;
Note! The i18n only change the language of Light7's components. It can't change the language of your entire site.