File tree Expand file tree Collapse file tree 3 files changed +61
-11
lines changed
docs/app/pages/Components/List/examples
src/components/MdList/MdListItem Expand file tree Collapse file tree 3 files changed +61
-11
lines changed Original file line number Diff line number Diff line change 11<template >
22 <div class =" full-control" >
33 <md-list >
4- <md-list-item md-expand >
4+ <md-list-item md-expand :md-expanded.sync = " expandNews " >
55 <md-icon >whatshot</md-icon >
66 <span class =" md-list-item-text" >News</span >
77
4040 <span class =" md-list-item-text" >Shop</span >
4141 </md-list-item >
4242 </md-list >
43+ <md-checkbox v-model =" expandNews" >Expand News</md-checkbox >
4344 </div >
4445</template >
4546
4647<script >
4748 export default {
48- name: ' ListExpansion'
49+ name: ' ListExpansion' ,
50+
51+ data () {
52+ return {
53+ expandNews: false
54+ }
55+ }
4956 }
5057 </script >
5158
Original file line number Diff line number Diff line change 6565 createElement (listComponent, {
6666 props,
6767 scopedSlots: resolveScopedSlot (props, children),
68- staticClass: ' md-list-item-container md-button-clean'
68+ staticClass: ' md-list-item-container md-button-clean' ,
69+ on: listeners,
6970 }, children .default )
7071 ])
7172 }
Original file line number Diff line number Diff line change 2727 expandStyles: {},
2828 showContent: false
2929 }),
30+ props: {
31+ mdExpanded: Boolean
32+ },
3033 computed: {
3134 expandClasses () {
3235 return {
4548
4649 return size
4750 },
48- toggleExpand () {
49- raf (() => {
50- let fullHeight = 0
51+ fetchStyle () {
52+ return new Promise (resolve => {
53+ raf (() => {
54+ let fullHeight = 0
5155
52- if (! this .showContent ) {
53- fullHeight = ' auto' // this.getChildrenSize() + 'px'
54- }
56+ if (! this .showContent ) {
57+ fullHeight = ' auto' // this.getChildrenSize() + 'px'
58+ }
5559
56- this .expandStyles = { height: fullHeight }
57- this .showContent = ! this .showContent
60+ this .expandStyles = { height: fullHeight }
61+ resolve ()
62+ })
5863 })
64+ },
65+ async toggleExpand () {
66+ await this .fetchStyle ()
67+ this .showContent = ! this .showContent
68+ },
69+ async open () {
70+ if (this .showContent ) {
71+ return false
72+ }
73+
74+ await this .fetchStyle ()
75+ this .showContent = true
76+ },
77+ async close () {
78+ if (! this .showContent ) {
79+ return false
80+ }
81+
82+ await this .fetchStyle ()
83+ this .showContent = false
84+ }
85+ },
86+ watch: {
87+ mdExpanded () {
88+ if (this .mdExpanded ) {
89+ this .open ()
90+ } else {
91+ this .close ()
92+ }
93+ },
94+ showContent () {
95+ this .$emit (' update:mdExpanded' , this .showContent )
96+ }
97+ },
98+ mounted () {
99+ if (this .mdExpanded ) {
100+ this .open ()
59101 }
60102 }
61103 }
You can’t perform that action at this time.
0 commit comments