kamrify commited on
Commit
33909e6
·
1 Parent(s): 31d8a1a

Fix - Clear overlay ignores the animation flag

Browse files
assets/scripts/src/overlay.js CHANGED
@@ -69,11 +69,15 @@ export default class Overlay {
69
  }
70
 
71
  clear() {
72
- // Cancel the existing animation frame if any
73
- // remove the highlighted element and remove the canvas
74
- this.window.cancelAnimationFrame(this.redrawAnimation);
75
  this.highlightedElement = null;
76
- this.document.body.removeChild(this.overlay);
 
 
 
 
 
 
77
  }
78
 
79
  /**
@@ -137,6 +141,8 @@ export default class Overlay {
137
  document.body.appendChild(this.overlay);
138
  }
139
 
 
 
140
  // Stage a new animation frame
141
  this.redrawAnimation = this.window.requestAnimationFrame(this.draw);
142
  } else {
 
69
  }
70
 
71
  clear() {
72
+ this.positionToHighlight = new Position();
 
 
73
  this.highlightedElement = null;
74
+
75
+ // If animation is not required, cancel the immediately remove the canvas
76
+ // This will stop the animation from the animation frames above
77
+ if (!this.animate) {
78
+ this.window.cancelAnimationFrame(this.redrawAnimation);
79
+ this.document.body.removeChild(this.overlay);
80
+ }
81
  }
82
 
83
  /**
 
141
  document.body.appendChild(this.overlay);
142
  }
143
 
144
+ // @todo: do not requestAnimationFrame once final highlight position has been reached
145
+
146
  // Stage a new animation frame
147
  this.redrawAnimation = this.window.requestAnimationFrame(this.draw);
148
  } else {
assets/scripts/src/position.js CHANGED
@@ -14,7 +14,7 @@ export default class Position {
14
  top = 0,
15
  right = 0,
16
  bottom = 0,
17
- }) {
18
  this.left = left;
19
  this.right = right;
20
  this.top = top;
 
14
  top = 0,
15
  right = 0,
16
  bottom = 0,
17
+ } = {}) {
18
  this.left = left;
19
  this.right = right;
20
  this.top = top;
index.html CHANGED
@@ -51,7 +51,8 @@
51
  ];
52
 
53
  const sholo = new Sholo({
54
- animate: false
 
55
  });
56
 
57
  nodesToSelect.forEach((nodeToSelect, index) => {
 
51
  ];
52
 
53
  const sholo = new Sholo({
54
+ padding: 10,
55
+ animate: true
56
  });
57
 
58
  nodesToSelect.forEach((nodeToSelect, index) => {