Swipeout - 图1

Swipeout React Component

Swipeout List is not a separate component, but just a particular case of using , React components and additional Swipeout components.

Swipeout React component represents Framework7’s Swipeout component.

Swipeout Components

There are following components included:

  • SwipeoutActions / F7SwipeoutActions - wrapper for swipeout buttons
  • SwipeoutButton / F7SwipeoutButton - single swipeout button

Swipeout Properties

PropTypeDefaultDescription
<SwipeoutActions> Properties
sidestringrightSwipeout actions side
rightbooleanShortcut for side=”right” prop
leftbooleanShortcut for side=”left” prop
<SwipeoutButton> Properties
deletebooleanfalseWill automatically delete swipeout list item on click
closebooleanfalseWill automatically close swipeout list item on click
overswipebooleanfalseWill be triggered click automatically if you swipe actions too much - overswipe
textstringSwipeout button text label
confirmTextstringThis text will be shown in dialog where user must agree before item delete
confirmTitlestringThis text will be shown as dialog title where user must agree before item delete

Swipeout Events

EventDescription
<SwipeoutButton> events
clickEvent will be triggered on swipeout button click
<ListItem> events
The following events will be available on <ListItem> with swipeout enabled
swipeoutEvent will be triggered while you move swipeout element. event.detail.progress contains current opened progress percentage
swipeoutOpenEvent will be triggered when swipeout element starts its opening animation
swipeoutOpenedEvent will be triggered after swipeout element completes its opening animation
swipeoutCloseEvent will be triggered when swipeout element starts its closing animation
swipeoutClosedEvent will be triggered after swipeout element completes its closing animation
swipeoutDeleteEvent will be triggered after swipeout element starts its delete animation
swipeoutDeletedEvent will be triggered after swipeout element completes its delete animation right before it will be removed from DOM
swipeoutOverswipeEnterEvent will be triggered when overswipe enabled
swipeoutOverswipeExitEvent will be triggered when overswipe disabled

