Sortable - 图1

Sortable Svelte Component

Sortable is not a separate component, but just a particular case of using and components.

Sortable Events

EventDescription
<List> events
The following events will be available on <List> when sortable prop enabled
sortableEnableEvent will be triggered when sortable mode is enabled
sortableDisableEvent will be triggered when sortable mode is disabled
sortableSortEvent will be triggered after user release currently sorting element in new position. First handler argument contains object with from, to and el properties with start/new index numbers of sorted list item and the HTML element of sorted list item

Examples

  1. <Page>
  2. <Navbar title="Sortable List">
  3. <NavRight>
  4. <Link sortableToggle=".sortable">Toggle</Link>
  5. </NavRight>
  6. </Navbar>
  7. <Block>
  8. <p>Just click "Toggle" button on navigation bar to enable/disable sorting</p>
  9. </Block>
  10. <List sortable>
  11. <ListItem
  12. title="1 Jenna Smith"
  13. after="CEO"
  14. >
  15. <i class="icon demo-list-icon" slot="media" />
  16. </ListItem>
  17. <ListItem
  18. title="2 John Doe"
  19. after="Director"
  20. >
  21. <i class="icon demo-list-icon" slot="media" />
  22. </ListItem>
  23. <ListItem
  24. title="3 John Doe"
  25. after="Developer"
  26. >
  27. <i class="icon demo-list-icon" slot="media" />
  28. </ListItem>
  29. <ListItem
  30. title="4 Aaron Darling"
  31. after="Manager"
  32. >
  33. <i class="icon demo-list-icon" slot="media" />
  34. </ListItem>
  35. <ListItem
  36. title="5 Calvin Johnson"
  37. after="Accounter"
  38. >
  39. <i class="icon demo-list-icon" slot="media" />
  40. </ListItem>
  41. <ListItem
  42. title="6 John Smith"
  43. after="SEO"
  44. >
  45. <i class="icon demo-list-icon" slot="media" />
  46. </ListItem>
  47. <ListItem
  48. title="7 Chloe"
  49. after="Manager"
  50. >
  51. <i class="icon demo-list-icon" slot="media" />
  52. </ListItem>
  53. </List>
  54. <List mediaList sortable>
  55. <ListItem
  56. title="Yellow Submarine"
  57. after="$15"
  58. subtitle="Beatles"
  59. 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."
  60. >
  61. <img slot="media" src="https://cdn.framework7.io/placeholder/people-160x160-1.jpg" width="80" />
  62. </ListItem>
  63. <ListItem
  64. title="Don't Stop Me Now"
  65. after="$22"
  66. subtitle="Queen"
  67. 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."
  68. >
  69. <img slot="media" src="https://cdn.framework7.io/placeholder/people-160x160-2.jpg" width="80" />
  70. </ListItem>
  71. <ListItem
  72. title="Billie Jean"
  73. after="$16"
  74. subtitle="Michael Jackson"
  75. 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."
  76. >
  77. <img slot="media" src="https://cdn.framework7.io/placeholder/people-160x160-3.jpg" width="80" />
  78. </ListItem>
  79. </List>
  80. <BlockTitle>Opposite Side</BlockTitle>
  81. <List sortable sortableOpposite>
  82. <ListItem
  83. title="1 Jenna Smith"
  84. after="CEO"
  85. >
  86. <i class="icon demo-list-icon" slot="media" />
  87. </ListItem>
  88. <ListItem
  89. title="2 John Doe"
  90. after="Director"
  91. >
  92. <i class="icon demo-list-icon" slot="media" />
  93. </ListItem>
  94. <ListItem
  95. title="3 John Doe"
  96. after="Developer"
  97. >
  98. <i class="icon demo-list-icon" slot="media" />
  99. </ListItem>
  100. <ListItem
  101. title="4 Aaron Darling"
  102. after="Manager"
  103. >
  104. <i class="icon demo-list-icon" slot="media" />
  105. </ListItem>
  106. <ListItem
  107. title="5 Calvin Johnson"
  108. after="Accounter"
  109. >
  110. <i class="icon demo-list-icon" slot="media" />
  111. </ListItem>
  112. <ListItem
  113. title="6 John Smith"
  114. after="SEO"
  115. >
  116. <i class="icon demo-list-icon" slot="media" />
  117. </ListItem>
  118. <ListItem
  119. title="7 Chloe"
  120. after="Manager"
  121. >
  122. <i class="icon demo-list-icon" slot="media" />
  123. </ListItem>
  124. </List>
  125. </Page>
  126. <style>
  127. :global(.demo-list-icon, .icon-f7) {
  128. background: #ccc;
  129. display: block;
  130. position: relative;
  131. }
  132. :global(.ios .demo-list-icon, .ios .icon-f7, .ios .icon-vi) {
  133. width: 29px;
  134. height: 29px;
  135. border-radius: 6px;
  136. box-sizing: border-box;
  137. }
  138. :global(.md .demo-list-icon, .md .icon-f7, .md .icon-vi) {
  139. width: 24px;
  140. height: 24px;
  141. border-radius: 4px;
  142. }
  143. :global(.aurora .demo-list-icon, .aurora .icon-f7, .aurora .icon-vi) {
  144. width: 18px;
  145. height: 18px;
  146. border-radius: 4px;
  147. }
  148. </style>
  149. <script>
  150. import {Page, Navbar, NavRight, Link, Block, List, ListItem, Icon, BlockTitle} from 'framework7-svelte';
  151. </script>

← Smart Select

Stepper →