2018-02-07 07:16:01 +01:00
|
|
|
<template>
|
2018-02-16 19:01:00 +01:00
|
|
|
<div class="mk-stream-indicator" v-if="stream">
|
|
|
|
<p v-if=" stream.state == 'initializing' ">
|
|
|
|
%fa:spinner .pulse%
|
|
|
|
<span>%i18n:common.tags.mk-stream-indicator.connecting%<mk-ellipsis/></span>
|
|
|
|
</p>
|
|
|
|
<p v-if=" stream.state == 'reconnecting' ">
|
|
|
|
%fa:spinner .pulse%
|
|
|
|
<span>%i18n:common.tags.mk-stream-indicator.reconnecting%<mk-ellipsis/></span>
|
|
|
|
</p>
|
|
|
|
<p v-if=" stream.state == 'connected' ">
|
|
|
|
%fa:check%
|
|
|
|
<span>%i18n:common.tags.mk-stream-indicator.connected%</span>
|
|
|
|
</p>
|
|
|
|
</div>
|
2018-02-07 07:16:01 +01:00
|
|
|
</template>
|
|
|
|
|
2018-02-16 19:01:00 +01:00
|
|
|
<script lang="ts">
|
|
|
|
import Vue from 'vue';
|
|
|
|
import * as anime from 'animejs';
|
2018-02-07 07:16:01 +01:00
|
|
|
|
2018-02-16 19:01:00 +01:00
|
|
|
export default Vue.extend({
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
stream: null
|
|
|
|
};
|
|
|
|
},
|
|
|
|
created() {
|
2018-02-18 04:35:18 +01:00
|
|
|
this.stream = (this as any).os.stream.borrow();
|
2018-02-16 19:01:00 +01:00
|
|
|
|
2018-02-18 04:35:18 +01:00
|
|
|
(this as any).os.stream.on('connected', this.onConnected);
|
|
|
|
(this as any).os.stream.on('disconnected', this.onDisconnected);
|
2018-02-16 19:01:00 +01:00
|
|
|
|
|
|
|
this.$nextTick(() => {
|
2018-02-07 07:16:01 +01:00
|
|
|
if (this.stream.state == 'connected') {
|
2018-02-16 19:01:00 +01:00
|
|
|
this.$el.style.opacity = '0';
|
2018-02-07 07:16:01 +01:00
|
|
|
}
|
2018-02-16 19:01:00 +01:00
|
|
|
});
|
|
|
|
},
|
|
|
|
beforeDestroy() {
|
2018-02-18 04:35:18 +01:00
|
|
|
(this as any).os.stream.off('connected', this.onConnected);
|
|
|
|
(this as any).os.stream.off('disconnected', this.onDisconnected);
|
2018-02-16 19:01:00 +01:00
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
onConnected() {
|
2018-02-18 04:35:18 +01:00
|
|
|
this.stream = (this as any).os.stream.borrow();
|
2018-02-07 07:16:01 +01:00
|
|
|
|
2018-02-16 19:01:00 +01:00
|
|
|
setTimeout(() => {
|
2018-02-07 07:16:01 +01:00
|
|
|
anime({
|
2018-02-16 19:01:00 +01:00
|
|
|
targets: this.$el,
|
|
|
|
opacity: 0,
|
2018-02-07 07:16:01 +01:00
|
|
|
easing: 'linear',
|
2018-02-16 19:01:00 +01:00
|
|
|
duration: 200
|
2018-02-07 07:16:01 +01:00
|
|
|
});
|
2018-02-16 19:01:00 +01:00
|
|
|
}, 1000);
|
|
|
|
},
|
|
|
|
onDisconnected() {
|
|
|
|
this.stream = null;
|
|
|
|
|
|
|
|
anime({
|
|
|
|
targets: this.$el,
|
|
|
|
opacity: 1,
|
|
|
|
easing: 'linear',
|
|
|
|
duration: 100
|
2018-02-07 07:16:01 +01:00
|
|
|
});
|
|
|
|
}
|
2018-02-16 19:01:00 +01:00
|
|
|
}
|
|
|
|
});
|
2018-02-07 07:16:01 +01:00
|
|
|
</script>
|
|
|
|
|
2018-02-07 10:30:17 +01:00
|
|
|
<style lang="stylus" scoped>
|
2018-02-16 19:01:00 +01:00
|
|
|
.mk-stream-indicator
|
|
|
|
pointer-events none
|
|
|
|
position fixed
|
|
|
|
z-index 16384
|
|
|
|
bottom 8px
|
|
|
|
right 8px
|
|
|
|
margin 0
|
|
|
|
padding 6px 12px
|
|
|
|
font-size 0.9em
|
|
|
|
color #fff
|
|
|
|
background rgba(0, 0, 0, 0.8)
|
|
|
|
border-radius 4px
|
|
|
|
|
|
|
|
> p
|
2018-02-07 07:16:01 +01:00
|
|
|
display block
|
|
|
|
margin 0
|
|
|
|
|
2018-02-16 19:01:00 +01:00
|
|
|
> [data-fa]
|
|
|
|
margin-right 0.25em
|
2018-02-07 07:16:01 +01:00
|
|
|
|
|
|
|
</style>
|