Examples

  1. export default class extends React.Component {
  2. constructor(props) {
  3. super(props);
  4. }
  5. more() {
  6. const self = this;
  7. self.actions.open();
  8. }
  9. mark() {
  10. const app = this.$f7;
  11. app.dialog.alert('Mark');
  12. }
  13. reply() {
  14. const app = this.$f7;
  15. app.dialog.alert('Reply');
  16. }
  17. forward() {
  18. const app = this.$f7;
  19. app.dialog.alert('Forward');
  20. }
  21. onDeleted() {
  22. const app = this.$f7;
  23. app.dialog.alert('Thanks, item removed!');
  24. }
  25. onPageBeforeRemove() {
  26. const self = this;
  27. self.actions.destroy();
  28. }
  29. onPageInit() {
  30. const self = this;
  31. const app = self.$f7;
  32. self.actions = app.actions.create({
  33. buttons: [
  34. [
  35. {
  36. text: 'Here comes some optional description or warning for actions below',
  37. label: true,
  38. },
  39. {
  40. text: 'Action 1',
  41. },
  42. {
  43. text: 'Action 2',
  44. },
  45. ],
  46. [
  47. {
  48. text: 'Cancel',
  49. bold: true,
  50. },
  51. ],
  52. ],
  53. });
  54. }
  55. render () {
  56. return (
  57. <Page onPageBeforeRemove={this.onPageBeforeRemove.bind(this)} onPageInit={this.onPageInit.bind(this)}>
  58. <Navbar title="Swipeout"></Navbar>
  59. <Block>
  60. <p>
  61. Swipe out actions on list elements is one of the most awesome F7 features. It allows you to call hidden menu for each list element where you can put default ready-to use delete button or any other buttons for some required actions.
  62. </p>
  63. </Block>
  64. <BlockTitle>Swipe to delete with confirm modal</BlockTitle>
  65. <List>
  66. <ListItem
  67. swipeout
  68. title="Swipe left on me please">
  69. <SwipeoutActions right>
  70. <SwipeoutButton delete confirmText="Are you sure you want to delete this item?">Delete</SwipeoutButton>
  71. </SwipeoutActions>
  72. </ListItem>
  73. <ListItem
  74. swipeout
  75. title="Swipe left on me too">
  76. <SwipeoutActions right>
  77. <SwipeoutButton delete confirmText="Are you sure you want to delete this item?">Delete</SwipeoutButton>
  78. </SwipeoutActions>
  79. </ListItem>
  80. <ListItem
  81. title="I am not removable">
  82. </ListItem>
  83. </List>
  84. <BlockTitle>Swipe to delete without confirm</BlockTitle>
  85. <List>
  86. <ListItem
  87. swipeout
  88. title="Swipe left on me please">
  89. <SwipeoutActions right>
  90. <SwipeoutButton delete>Delete</SwipeoutButton>
  91. </SwipeoutActions>
  92. </ListItem>
  93. <ListItem
  94. swipeout
  95. title="Swipe left on me too">
  96. <SwipeoutActions right>
  97. <SwipeoutButton delete>Delete</SwipeoutButton>
  98. </SwipeoutActions>
  99. </ListItem>
  100. <ListItem
  101. title="I am not removable">
  102. </ListItem>
  103. </List>
  104. <BlockTitle>Swipe for actions</BlockTitle>
  105. <List>
  106. <ListItem
  107. swipeout
  108. title="Swipe left on me please">
  109. <SwipeoutActions right>
  110. <SwipeoutButton onClick={this.more.bind(this)}>More</SwipeoutButton>
  111. <SwipeoutButton delete>Delete</SwipeoutButton>
  112. </SwipeoutActions>
  113. </ListItem>
  114. <ListItem
  115. swipeout
  116. title="Swipe left on me too">
  117. <SwipeoutActions right>
  118. <SwipeoutButton onClick={this.more.bind(this)}>More</SwipeoutButton>
  119. <SwipeoutButton delete>Delete</SwipeoutButton>
  120. </SwipeoutActions>
  121. </ListItem>
  122. <ListItem
  123. swipeout
  124. title="You can't delete me">
  125. <SwipeoutActions right>
  126. <SwipeoutButton onClick={this.more.bind(this)}>More</SwipeoutButton>
  127. </SwipeoutActions>
  128. </ListItem>
  129. </List>
  130. <BlockTitle>With callback on remove</BlockTitle>
  131. <List>
  132. <ListItem
  133. swipeout
  134. onSwipeoutDeleted={this.onDeleted.bind(this)}
  135. title="Swipe left on me please">
  136. <SwipeoutActions right>
  137. <SwipeoutButton delete>Delete</SwipeoutButton>
  138. </SwipeoutActions>
  139. </ListItem>
  140. <ListItem
  141. swipeout
  142. onSwipeoutDeleted={this.onDeleted.bind(this)}
  143. title="Swipe left on me too">
  144. <SwipeoutActions right>
  145. <SwipeoutButton delete>Delete</SwipeoutButton>
  146. </SwipeoutActions>
  147. </ListItem>
  148. <ListItem
  149. title="I am not removable">
  150. </ListItem>
  151. </List>
  152. <BlockTitle>With actions on left side (swipe to right)</BlockTitle>
  153. <List>
  154. <ListItem
  155. swipeout
  156. title="Swipe right on me please">
  157. <SwipeoutActions left>
  158. <SwipeoutButton color="green" onClick={this.reply.bind(this)}>Reply</SwipeoutButton>
  159. <SwipeoutButton color="blue" onClick={this.forward.bind(this)}>Forward</SwipeoutButton>
  160. </SwipeoutActions>
  161. </ListItem>
  162. <ListItem
  163. swipeout
  164. title="Swipe right on me too">
  165. <SwipeoutActions left>
  166. <SwipeoutButton color="green" onClick={this.reply.bind(this)}>Reply</SwipeoutButton>
  167. <SwipeoutButton color="blue" onClick={this.forward.bind(this)}>Forward</SwipeoutButton>
  168. </SwipeoutActions>
  169. </ListItem>
  170. </List>
  171. <BlockTitle>On both sides with overswipes</BlockTitle>
  172. <List mediaList>
  173. <ListItem
  174. swipeout
  175. title="Facebook"
  176. after="17:14"
  177. subtitle="New messages from John Doe"
  178. text="Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla sagittis tellus ut turpis condimentum, ut dignissim lacus tincidunt. Cras dolor metus, ultrices condimentum sodales sit amet, pharetra sodales eros. Phasellus vel felis tellus. Mauris rutrum ligula nec dapibus feugiat. In vel dui laoreet, commodo augue id, pulvinar lacus."
  179. >
  180. <SwipeoutActions left>
  181. <SwipeoutButton overswipe color="green" onClick={this.reply.bind(this)}>Reply</SwipeoutButton>
  182. <SwipeoutButton color="blue" onClick={this.forward.bind(this)}>Forward</SwipeoutButton>
  183. </SwipeoutActions>
  184. <SwipeoutActions right>
  185. <SwipeoutButton onClick={this.more.bind(this)}>More</SwipeoutButton>
  186. <SwipeoutButton color="orange" onClick={this.mark.bind(this)}>Mark</SwipeoutButton>
  187. <SwipeoutButton delete overswipe confirmText="Are you sure you want to delete this item?">Delete</SwipeoutButton>
  188. </SwipeoutActions>
  189. </ListItem>
  190. <ListItem
  191. swipeout
  192. title="John Doe (via Twitter)"
  193. after="17:11"
  194. subtitle="John Doe (@_johndoe) mentioned you on Twitter!"
  195. text="Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla sagittis tellus ut turpis condimentum, ut dignissim lacus tincidunt. Cras dolor metus, ultrices condimentum sodales sit amet, pharetra sodales eros. Phasellus vel felis tellus. Mauris rutrum ligula nec dapibus feugiat. In vel dui laoreet, commodo augue id, pulvinar lacus."
  196. >
  197. <SwipeoutActions left>
  198. <SwipeoutButton overswipe color="green" onClick={this.reply.bind(this)}>Reply</SwipeoutButton>
  199. <SwipeoutButton color="blue" onClick={this.forward.bind(this)}>Forward</SwipeoutButton>
  200. </SwipeoutActions>
  201. <SwipeoutActions right>
  202. <SwipeoutButton onClick={this.more.bind(this)}>More</SwipeoutButton>
  203. <SwipeoutButton color="orange" onClick={this.mark.bind(this)}>Mark</SwipeoutButton>
  204. <SwipeoutButton delete overswipe confirmText="Are you sure you want to delete this item?">Delete</SwipeoutButton>
  205. </SwipeoutActions>
  206. </ListItem>
  207. <ListItem
  208. swipeout
  209. title="Facebook"
  210. after="16:48"
  211. subtitle="New messages from John Doe"
  212. text="Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla sagittis tellus ut turpis condimentum, ut dignissim lacus tincidunt. Cras dolor metus, ultrices condimentum sodales sit amet, pharetra sodales eros. Phasellus vel felis tellus. Mauris rutrum ligula nec dapibus feugiat. In vel dui laoreet, commodo augue id, pulvinar lacus."
  213. >
  214. <SwipeoutActions left>
  215. <SwipeoutButton overswipe color="green" onClick={this.reply.bind(this)}>Reply</SwipeoutButton>
  216. <SwipeoutButton color="blue" onClick={this.forward.bind(this)}>Forward</SwipeoutButton>
  217. </SwipeoutActions>
  218. <SwipeoutActions right>
  219. <SwipeoutButton onClick={this.more.bind(this)}>More</SwipeoutButton>
  220. <SwipeoutButton color="orange" onClick={this.mark.bind(this)}>Mark</SwipeoutButton>
  221. <SwipeoutButton delete overswipe confirmText="Are you sure you want to delete this item?">Delete</SwipeoutButton>
  222. </SwipeoutActions>
  223. </ListItem>
  224. <ListItem
  225. swipeout
  226. title="John Doe (via Twitter)"
  227. after="15:32"
  228. subtitle="John Doe (@_johndoe) mentioned you on Twitter!"
  229. text="Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla sagittis tellus ut turpis condimentum, ut dignissim lacus tincidunt. Cras dolor metus, ultrices condimentum sodales sit amet, pharetra sodales eros. Phasellus vel felis tellus. Mauris rutrum ligula nec dapibus feugiat. In vel dui laoreet, commodo augue id, pulvinar lacus."
  230. >
  231. <SwipeoutActions left>
  232. <SwipeoutButton overswipe color="green" onClick={this.reply.bind(this)}>Reply</SwipeoutButton>
  233. <SwipeoutButton color="blue" onClick={this.forward.bind(this)}>Forward</SwipeoutButton>
  234. </SwipeoutActions>
  235. <SwipeoutActions right>
  236. <SwipeoutButton onClick={this.more.bind(this)}>More</SwipeoutButton>
  237. <SwipeoutButton color="orange" onClick={this.mark.bind(this)}>Mark</SwipeoutButton>
  238. <SwipeoutButton delete overswipe confirmText="Are you sure you want to delete this item?">Delete</SwipeoutButton>
  239. </SwipeoutActions>
  240. </ListItem>
  241. </List>
  242. </Page>
  243. );
  244. }
  245. };

← Subnavbar

Swiper →