Skip to content

Commit 0f4e592

Browse files
committed
Phenome ListItem: open swipeout by prop
1 parent 7536f72 commit 0f4e592

1 file changed

Lines changed: 24 additions & 7 deletions

File tree

src/phenome/components/list-item.jsx

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ export default {
3131
divider: Boolean,
3232
groupTitle: Boolean,
3333
swipeout: Boolean,
34+
swipeoutOpened: Boolean,
3435
sortable: Boolean,
3536
accordionItem: Boolean,
3637
accordionItemOpened: Boolean,
@@ -240,6 +241,18 @@ export default {
240241
</li>
241242
);
242243
},
244+
watch: {
245+
'props.swipeoutOpened': function watchSwipeoutOpened(opened) {
246+
const self = this;
247+
if (!self.props.swipeout) return;
248+
const el = self.refs.el;
249+
if (opened) {
250+
self.$f7.swipeout.open(el);
251+
} else {
252+
self.$f7.swipeout.close(el);
253+
}
254+
},
255+
},
243256
componentDidCreate() {
244257
const self = this;
245258
self.onClickBound = self.onClick.bind(self);
@@ -269,7 +282,7 @@ export default {
269282
isSortable: self.$listEl.hasClass('sortable'),
270283
});
271284
}
272-
const { swipeout, accordionItem, smartSelect, smartSelectParams } = self.props;
285+
const { swipeout, swipeoutOpened, accordionItem, smartSelect, smartSelectParams } = self.props;
273286
if (swipeout) {
274287
el.addEventListener('swipeout:open', self.onSwipeoutOpenBound);
275288
el.addEventListener('swipeout:opened', self.onSwipeoutOpenedBound);
@@ -286,13 +299,17 @@ export default {
286299
el.addEventListener('accordion:closed', self.onAccClosedBound);
287300
}
288301

289-
if (!smartSelect) return;
290302
self.$f7ready((f7) => {
291-
const ssParams = Utils.extend(
292-
{ el: el.querySelector('a.smart-select') },
293-
smartSelectParams || {},
294-
);
295-
self.f7SmartSelect = f7.smartSelect.create(ssParams);
303+
if (smartSelect) {
304+
const ssParams = Utils.extend(
305+
{ el: el.querySelector('a.smart-select') },
306+
smartSelectParams || {},
307+
);
308+
self.f7SmartSelect = f7.smartSelect.create(ssParams);
309+
}
310+
if (swipeoutOpened) {
311+
f7.swipeout.open(el);
312+
}
296313
});
297314
},
298315
componentDidUpdate() {

0 commit comments

Comments
 (0)