Skip to content
This repository was archived by the owner on Mar 9, 2023. It is now read-only.

Commit c6ef1a7

Browse files
committed
Use transition to animate, use button as dropdown items
1 parent 3170d32 commit c6ef1a7

File tree

1 file changed

+22
-32
lines changed

1 file changed

+22
-32
lines changed

src/Pivot.vue

Lines changed: 22 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -70,16 +70,18 @@
7070
<slot name="loading"></slot>
7171
</template>
7272
</pivot-table>
73-
<div ref="pivot-copied-alert" class="alert alert-secondary pivot-alert hide" @click="hideCopiedAlert">
74-
Copied to clipboard
75-
</div>
73+
<transition name="copied-alert">
74+
<div v-if="showCopiedAlert" class="alert alert-secondary pivot-copied-alert">
75+
Copied to clipboard
76+
</div>
77+
</transition>
7678
</div>
7779

7880
<div v-if="showSettings" class="table-option-button circle-background bg-primary dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" v-b-tooltip:hover title="Show menu"></div>
7981
<div class="dropdown-menu" aria-labelledby="dropdownMenuButton">
80-
<a ref="pivot-copy-button" class="dropdown-item" href="#">Copy table to clipboard</a>
81-
<a class="dropdown-item" href="#!" @click="_clickedSaveButton('csv')">Save table in CSV</a>
82-
<a class="dropdown-item" href="#!" @click="_clickedSaveButton('tsv')">Save table in TSV</a>
82+
<button ref="pivot-copy-button" class="dropdown-item" >Copy table to clipboard</button>
83+
<button class="dropdown-item" @click="_clickedSaveButton('csv')">Save table in CSV</button>
84+
<button class="dropdown-item" @click="_clickedSaveButton('tsv')">Save table in TSV</button>
8385
</div>
8486
</div>
8587
</div>
@@ -166,7 +168,8 @@ export default {
166168
colFields: this.fields.colFields,
167169
fieldsOrder: this.fields.fieldsOrder
168170
},
169-
dragging: false
171+
dragging: false,
172+
showCopiedAlert: false
170173
}
171174
},
172175
created () {
@@ -255,20 +258,9 @@ export default {
255258
}
256259
this._sortFields(this.internal.fieldsOrder)
257260
},
258-
onPivotTableCopied (e) {
259-
this.showCopiedAlert()
260-
setTimeout(this.startHideCopiedAlert, 500)
261-
},
262-
showCopiedAlert () {
263-
this.$refs['pivot-copied-alert'].classList.remove('hide')
264-
},
265-
startHideCopiedAlert () {
266-
this.$refs['pivot-copied-alert'].classList.add('hiding')
267-
setTimeout(this.hideCopiedAlert, 1000)
268-
},
269-
hideCopiedAlert () {
270-
this.$refs['pivot-copied-alert'].classList.remove('hiding')
271-
this.$refs['pivot-copied-alert'].classList.add('hide')
261+
onPivotTableCopied () {
262+
this.showCopiedAlert = true
263+
setTimeout(() => { this.showCopiedAlert = false }, 700)
272264
}
273265
}
274266
}
@@ -413,19 +405,17 @@ $hamburger-svg: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/
413405
left: $base-space*3 + 10rem - $border-space*3;
414406
}
415407
416-
.pivot-alert {
408+
.pivot-copied-alert {
417409
position: absolute;
418410
bottom: 1rem;
419411
right: 1rem;
420-
opacity: 0.8;
421-
visibility: vislble;
422-
transition: opacity 1s ease-in-out;
423-
&.hiding {
424-
opacity: 0;
425-
visibility: visible;
426-
}
427-
&.hide {
428-
visibility: hidden;
429-
}
412+
}
413+
414+
.copied-alert-enter-active {
415+
opacity: 0.6;
416+
}
417+
.copied-alert-leave-active {
418+
opacity: 0;
419+
transition: all 0.7s ease;
430420
}
431421
</style>

0 commit comments

Comments
 (0)