Skip to content
This repository has been archived by the owner on Jul 12, 2020. It is now read-only.

Cache panel contents after first load #105

Merged
merged 1 commit into from
May 27, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 12 additions & 17 deletions src/Panel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
</slot>
</div>
</div>
<template v-if="preloadBool">
<template v-if="preloadBool || isCached">
<div class="card-collapse"
ref="panel"
v-show="localExpanded"
Expand All @@ -57,21 +57,6 @@
<hr v-show="isSeamless" />
</div>
</template>
<template v-else>
<div class="card-collapse"
ref="panel"
v-if="localExpanded"
>
<div class="card-body">
<slot></slot>
<retriever v-if="hasSrc" ref="retriever" :src="src" :fragment="fragment" delay></retriever>
<panel-switch v-show="isExpandableCard && bottomSwitchBool" :is-open="localExpanded"
@click.native.stop.prevent="collapseThenScrollIntoViewIfNeeded()"
@is-open-event="retrieveOnOpen"></panel-switch>
</div>
<hr v-show="isSeamless" />
</div>
</template>
</div>
</span>
</template>
Expand Down Expand Up @@ -229,7 +214,8 @@
return {
onHeaderHover: false,
localExpanded: false,
localMinimized: false
localMinimized: false,
isCached: false
}
},
methods: {
Expand Down Expand Up @@ -270,6 +256,15 @@
},
watch: {
'localExpanded': function (val, oldVal) {
if (this.isCached) {
return;
}
/* When either one of the values is true,
* it means that the data is/will be cached.
*/
if (val || oldVal) {
this.isCached = true;
}
this.$nextTick(function () {
this.retrieveOnOpen(this, val);
})
Expand Down