highmark-cli 0.0.135 → 0.0.138

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.
@@ -0,0 +1,63 @@
1
+ "use strict";
2
+
3
+ import { PI } from "../constants";
4
+
5
+ export default class RelativePosition {
6
+ constructor(top, left, time, speed, magnitude, direction) {
7
+ this.top = top;
8
+ this.left = left;
9
+ this.time = time;
10
+ this.speed = speed;
11
+ this.magnitude = magnitude;
12
+ this.direction = direction;
13
+ }
14
+
15
+ getTop() {
16
+ return this.top;
17
+ }
18
+
19
+ getLeft() {
20
+ return this.left;
21
+ }
22
+
23
+ getTime() {
24
+ return this.time;
25
+ }
26
+
27
+ getSpeed() {
28
+ return this.speed;
29
+ }
30
+
31
+ getMagnitude() {
32
+ return this.magnitude;
33
+ }
34
+
35
+ getDirection() {
36
+ return this.direction;
37
+ }
38
+
39
+ static fromFirstPositionAndSecondPosition(firstPosition, secondPosition) {
40
+ const position = secondPosition.minus(firstPosition),
41
+ top = position.getTop(),
42
+ left = position.getLeft(),
43
+ time = position.getTime(),
44
+ magnitude = Math.sqrt(top * top + left * left),
45
+ speed = (time === 0) ?
46
+ 0 :
47
+ magnitude / time;
48
+
49
+ let direction;
50
+
51
+ if (left === 0) {
52
+ direction = (top < 0) ?
53
+ +PI / 2 :
54
+ -PI / 2;
55
+ } else {
56
+ direction = Math.atan2(-top, left);
57
+ }
58
+
59
+ const relativePosition = new RelativePosition(top, left, time, speed, magnitude, direction);
60
+
61
+ return relativePosition;
62
+ }
63
+ }
package/src/position.js CHANGED
@@ -1,11 +1,5 @@
1
1
  "use strict";
2
2
 
