15
15
</template >
16
16
17
17
<script lang="ts">
18
- import { ITourBroadcast , ITourBroadcastStepChanged , TourStepIndex , IWalletHTMLElements } from ' @/lib/tour' ;
19
- import { defineComponent , onMounted , onUnmounted , Ref , ref } from ' @vue/composition-api' ;
18
+ import { ITourBroadcast , ITourBroadcastStepChanged , TourStepIndex } from ' @/lib/tour' ;
19
+ import { defineComponent , onMounted , Ref , ref } from ' @vue/composition-api' ;
20
20
21
21
export default defineComponent ({
22
22
name: ' tour-large-screen-manager' ,
@@ -36,72 +36,15 @@ export default defineComponent({
36
36
37
37
onMounted (async () => {
38
38
show .value = true ;
39
- setTimeout (() => _checkIfModalIsOpen (), 2000 );
40
39
});
41
40
42
- onUnmounted (() => _removeClonedManager ());
43
-
44
41
async function _stepChanged(
45
42
{ nSteps : newNSteps , currentStep : newCurrentStep }: ITourBroadcastStepChanged [' payload' ]) {
46
43
nSteps .value = newNSteps ;
47
44
currentStep .value = newCurrentStep ;
48
-
49
- await context .root .$nextTick ();
50
-
51
- _checkIfModalIsOpen ();
52
- }
53
-
54
- function _checkIfModalIsOpen() {
55
- const modalIsOpen = document .querySelector (IWalletHTMLElements .MODAL_CONTAINER ) !== null ;
56
- if (modalIsOpen ) {
57
- _duplicateManager ();
58
- } else {
59
- _removeClonedManager ();
60
- }
61
- }
62
-
63
- // remove the cloned manager if it exists due to a modal not being open anymore
64
- // see _duplicateManager()
65
- function _removeClonedManager() {
66
- const tourManager = document .querySelector (' body > .tour-manager' );
67
- if (tourManager ) {
68
- tourManager .remove ();
69
- }
70
- const original = $originalManager .value ! ;
71
- if (! original ) return ;
72
- original .style .visibility = ' initial' ;
73
- }
74
-
75
- // at some steps, a modal will be openened in the tour and we still need to show the tour
76
- // manager to the user, therefore, we need to duplicate the manager and set it to the body
77
- // positionated over the modal
78
- function _duplicateManager() {
79
- _removeClonedManager ();
80
- const original = $originalManager .value ! ;
81
- if (! original ) return ;
82
-
83
- original .style .visibility = ' hidden' ;
84
-
85
- const manager = original .cloneNode (true ) as HTMLDivElement ;
86
-
87
- if (! manager ) {
88
- return ;
89
- }
90
-
91
- manager .style .position = ' absolute' ;
92
- manager .style .top = ` ${original .offsetTop }px ` ;
93
- manager .style .left = ` ${original .offsetLeft }px ` ;
94
- manager .style .width = ` ${original .offsetWidth }px ` ;
95
- manager .style .height = ` ${original .offsetHeight }px ` ;
96
- manager .style .visibility = ' inherit' ;
97
- manager .style .zIndex = ' 10' ;
98
- document .body .appendChild (manager );
99
-
100
- manager .querySelector (' button' )! .addEventListener (' click' , () => endTour ());
101
45
}
102
46
103
47
function endTour(emit = true ) {
104
- _removeClonedManager ();
105
48
show .value = false ;
106
49
if (emit ) {
107
50
// Notify tour component through root instance event bus
@@ -134,6 +77,7 @@ export default defineComponent({
134
77
.tour-manager {
135
78
width : 100% ;
136
79
overflow : hidden ;
80
+ z-index : 10 ;
137
81
138
82
margin-bottom : 2rem ;
139
83
0 commit comments