js added to animate div on copy

This commit is contained in:
edbrz9 2022-12-30 19:10:09 +01:00
parent e8328a86db
commit 070543f7c2
1 changed files with 15 additions and 2 deletions

View File

@ -1,16 +1,22 @@
Vue.component('copbox',{
template : `
<div class="y2t-output">
<div class="copied" v-bind:class="{ 'success': isSuccess}" ref="element"></div>
<div class="top" v-on:click="copyToClipboard">
<span class="copylabel">Copy to clipboard</span><span class="byl-icon-copy"></span>
</div>
<div ref="textToCopy">
<div ref="textToCopy" class="promptext">
<slot></slot>
</div>
<div class="shader"></div>
</div>
`,
data() {
return {
isSuccess: false
}
},
methods : {
copyToClipboard() {
const textToCopy = this.$refs.textToCopy;
@ -20,7 +26,14 @@ Vue.component('copbox',{
window.getSelection().addRange(range);
document.execCommand('copy');
window.getSelection().removeAllRanges();
this.successOk();
},
successOk(){
this.isSuccess = true;
this.$refs.element.addEventListener('animationend', () => {
this.isFaded = false;
});
}
}
})