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

Escape key to clear the overlay

Browse files
Files changed (1) hide show
  1. assets/scripts/src/sholo.js +8 -0
assets/scripts/src/sholo.js CHANGED
@@ -22,6 +22,7 @@ export default class Sholo {
22
 
23
  this.onScroll = this.onScroll.bind(this);
24
  this.onResize = this.onResize.bind(this);
 
25
 
26
  // Event bindings
27
  this.bind();
@@ -32,6 +33,7 @@ export default class Sholo {
32
  this.document.addEventListener('scroll', this.onScroll, false);
33
  this.document.addEventListener('DOMMouseScroll', this.onScroll, false);
34
  this.window.addEventListener('resize', this.onResize, false);
 
35
  }
36
 
37
  onScroll() {
@@ -44,6 +46,12 @@ export default class Sholo {
44
  this.overlay.refresh(true);
45
  }
46
 
 
 
 
 
 
 
47
  highlight(selector) {
48
  let domElement;
49
 
 
22
 
23
  this.onScroll = this.onScroll.bind(this);
24
  this.onResize = this.onResize.bind(this);
25
+ this.onKeyUp = this.onKeyUp.bind(this);
26
 
27
  // Event bindings
28
  this.bind();
 
33
  this.document.addEventListener('scroll', this.onScroll, false);
34
  this.document.addEventListener('DOMMouseScroll', this.onScroll, false);
35
  this.window.addEventListener('resize', this.onResize, false);
36
+ this.window.addEventListener('keyup', this.onKeyUp, false);
37
  }
38
 
39
  onScroll() {
 
46
  this.overlay.refresh(true);
47
  }
48
 
49
+ onKeyUp(event) {
50
+ if (event.keyCode === 27) {
51
+ this.overlay.clear();
52
+ }
53
+ }
54
+
55
  highlight(selector) {
56
  let domElement;
57