highmark-cli 0.0.140 → 0.0.142

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3,7 +3,7 @@
3
3
  import withStyle from "easy-with-style"; ///
4
4
 
5
5
  import { window } from "easy";
6
- import { keyCodes } from "necessary";
6
+ import { keyCodes, arrayUtilities } from "necessary";
7
7
 
8
8
  import Div from "../div";
9
9
  import Element from "../element";
@@ -12,10 +12,11 @@ import fullScreenMixins from "../../mixins/fullsrean";
12
12
 
13
13
  import { isFullScreen } from "../../utilities/fullScreen";
14
14
  import { elementsFromDOMElements } from "../../utilities/element";
15
+ import { getOverlayZoom as getZoom, areColoursInverted, areNativeGesturesRestored } from "../../state";
15
16
  import { SCROLL_DELAY, UP_DIRECTION, DECELERATION, DOWN_DIRECTION, OPEN_MENU_TAP_AREA_HEIGHT } from "../../constants";
16
- import { getViewZoom as getZoom, setViewZoom as setZoom, setColoursInverted, areColoursInverted } from "../../state";
17
17
 
18
- const { ENTER_KEY_CODE,
18
+ const { first } = arrayUtilities,
19
+ { ENTER_KEY_CODE,
19
20
  ESCAPE_KEY_CODE,
20
21
  BACKSPACE_KEY_CODE,
21
22
  ARROW_UP_KEY_CODE,
@@ -27,21 +28,15 @@ class OverlayDiv extends Element {
27
28
  fullScreenChangeCustomHandler = (event, element) => {
28
29
  controller.closeMenu();
29
30
 
30
- this.updateZoom();
31
+ this.updateOverlayZoom();
31
32
  }
32
33
 
33
34
  doubleTapCustomHandler = (event, element, top, left) => {
34
35
  const fullScreen = isFullScreen();
35
36
 
36
- if (fullScreen) {
37
- controller.exitFullScreen();
38
-
39
- return;
40
- }
41
-
42
- this.restoreNativeGestures();
43
-
44
- controller.checkRestoreNativeGesturesCheckbox();
37
+ fullScreen ?
38
+ controller.exitFullScreen() :
39
+ controller.enterFullScreen();
45
40
  }
46
41
 
47
42
  pinchStartCustomHandler = (event, element) => {
@@ -53,11 +48,9 @@ class OverlayDiv extends Element {
53
48
 
54
49
  pinchMoveCustomHandler = (event, element, ratio) => {
55
50
  const startZoom = this.getStartZoom(),
56
- zoom = startZoom * Math.sqrt(ratio);
57
-
58
- setZoom(zoom);
51
+ overlayZoom = startZoom * Math.sqrt(ratio); ///
59
52
 
60
- this.updateZoom();
53
+ controller.zoomOverlay(overlayZoom);
61
54
  }
62
55
 
63
56
  swipeRightCustomHandler = (event, element) => {
@@ -112,22 +105,20 @@ class OverlayDiv extends Element {
112
105
  }
113
106
 
114
107
  tapCustomHandler = (event, element, top, left) => {
115
- const fullScreen = isFullScreen();
116
-
117
- if (!fullScreen) {
118
- const height = this.getHeight(),
119
- bottom = height - top;
108
+ const height = this.getHeight(),
109
+ bottom = height - top;
120
110
 
121
- if (bottom < OPEN_MENU_TAP_AREA_HEIGHT) {
122
- controller.openMenu();
111
+ if (bottom < OPEN_MENU_TAP_AREA_HEIGHT) {
112
+ controller.openMenu();
123
113
 
124
- return;
125
- }
114
+ return;
126
115
  }
127
116
 
128
- this.suppressNativeGestures();
117
+ const nativeGesturesRestored = areNativeGesturesRestored();
129
118
 
130
- controller.uncheckRestoreNativeGesturesCheckbox();
119
+ nativeGesturesRestored ?
120
+ controller.suppressNativeGestures() :
121
+ controller.restoreNativeGestures();
131
122
  }
132
123
 
133
124
  keyDownHandler = (event, element) => {
@@ -149,7 +140,7 @@ class OverlayDiv extends Element {
149
140
  }
150
141
 
151
142
  case ESCAPE_KEY_CODE: {
152
- ///
143
+ controller.exitFullScreen();
153
144
 
154
145
  break;
155
146
  }
@@ -168,23 +159,6 @@ class OverlayDiv extends Element {
168
159
  }
169
160
  }
170
161
 
171
- updateColours() {
172
- const coloursInverted = areColoursInverted();
173
-
174
- coloursInverted ?
175
- this.addClass("inverted-colours") :
176
- this.removeClass("inverted-colours");
177
-
178
- this.updateZoom();
179
- }
180
-
181
- updateZoom() {
182
- const zoom = getZoom(),
183
- displayedDiv = this.findDisplayedDiv();
184
-
185
- displayedDiv.zoom(zoom);
186
- }
187
-
188
162
  scrollToTop() {
189
163
  const scrollTop = 0;
190
164
 
@@ -237,43 +211,50 @@ class OverlayDiv extends Element {
237
211
  this.setInterval(interval);
238
212
  }
239
213
 
240
- invertColours() {
241
- const coloursInverted = true;
214
+ enterFullScreen(callback) {
215
+ this.requestFullScreen(callback);
216
+ }
242
217
 
243
- setColoursInverted(coloursInverted);
218
+ updateOverlayZoom() {
219
+ const div = this.findDiv(),
220
+ zoom = getZoom();
244
221
 
245
- this.updateColours();
222
+ div.zoom(zoom);
246
223
  }
247
224
 
248
- revertColours() {
249
- const coloursInverted = false;
250
-
251
- setColoursInverted(coloursInverted);
225
+ updateOverlayColours() {
226
+ const coloursInverted = areColoursInverted();
252
227
 
253
- this.updateColours();
254
- }
228
+ coloursInverted ?
229
+ this.addClass("inverted-colours") :
230
+ this.removeClass("inverted-colours");
255
231
 
256
- enterFullScreen() {
257
- this.requestFullScreen();
232
+ this.updateOverlayZoom();
258
233
  }
259
234
 
260
- restoreNativeGestures() {
261
- this.addClass("native-gestures");
262
-
263
- this.disableCustomGestures();
235
+ updateNativeGestures() {
236
+ // const nativeGesturesRestored = areNativeGesturesRestored();
237
+ //
238
+ // nativeGesturesRestored ?
239
+ // this.addClass("native-gestures") :
240
+ // this.removeClass("native-gestures");
241
+ //
242
+ // nativeGesturesRestored ?
243
+ // this.disableCustomGestures() :
244
+ // this.enableCustomGestures();
264
245
  }
265
246
 
266
- suppressNativeGestures() {
267
- this.removeClass("native-gestures");
247
+ areNativeGesturesRestored() {
248
+ const nativeGesturesRestored = this.hasClass("native-gestures");
268
249
 
269
- this.enableCustomGestures();
250
+ return nativeGesturesRestored;
270
251
  }
271
252
 
272
253
  showRightDiv() {
273
- const displayedDiv = this.findDisplayedDiv(),
254
+ const div = this.findDiv(),
274
255
  divs = this.getDivs(),
275
256
  divsLength = divs.length,
276
- index = divs.indexOf(displayedDiv),
257
+ index = divs.indexOf(div),
277
258
  nextIndex = index + 1,
278
259
  previousIndex = index; ///
279
260
 
@@ -284,22 +265,10 @@ class OverlayDiv extends Element {
284
265
  this.showNextDiv(nextIndex, previousIndex);
285
266
  }
286
267
 
287
- showFirstDiv() {
288
- const displayedDiv = this.findDisplayedDiv(),
289
- divs = this.getDivs(),
290
- index = divs.indexOf(displayedDiv),
291
- nextIndex = 0,
292
- previousIndex = (index === -1) ?
293
- nextIndex : ///
294
- index; ///
295
-
296
- this.showNextDiv(nextIndex, previousIndex);
297
- }
298
-
299
268
  showLeftDiv() {
300
- const displayedDiv = this.findDisplayedDiv(),
269
+ const div = this.findDiv(),
301
270
  divs = this.getDivs(),
302
- index = divs.indexOf(displayedDiv),
271
+ index = divs.indexOf(div),
303
272
  nextIndex = index - 1,
304
273
  previousIndex = index; ///
305
274
 
@@ -311,9 +280,9 @@ class OverlayDiv extends Element {
311
280
  }
312
281
 
313
282
  showLastDiv() {
314
- const displayedDiv = this.findDisplayedDiv(),
283
+ const div = this.findDiv(),
315
284
  divs = this.getDivs(),
316
- index = divs.indexOf(displayedDiv),
285
+ index = divs.indexOf(div),
317
286
  divsLength = divs.length,
318
287
  nextIndex = divsLength - 1,
319
288
  previousIndex = (index === -1) ?
@@ -324,30 +293,42 @@ class OverlayDiv extends Element {
324
293
  }
325
294
 
326
295
  showNextDiv(nextIndex, previousIndex) {
327
- const divs = this.getDivs(),
296
+ const zoom = getZoom(),
297
+ divs = this.getDivs(),
328
298
  nextDiv = divs[nextIndex],
329
- previousDiv = divs[previousIndex],
330
- backgroundColour = nextDiv.getBackgroundColour();
299
+ previousDiv = divs[previousIndex];
331
300
 
332
- let zoom;
301
+ this.stopScrolling();
333
302
 
334
- zoom = 1;
303
+ this.scrollToTop();
335
304
 
336
- previousDiv.zoom(zoom);
305
+ this.remove(previousDiv);
337
306
 
338
- zoom = getZoom();
307
+ this.add(nextDiv);
339
308
 
340
309
  nextDiv.zoom(zoom);
341
310
 
342
- previousDiv.hide();
311
+ setTimeout(() => {
312
+ const backgroundColour = nextDiv.getBackgroundColour();
343
313
 
344
- this.setBackgroundColour(backgroundColour);
314
+ this.setBackgroundColour(backgroundColour);
315
+ }, 0);
316
+ }
345
317
 
346
- this.stopScrolling();
318
+ showFirstDiv() {
319
+ const zoom = getZoom(),
320
+ divs = this.getDivs(),
321
+ firstDiv = first(divs);
347
322
 
348
- this.scrollToTop();
323
+ this.add(firstDiv);
324
+
325
+ firstDiv.zoom(zoom);
326
+
327
+ setTimeout(() => {
328
+ const backgroundColour = firstDiv.getBackgroundColour();
349
329
 
350
- nextDiv.show();
330
+ this.setBackgroundColour(backgroundColour);
331
+ }, 0);
351
332
  }
352
333
 
353
334
  setBackgroundColour(backgroundColour) {
@@ -359,26 +340,31 @@ class OverlayDiv extends Element {
359
340
  this.css(css);
360
341
  }
361
342
 
362
- findDisplayedDiv() {
343
+ findDiv() {
363
344
  const divs = this.getDivs(),
364
- displayedDiv = divs.find((div) => {
365
- const displayed = div.isDisplayed();
345
+ div = divs.find((div) => {
346
+ const added = div.isAdded();
366
347
 
367
- if (displayed) {
348
+ if (added) {
368
349
  return true;
369
350
  }
370
351
  });
371
352
 
372
- return displayedDiv;
353
+ return div;
373
354
  }
374
355
 
375
356
  getDivs() {
376
- const childElements = this.getChildElements(),
377
- divs = childElements; ///
357
+ const { divs } = this.getState();
378
358
 
379
359
  return divs;
380
360
  }
381
361
 
362
+ setDivs(divs) {
363
+ this.updateState({
364
+ divs
365
+ });
366
+ }
367
+
382
368
  getInterval() {
383
369
  const { interval } = this.getState();
384
370
 
@@ -416,11 +402,13 @@ class OverlayDiv extends Element {
416
402
  }
417
403
 
418
404
  setInitialState() {
419
- const interval = null,
405
+ const divs = this.createDivs(),
406
+ interval = null,
420
407
  startZoom = null,
421
408
  startScrollTop = null;
422
409
 
423
410
  this.setState({
411
+ divs,
424
412
  interval,
425
413
  startZoom,
426
414
  startScrollTop
@@ -447,10 +435,6 @@ class OverlayDiv extends Element {
447
435
  this.enableFullScreen();
448
436
 
449
437
  this.enableTouch();
450
-
451
- this.updateZoom();
452
-
453
- this.updateColours();
454
438
  }
455
439
 
456
440
  willUnmount() {
@@ -475,33 +459,26 @@ class OverlayDiv extends Element {
475
459
  window.offKeyDown(this.keyDownHandler);
476
460
  }
477
461
 
478
- childElements() {
462
+ createDivs() {
479
463
  const { divDOMElements } = this.properties,
480
- divs = elementsFromDOMElements(divDOMElements, Div),
481
- childElements = [
482
- ...divs
483
- ];
464
+ divs = elementsFromDOMElements(divDOMElements, Div);
484
465
 
485
- return childElements;
466
+ return divs;
486
467
  }
487
468
 
488
469
  parentContext() {
489
- const invertColours = this.invertColours.bind(this),
490
- revertColours = this.revertColours.bind(this),
491
- exitFullScreen = this.exitFullScreen.bind(this),
470
+ const exitFullScreen = this.exitFullScreen.bind(this),
492
471
  enterFullScreen = this.enterFullScreen.bind(this),
493
- updateOverlayDivZoom = this.updateZoom.bind(this), ///
494
- restoreNativeGestures = this.restoreNativeGestures.bind(this),
495
- suppressNativeGestures = this.suppressNativeGestures.bind(this);
472
+ updateOverlayZoom = this.updateOverlayZoom.bind(this),
473
+ updateOverlayColours = this.updateOverlayColours.bind(this),
474
+ updateNativeGestures = this.updateNativeGestures.bind(this);
496
475
 
497
476
  return ({
498
- invertColours,
499
- revertColours,
500
477
  exitFullScreen,
501
478
  enterFullScreen,
502
- updateOverlayDivZoom,
503
- restoreNativeGestures,
504
- suppressNativeGestures
479
+ updateOverlayZoom,
480
+ updateOverlayColours,
481
+ updateNativeGestures
505
482
  });
506
483
  }
507
484
 
package/src/view/div.js CHANGED
@@ -13,12 +13,23 @@ class Div extends Element {
13
13
  return backgroundColour;
14
14
  }
15
15
 
16
+ isAdded() {
17
+ const domElement = this.getDOMElement(),
18
+ { parentNode } = domElement,
19
+ added = (parentNode !== null);
20
+
21
+ return added;
22
+ }
23
+
16
24
  zoom(zoom) {
17
- const width = `${100/zoom}%`,
25
+ const zoomRatio = 100 / zoom,
26
+ width = `${zoomRatio}%`,
27
+ minHeight = `${zoomRatio}%`,
18
28
  transform = `scale(${zoom})`;
19
29
 
20
30
  const css = {
21
31
  width,
32
+ minHeight,
22
33
  transform
23
34
  };
24
35
 
@@ -31,9 +42,6 @@ class Div extends Element {
31
42
  export default withStyle(Div)`
32
43
 
33
44
  width: 100%;
34
- display: none;
35
- min-height: 100%;
36
- pointer-events: none;
37
45
  transform-origin: top left;
38
46
 
39
47
  `;
package/src/view.js CHANGED
@@ -9,8 +9,22 @@ import PreloaderDiv from "./view/div/preloader";
9
9
 
10
10
  class View extends Element {
11
11
  updateZoom() {
12
- this.updateMenuDivZoom();
13
- this.updateOverlayDivZoom();
12
+ this.updateMenuZoom();
13
+ this.updateOverlayZoom();
14
+ }
15
+
16
+ didMount() {
17
+ this.updateMenuZoom();
18
+ this.updateOverlayZoom();
19
+ this.updateOverlayColours();
20
+ this.updateNativeGestures();
21
+ this.updateFullScreenCheckboxDiv();
22
+ this.updateInvertColoursCheckboxDiv();
23
+ this.updateNativeGesturesCheckboxDiv();
24
+ }
25
+
26
+ willUnmount() {
27
+ ///
14
28
  }
15
29
 
16
30
  childElements() {
@@ -1,121 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- Object.defineProperty(exports, "default", {
6
- enumerable: true,
7
- get: function() {
8
- return FullScreenButton;
9
- }
10
- });
11
- var _button = /*#__PURE__*/ _interop_require_default(require("../button"));
12
- var _fullScreen = /*#__PURE__*/ _interop_require_default(require("../svg/fullScreen"));
13
- function _assert_this_initialized(self) {
14
- if (self === void 0) {
15
- throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
16
- }
17
- return self;
18
- }
19
- function _class_call_check(instance, Constructor) {
20
- if (!(instance instanceof Constructor)) {
21
- throw new TypeError("Cannot call a class as a function");
22
- }
23
- }
24
- function _define_property(obj, key, value) {
25
- if (key in obj) {
26
- Object.defineProperty(obj, key, {
27
- value: value,
28
- enumerable: true,
29
- configurable: true,
30
- writable: true
31
- });
32
- } else {
33
- obj[key] = value;
34
- }
35
- return obj;
36
- }
37
- function _get_prototype_of(o) {
38
- _get_prototype_of = Object.setPrototypeOf ? Object.getPrototypeOf : function getPrototypeOf(o) {
39
- return o.__proto__ || Object.getPrototypeOf(o);
40
- };
41
- return _get_prototype_of(o);
42
- }
43
- function _inherits(subClass, superClass) {
44
- if (typeof superClass !== "function" && superClass !== null) {
45
- throw new TypeError("Super expression must either be null or a function");
46
- }
47
- subClass.prototype = Object.create(superClass && superClass.prototype, {
48
- constructor: {
49
- value: subClass,
50
- writable: true,
51
- configurable: true
52
- }
53
- });
54
- if (superClass) _set_prototype_of(subClass, superClass);
55
- }
56
- function _interop_require_default(obj) {
57
- return obj && obj.__esModule ? obj : {
58
- default: obj
59
- };
60
- }
61
- function _possible_constructor_return(self, call) {
62
- if (call && (_type_of(call) === "object" || typeof call === "function")) {
63
- return call;
64
- }
65
- return _assert_this_initialized(self);
66
- }
67
- function _set_prototype_of(o, p) {
68
- _set_prototype_of = Object.setPrototypeOf || function setPrototypeOf(o, p) {
69
- o.__proto__ = p;
70
- return o;
71
- };
72
- return _set_prototype_of(o, p);
73
- }
74
- function _type_of(obj) {
75
- "@swc/helpers - typeof";
76
- return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
77
- }
78
- function _is_native_reflect_construct() {
79
- if (typeof Reflect === "undefined" || !Reflect.construct) return false;
80
- if (Reflect.construct.sham) return false;
81
- if (typeof Proxy === "function") return true;
82
- try {
83
- Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
84
- return true;
85
- } catch (e) {
86
- return false;
87
- }
88
- }
89
- function _create_super(Derived) {
90
- var hasNativeReflectConstruct = _is_native_reflect_construct();
91
- return function _createSuperInternal() {
92
- var Super = _get_prototype_of(Derived), result;
93
- if (hasNativeReflectConstruct) {
94
- var NewTarget = _get_prototype_of(this).constructor;
95
- result = Reflect.construct(Super, arguments, NewTarget);
96
- } else {
97
- result = Super.apply(this, arguments);
98
- }
99
- return _possible_constructor_return(this, result);
100
- };
101
- }
102
- var FullScreenButton = /*#__PURE__*/ function(Button) {
103
- _inherits(FullScreenButton, Button);
104
- var _super = _create_super(FullScreenButton);
105
- function FullScreenButton() {
106
- _class_call_check(this, FullScreenButton);
107
- var _this;
108
- _this = _super.apply(this, arguments);
109
- _define_property(_assert_this_initialized(_this), "clickHandler", function(event, element) {
110
- controller.enterFullScreen();
111
- });
112
- return _this;
113
- }
114
- return FullScreenButton;
115
- }(_button.default);
116
- _define_property(FullScreenButton, "SVG", _fullScreen.default);
117
- _define_property(FullScreenButton, "defaultProperties", {
118
- className: "full-screen"
119
- });
120
-
121
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3NyYy92aWV3L2J1dHRvbi9mdWxsU2NyZWVuLmpzIl0sInNvdXJjZXNDb250ZW50IjpbIlwidXNlIHN0cmljdFwiO1xuXG5pbXBvcnQgQnV0dG9uIGZyb20gXCIuLi9idXR0b25cIjtcbmltcG9ydCBGdWxsU2NyZWVuU1ZHIGZyb20gXCIuLi9zdmcvZnVsbFNjcmVlblwiO1xuXG5leHBvcnQgZGVmYXVsdCBjbGFzcyBGdWxsU2NyZWVuQnV0dG9uIGV4dGVuZHMgQnV0dG9uIHtcbiAgY2xpY2tIYW5kbGVyID0gKGV2ZW50LCBlbGVtZW50KSA9PiB7XG4gICAgY29udHJvbGxlci5lbnRlckZ1bGxTY3JlZW4oKTtcbiAgfVxuXG4gIHN0YXRpYyBTVkcgPSBGdWxsU2NyZWVuU1ZHO1xuXG4gIHN0YXRpYyBkZWZhdWx0UHJvcGVydGllcyA9IHtcbiAgICBjbGFzc05hbWU6IFwiZnVsbC1zY3JlZW5cIlxuICB9O1xufVxuIl0sIm5hbWVzIjpbIkZ1bGxTY3JlZW5CdXR0b24iLCJjbGlja0hhbmRsZXIiLCJldmVudCIsImVsZW1lbnQiLCJjb250cm9sbGVyIiwiZW50ZXJGdWxsU2NyZWVuIiwiQnV0dG9uIiwiU1ZHIiwiRnVsbFNjcmVlblNWRyIsImRlZmF1bHRQcm9wZXJ0aWVzIiwiY2xhc3NOYW1lIl0sInJhbmdlTWFwcGluZ3MiOiI7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7IiwibWFwcGluZ3MiOiJBQUFBOzs7Ozs7O2VBS3FCQTs7OzZEQUhGO2lFQUNPOzs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7QUFFWCxJQUFBLEFBQU1BLGlDQUFELEFBQUw7Y0FBTUE7K0JBQUFBO2FBQUFBO2dDQUFBQTs7O1FBQ25CQyxrREFBQUEsZ0JBQWUsU0FBQ0MsT0FBT0M7WUFDckJDLFdBQVdDLGVBQWU7UUFDNUI7OztXQUhtQkw7RUFBeUJNLGVBQU07QUFLbEQsaUJBTG1CTixrQkFLWk8sT0FBTUMsbUJBQWE7QUFFMUIsaUJBUG1CUixrQkFPWlMscUJBQW9CO0lBQ3pCQyxXQUFXO0FBQ2IifQ==