js added to animate div on copy
This commit is contained in:
parent
e8328a86db
commit
070543f7c2
|
@ -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;
|
||||
|
@ -19,8 +25,15 @@ Vue.component('copbox',{
|
|||
window.getSelection().removeAllRanges();
|
||||
window.getSelection().addRange(range);
|
||||
document.execCommand('copy');
|
||||
window.getSelection().removeAllRanges();
|
||||
window.getSelection().removeAllRanges();
|
||||
this.successOk();
|
||||
},
|
||||
successOk(){
|
||||
this.isSuccess = true;
|
||||
this.$refs.element.addEventListener('animationend', () => {
|
||||
this.isFaded = false;
|
||||
});
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
|
|
Loading…
Reference in New Issue