kamrify commited on
Commit
3155c68
·
1 Parent(s): 10f5516

Accessibility improvements and refactorign

Browse files
demo/scripts/demo.js CHANGED
@@ -111,7 +111,7 @@ document.addEventListener("DOMContentLoaded", function () {
111
  document.querySelector('#animated-tour')
112
  .addEventListener('click', () => {
113
  if (boringTourDriver.isActivated) {
114
- boringTourDriver.reset();
115
  }
116
 
117
  animatedTourDriver.start();
@@ -120,7 +120,7 @@ document.addEventListener("DOMContentLoaded", function () {
120
  document.querySelector('#boring-tour')
121
  .addEventListener('click', () => {
122
  if (animatedTourDriver.isActivated) {
123
- animatedTourDriver.reset();
124
  }
125
 
126
  boringTourDriver.start();
 
111
  document.querySelector('#animated-tour')
112
  .addEventListener('click', () => {
113
  if (boringTourDriver.isActivated) {
114
+ boringTourDriver.reset(true);
115
  }
116
 
117
  animatedTourDriver.start();
 
120
  document.querySelector('#boring-tour')
121
  .addEventListener('click', () => {
122
  if (animatedTourDriver.isActivated) {
123
+ animatedTourDriver.reset(true);
124
  }
125
 
126
  boringTourDriver.start();
src/common/constants.js CHANGED
@@ -34,10 +34,10 @@ export const POPOVER_HTML = `
34
  <div class="${CLASS_POPOVER_TITLE}">Popover Title</div>
35
  <div class="${CLASS_POPOVER_DESCRIPTION}">Popover Description</div>
36
  <div class="${CLASS_POPOVER_FOOTER}">
37
- <a href="javascript:void(0)" class="${CLASS_CLOSE_BTN}">Close</a>
38
  <span class="driver-btn-group">
39
- <a class="${CLASS_PREV_STEP_BTN}" href="javascript:void(0)">&larr; Previous</a>
40
- <a class="${CLASS_NEXT_STEP_BTN}" href="javascript:void(0)">Next &rarr;</a>
41
  </span>
42
  </div>
43
  </div>`;
 
34
  <div class="${CLASS_POPOVER_TITLE}">Popover Title</div>
35
  <div class="${CLASS_POPOVER_DESCRIPTION}">Popover Description</div>
36
  <div class="${CLASS_POPOVER_FOOTER}">
37
+ <button class="${CLASS_CLOSE_BTN}">Close</button>
38
  <span class="driver-btn-group">
39
+ <button class="${CLASS_PREV_STEP_BTN}">&larr; Previous</button>
40
+ <button class="${CLASS_NEXT_STEP_BTN}">Next &rarr;</button>
41
  </span>
42
  </div>
43
  </div>`;
src/core/overlay.js CHANGED
@@ -20,6 +20,8 @@ export default class Overlay {
20
 
21
  this.window = window;
22
  this.document = document;
 
 
23
  }
24
 
25
  /**
@@ -120,10 +122,11 @@ export default class Overlay {
120
  /**
121
  * Removes the overlay and cancel any listeners
122
  */
123
- clear() {
124
  // Deselect the highlighted element if any
125
  if (this.highlightedElement) {
126
- this.highlightedElement.onDeselected(true);
 
127
  }
128
 
129
  this.highlightedElement = null;
@@ -136,9 +139,9 @@ export default class Overlay {
136
  // Clear any existing timers and remove node
137
  this.window.clearTimeout(this.hideTimer);
138
 
139
- if (this.options.animate) {
140
  this.node.style.opacity = '0';
141
- this.hideTimer = window.setTimeout(this.removeNode, ANIMATION_DURATION_MS);
142
  } else {
143
  this.removeNode();
144
  }
 
20
 
21
  this.window = window;
22
  this.document = document;
23
+
24
+ this.removeNode = this.removeNode.bind(this);
25
  }
26
 
27
  /**
 
122
  /**
123
  * Removes the overlay and cancel any listeners
124
  */
125
+ clear(immediate = false) {
126
  // Deselect the highlighted element if any
127
  if (this.highlightedElement) {
128
+ const hideStage = true;
129
+ this.highlightedElement.onDeselected(hideStage);
130
  }
131
 
132
  this.highlightedElement = null;
 
139
  // Clear any existing timers and remove node
140
  this.window.clearTimeout(this.hideTimer);
141
 
142
+ if (this.options.animate && !immediate) {
143
  this.node.style.opacity = '0';
144
+ this.hideTimer = this.window.setTimeout(this.removeNode, ANIMATION_DURATION_MS);
145
  } else {
146
  this.removeNode();
147
  }
src/driver.scss CHANGED
@@ -56,7 +56,7 @@ div#driver-popover-item {
56
  clear: both;
57
  margin-top: 5px;
58
 
59
- a {
60
  display: inline-block;
61
  padding: 3px 10px;
62
  border: 1px solid #d4d4d4;
@@ -72,7 +72,7 @@ div#driver-popover-item {
72
  margin: 10px 0 0;
73
  }
74
 
75
- a.driver-disabled {
76
  color: #808080;
77
  cursor: default;
78
  pointer-events: none;
 
56
  clear: both;
57
  margin-top: 5px;
58
 
59
+ button {
60
  display: inline-block;
61
  padding: 3px 10px;
62
  border: 1px solid #d4d4d4;
 
72
  margin: 10px 0 0;
73
  }
74
 
75
+ button.driver-disabled {
76
  color: #808080;
77
  cursor: default;
78
  pointer-events: none;
src/index.js CHANGED
@@ -147,10 +147,10 @@ export default class Driver {
147
  /**
148
  * Resets the steps if any and clears the overlay
149
  */
150
- reset() {
151
  this.currentStep = 0;
152
  this.isActivated = false;
153
- this.overlay.clear();
154
  }
155
 
156
  /**
 
147
  /**
148
  * Resets the steps if any and clears the overlay
149
  */
150
+ reset(immediate = false) {
151
  this.currentStep = 0;
152
  this.isActivated = false;
153
+ this.overlay.clear(immediate);
154
  }
155
 
156
  /**