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

Allow disabling highlight

Browse files
assets/scripts/src/overlay.js CHANGED
@@ -5,9 +5,14 @@ import Position from './position';
5
  * cutting out the visible part, animating between the sections etc
6
  */
7
  export default class Overlay {
8
- constructor({ opacity = 0.75, padding = 5 }) {
 
 
 
 
9
  this.opacity = opacity; // Fixed opacity for the layover
10
  this.padding = padding; // Padding around the highlighted item
 
11
 
12
  this.overlayAlpha = 0; // Is used to animate the layover
13
  this.positionToHighlight = new Position({}); // position at which layover is to be patched at
@@ -56,7 +61,7 @@ export default class Overlay {
56
 
57
  // If animation is not required then set the last path to be same
58
  // as the current path so that there is no easing towards it
59
- if (!animate) {
60
  this.highlightedPosition = this.positionToHighlight;
61
  }
62
 
@@ -111,7 +116,11 @@ export default class Overlay {
111
 
112
  if (canHighlight) {
113
  // Fade the overlay in if we can highlight
114
- this.overlayAlpha += (this.opacity - this.overlayAlpha) * 0.08;
 
 
 
 
115
  } else {
116
  // otherwise fade out
117
  this.overlayAlpha = Math.max((this.overlayAlpha * 0.85) - 0.02, 0);
 
5
  * cutting out the visible part, animating between the sections etc
6
  */
7
  export default class Overlay {
8
+ constructor({
9
+ opacity = 0.75,
10
+ padding = 5,
11
+ animate = true,
12
+ }) {
13
  this.opacity = opacity; // Fixed opacity for the layover
14
  this.padding = padding; // Padding around the highlighted item
15
+ this.animate = animate; // Should animate between the transitions
16
 
17
  this.overlayAlpha = 0; // Is used to animate the layover
18
  this.positionToHighlight = new Position({}); // position at which layover is to be patched at
 
61
 
62
  // If animation is not required then set the last path to be same
63
  // as the current path so that there is no easing towards it
64
+ if (!this.animate || !animate) {
65
  this.highlightedPosition = this.positionToHighlight;
66
  }
67
 
 
116
 
117
  if (canHighlight) {
118
  // Fade the overlay in if we can highlight
119
+ if (!this.animate) {
120
+ this.overlayAlpha = this.opacity;
121
+ } else {
122
+ this.overlayAlpha += (this.opacity - this.overlayAlpha) * 0.08;
123
+ }
124
  } else {
125
  // otherwise fade out
126
  this.overlayAlpha = Math.max((this.overlayAlpha * 0.85) - 0.02, 0);
assets/scripts/src/sholo.js CHANGED
@@ -6,8 +6,17 @@ import './polyfill';
6
  * Plugin class that drives the plugin
7
  */
8
  export default class Sholo {
9
- constructor({ opacity = 0.75, padding = 5 } = {}) {
10
- this.overlay = new Overlay({ opacity, padding });
 
 
 
 
 
 
 
 
 
11
  this.document = document;
12
  this.window = window;
13
 
 
6
  * Plugin class that drives the plugin
7
  */
8
  export default class Sholo {
9
+ constructor({
10
+ opacity = 0.75,
11
+ padding = 5,
12
+ animate = true,
13
+ } = {}) {
14
+ this.overlay = new Overlay({
15
+ opacity,
16
+ padding,
17
+ animate,
18
+ });
19
+
20
  this.document = document;
21
  this.window = window;
22
 
index.html CHANGED
@@ -50,7 +50,9 @@
50
  '.section__examples'
51
  ];
52
 
53
- const sholo = new Sholo();
 
 
54
 
55
  nodesToSelect.forEach((nodeToSelect, index) => {
56
  window.setTimeout(() => {
 
50
  '.section__examples'
51
  ];
52
 
53
+ const sholo = new Sholo({
54
+ animate: false
55
+ });
56
 
57
  nodesToSelect.forEach((nodeToSelect, index) => {
58
  window.setTimeout(() => {