kamrify commited on
Commit
5829a93
·
1 Parent(s): 22c7264

Minor update

Browse files
assets/scripts/src/overlay.js CHANGED
@@ -7,8 +7,10 @@ import Position from './position';
7
  export default class Overlay {
8
  constructor({ alpha = 0.75 }) {
9
  this.alpha = alpha;
 
 
 
10
  this.window = window;
11
- this.selected = new Position({});
12
 
13
  this.prepareContext();
14
  this.setSize();
@@ -30,7 +32,7 @@ export default class Overlay {
30
  }
31
 
32
  // Highlights the dom element on the screen
33
- highglight(element) {
34
  if (!element) {
35
  // @todo - clearing the overlay
36
  return;
@@ -42,21 +44,22 @@ export default class Overlay {
42
  return;
43
  }
44
 
45
- this.selected = position;
46
  this.draw();
47
  }
48
 
49
  draw() {
 
50
  this.context.clearRect(0, 0, this.overlay.width, this.overlay.height);
51
  this.context.fillStyle = `rgba( 0, 0, 0, ${this.alpha})`;
52
  this.context.fillRect(0, 0, this.overlay.width, this.overlay.height);
53
 
54
  // Cut out the cleared region
55
  this.context.clearRect(
56
- this.selected.left - window.scrollX,
57
- this.selected.top - window.scrollY,
58
- (this.selected.right - this.selected.left),
59
- (this.selected.bottom - this.selected.top),
60
  );
61
 
62
  // Append the overlay if not there already
 
7
  export default class Overlay {
8
  constructor({ alpha = 0.75 }) {
9
  this.alpha = alpha;
10
+ this.selectedPosition = new Position({});
11
+ this.lastSelectedPosition = new Position({});
12
+
13
  this.window = window;
 
14
 
15
  this.prepareContext();
16
  this.setSize();
 
32
  }
33
 
34
  // Highlights the dom element on the screen
35
+ highlight(element) {
36
  if (!element) {
37
  // @todo - clearing the overlay
38
  return;
 
44
  return;
45
  }
46
 
47
+ this.selectedPosition = position;
48
  this.draw();
49
  }
50
 
51
  draw() {
52
+ // Reset the overlay
53
  this.context.clearRect(0, 0, this.overlay.width, this.overlay.height);
54
  this.context.fillStyle = `rgba( 0, 0, 0, ${this.alpha})`;
55
  this.context.fillRect(0, 0, this.overlay.width, this.overlay.height);
56
 
57
  // Cut out the cleared region
58
  this.context.clearRect(
59
+ this.selectedPosition.left - window.scrollX,
60
+ this.selectedPosition.top - window.scrollY,
61
+ (this.selectedPosition.right - this.selectedPosition.left),
62
+ (this.selectedPosition.bottom - this.selectedPosition.top),
63
  );
64
 
65
  // Append the overlay if not there already
assets/scripts/src/sholo.js CHANGED
@@ -6,8 +6,8 @@ import Element from './element';
6
  * Plugin class that drives the plugin
7
  */
8
  export default class Sholo {
9
- constructor({ alpha = 0.75 } = {}) {
10
- this.overlay = new Overlay({ alpha });
11
  }
12
 
13
  highlight(selector) {
@@ -22,6 +22,6 @@ export default class Sholo {
22
  }
23
 
24
  const element = new Element(domElement);
25
- this.overlay.highglight(element);
26
  }
27
  }
 
6
  * Plugin class that drives the plugin
7
  */
8
  export default class Sholo {
9
+ constructor({ opacity = 0.75 } = {}) {
10
+ this.overlay = new Overlay({ opacity });
11
  }
12
 
13
  highlight(selector) {
 
22
  }
23
 
24
  const element = new Element(domElement);
25
+ this.overlay.highlight(element);
26
  }
27
  }
index.html CHANGED
@@ -47,6 +47,7 @@
47
  const nodesToSelect = [
48
  '.section__header',
49
  '.section__how',
 
50
  ];
51
 
52
  const sholo = new Sholo();
@@ -54,7 +55,7 @@
54
  nodesToSelect.forEach((nodeToSelect, index) => {
55
  window.setTimeout(() => {
56
  sholo.highlight(nodeToSelect);
57
- }, index * 1000);
58
  });
59
  </script>
60
  </body>
 
47
  const nodesToSelect = [
48
  '.section__header',
49
  '.section__how',
50
+ '.section__examples'
51
  ];
52
 
53
  const sholo = new Sholo();
 
55
  nodesToSelect.forEach((nodeToSelect, index) => {
56
  window.setTimeout(() => {
57
  sholo.highlight(nodeToSelect);
58
+ }, index * 5000);
59
  });
60
  </script>
61
  </body>