3
- import { arrayUtilities } from "necessary";
4
-
5
- import { PI, ONE_HUNDRED_AND_EIGHTY } from "./constants";
6
-
7
- const { first } = arrayUtilities;
8
-
9
3
  export default class Position {
10
4
  constructor(top, left, time, identifier) {
11
5
  this.top = top;
@@ -30,28 +24,6 @@ export default class Position {
30
24
  return this.identifier;
31
25
  }
32
26
 
33
- getMagnitude() {
34
- const magnitude = Math.sqrt(this.top * this.top + this.left * this.left);
35
-
36
- return magnitude;
37
- }
38
-
39
- getDirection() {
40
- let direction = 0;
41
-
42
- if (this.left === 0) {
43
- direction = (this.top < 0) ?
44
- +PI / 2 :
45
- -PI / 2;
46
- } else {
47
- direction = Math.atan2(-this.top, this.left);
48
- }
49
-
50
- direction = direction * ONE_HUNDRED_AND_EIGHTY / PI;
51
-
52
- return direction;
53
- }
54
-
55
27
  minus(position) {
56
28
  const positionTop = position.getTop(),
57
29
  positionLeft = position.getLeft(),
@@ -59,7 +31,7 @@ export default class Position {
59
31
  top = this.top - positionTop,
60
32
  left = this.left - positionLeft,
61
33
  time = this.time - positionTime,
62
- identifier = null; ///
34
+ identifier = this.identifier;
63
35
 
64
36
  position = new Position(top, left, time, identifier); ///
65
37
 
@@ -73,33 +45,23 @@ export default class Position {
73
45
  return matches;
74
46
  }
75
47
 
76
- static fromMouseEvent(mouseEvent) {
77
- const { pageX, pageY } = mouseEvent,
48
+ static fromTouch(touch) {
49
+ const { pageX, pageY, identifier } = touch,
78
50
  top = pageY, ///
79
51
  left = pageX, ///
80
52
  time = getTime(),
81
- identifier = null,
82
53
  position = new Position(top, left, time, identifier);
83
54
 
84
55
  return position;
85
56
  }
86
57
 
87
- static fromTouchEvent(touchEvent) {
88
- let position = null;
89
-
90
- const { touches } = touchEvent,
91
- touchesLength = touches.length;
92
-
93
- if (touchesLength === 1) {
94
- const firstTouch = first(touches),
95
- touch = firstTouch, ///
96
- { pageX, pageY, identifier } = touch,
97
- top = pageY,
98
- left = pageX,
99
- time = getTime();
100
-
101
- position = new Position(top, left, time, identifier);
102
- }
58
+ static fromMouseEvent(mouseEvent) {
59
+ const { pageX, pageY } = mouseEvent,
60
+ top = pageY, ///
61
+ left = pageX, ///
62
+ time = getTime(),
63
+ identifier = null,
64
+ position = new Position(top, left, time, identifier);
103
65
 
104
66
  return position;
105
67
  }
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+
3
+ export const VIEW_DIV_SELECTOR = "body > div:not(.loading)"; ///
4
+ export const LOADING_DIV_SELECTOR = "body > div.loading";
5
+ export const VIEW_CHILD_DIVS_SELECTOR = "body > div:not(.loading) div"; ///
package/src/style.js ADDED
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+
3
+ export const menuDivHeight = "256px";
@@ -13,13 +13,18 @@ export function elementsFromDOMElements(domElements, Element) {
13
13
  }
14
14
 
15
15
  export function elementFromDOMElement(domElement, Element) {
16
- const element = Element(); ///
16
+ const element = <Element/>;
17
17
 
18
18
  const { domElement: temporaryDOMElement } = element,
19
19
  { className: classNamesString } = temporaryDOMElement,
20
20
  classNames = classNamesString.split(SINGLE_SPACE);
21
21
 
22
- const { classList } = domElement;
22
+ const { classList } = domElement,
23
+ { childNodes } = temporaryDOMElement;
24
+
25
+ childNodes.forEach((childNode) => {
26
+ domElement.appendChild(childNode);
27
+ });
23
28
 
24
29
  classNames.forEach((className) => {
25
30
  classList.add(className);
@@ -0,0 +1,127 @@
1
+ "use strict";
2
+
3
+ import { arrayUtilities } from "necessary";
4
+
5
+ import Position from "../position";
6
+
7
+ const { clear, filter } = arrayUtilities;
8
+
9
+ export function sortPositions(positionsA, positionsB) {
10
+ const positionAMap = positionsA.reduce((positionAMap, positionA) => {
11
+ const identifier = positionA.getIdentifier();
12
+
13
+ positionAMap[identifier] = positionA;
14
+
15
+ return positionAMap;
16
+ }, {});
17
+
18
+ clear(positionsA);
19
+
20
+ positionsB.forEach((positionB) => {
21
+ const identifier = positionB.getIdentifier(),
22
+ positionA = positionAMap[identifier];
23
+
24
+ positionsA.push(positionA);
25
+ });
26
+ }
27
+
28
+ export function matchPositions(positionsA, positionsB) {
29
+ let positionsMatch = false;
30
+
31
+ const positionsALength = positionsA.length,
32
+ positionsBLength = positionsB.length;
33
+
34
+ if (positionsALength === positionsBLength) {
35
+ const identifiersA = identifiersFromPositions(positionsA),
36
+ identifiersB = identifiersFromPositions(positionsB);
37
+
38
+ identifiersA.sort();
39
+
40
+ identifiersB.sort();
41
+
42
+ const identifiersMatch = identifiersA.every((identifierA, index) => {
43
+ const identifierB = identifiersB[index];
44
+
45
+ if (identifierA === identifierB) {
46
+ return true;
47
+ }
48
+ });
49
+
50
+ positionsMatch = identifiersMatch; ///
51
+ }
52
+
53
+ return positionsMatch;
54
+ }
55
+
56
+ export function filterPositions(positionsA, positionsB) {
57
+ filter(positionsA, (positionA) => {
58
+ const matches = positionsB.some((positionB) => {
59
+ const matches = positionA.match(positionB);
60
+
61
+ if (matches) {
62
+ return true;
63
+ }
64
+ });
65
+
66
+ if (!matches) {
67
+ return true;
68
+ }
69
+ });
70
+ }
71
+
72
+ export function positionsFromMouseEvent(mouseEvent) {
73
+ const position = Position.fromMouseEvent(mouseEvent),
74
+ positions = [
75
+ position
76
+ ];
77
+
78
+ return positions;
79
+ }
80
+
81
+ export function positionsFromTouchEvent(touchEvent, changed = true) {
82
+ let touchesNodeList;
83
+
84
+ if (changed) {
85
+ ({ changedTouches: touchesNodeList } = touchEvent);
86
+ } else {
87
+ ({ touches: touchesNodeList } = touchEvent);
88
+ }
89
+
90
+ const touches = [
91
+ ...touchesNodeList
92
+ ],
93
+ positions = touches.map((touch) => {
94
+ const position = Position.fromTouch(touch);
95
+
96
+ return position;
97
+ });
98
+
99
+ compressPositions(positions);
100
+
101
+ return positions;
102
+ }
103
+
104
+ function compressPositions(positions) {
105
+ const positionMap = positions.reduce((positionMap, position) => {
106
+ const identifier = position.getIdentifier();
107
+
108
+ positionMap[identifier] = position;
109
+
110
+ return positionMap;
111
+ }, {});
112
+
113
+ positions = Object.values(positionMap);
114
+
115
+ return positions;
116
+ }
117
+
118
+ function identifiersFromPositions(positions) {
119
+ const identifiers = positions.map((position) => {
120
+ const identifier = position.getIdentifier();
121
+
122
+ return identifier;
123
+ });
124
+
125
+ return identifiers;
126
+ }
127
+
@@ -4,21 +4,31 @@ import { Element } from "easy";
4
4
 
5
5
  import withStyle from "easy-with-style"; ///
6
6
 
7
- import eventMixins from "../../mixins/event";
8
- import touchMixins from "../../mixins/touch";
9
-
10
7
  class LeafDiv extends Element {
11
- wiggle() {
12
- this.removeClass("wiggle");
13
- this.addClass("wiggle");
8
+ zoom(zoom) {
9
+ const width = `${100/zoom}%`,
10
+ minHeight = `${100/zoom}%`,
11
+ transform = `scale(${zoom})`;
12
+
13
+ const css = {
14
+ width,
15
+ minHeight,
16
+ transform
17
+ };
18
+
19
+ this.css(css);
14
20
  }
15
21
 
16
- didMount() {
17
- this.enableTouch();
22
+ setInitialState() {
23
+ const zoom = 1;
24
+
25
+ this.setState({
26
+ zoom
27
+ });
18
28
  }
19
29
 
20
- willUnmount() {
21
- this.disableTouch();
30
+ initialise() {
31
+ this.setInitialState();
22
32
  }
23
33
 
24
34
  static tagName = "div";
@@ -28,23 +38,10 @@ class LeafDiv extends Element {
28
38
  };
29
39
  }
30
40
 
31
- Object.assign(LeafDiv.prototype, eventMixins);
32
- Object.assign(LeafDiv.prototype, touchMixins);
33
-
34
41
  export default withStyle(LeafDiv)`
35
42
 
36
- width: 100vw;
37
- position: absolute;
38
- min-height: 100vh;
43
+ width: 100%;
44
+ min-height: 100%;
45
+ transform-origin: top left;
39
46
 
40
- @keyframes wiggle {
41
- 0% { transform: translateX(-5px); }
42
- 50% { transform: translateX(5px); }
43
- 100% { transform: translateX(-5px); }
44
- }
45
-
46
- .wiggle {
47
- animation: wiggle 0.5s ease-in-out 1;
48
- }
49
-
50
47
  `;
@@ -0,0 +1,62 @@
1
+ "use strict";
2
+
3
+ import withStyle from "easy-with-style";
4
+
5
+ import { Element } from "easy";
6
+
7
+ import touchMixins from "../../mixins/touch";
8
+
9
+ import { menuDivHeight } from "../../style";
10
+
11
+ class MenuDiv extends Element {
12
+ customTapHandler = (event, element) => {
13
+ alert("MENU DIV TAP!")
14
+ }
15
+
16
+ didMount() {
17
+ this.enableTouch();
18
+
19
+ this.onCustomTap(this.customTapHandler);
20
+ }
21
+
22
+ willUnmount() {
23
+ this.disableTouch();
24
+
25
+ this.offCustomTap(this.customTapHandler);
26
+ }
27
+
28
+ initialise() {
29
+ this.hide();
30
+ }
31
+
32
+ parentContext() {
33
+ const showMenuDiv = this.show.bind(this), ///
34
+ hideMenuDiv = this.hide.bind(this), ///
35
+ isMenuDivDisplayed = this.isDisplayed.bind(this); ///
36
+
37
+ return ({
38
+ showMenuDiv,
39
+ hideMenuDiv,
40
+ isMenuDivDisplayed
41
+ });
42
+ }
43
+
44
+ static tagName = "div";
45
+
46
+ static defaultProperties = {
47
+ className: "menu"
48
+ };
49
+ }
50
+
51
+ Object.assign(MenuDiv.prototype, touchMixins);
52
+
53
+ export default withStyle(MenuDiv)`
54
+
55
+ left: 0;
56
+ width: 100%;
57
+ height: ${menuDivHeight};
58
+ bottom: 0;
59
+ position: fixed;
60
+ background-color: black;
61
+
62
+ `;