dbm 1.1.5 → 1.1.6

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.
@@ -1,3 +1,4 @@
1
1
  export * as select from "./select/index.js";
2
2
  export * as edit from "./edit/index.js";
3
- export * as transform from "./transform/index.js";
3
+ export * as transform from "./transform/index.js";
4
+ export * as interaction from "./interaction/index.js";
@@ -0,0 +1,179 @@
1
+ import Dbm from "../../../index.js";
2
+
3
+ export default class MoveElement extends Dbm.core.BaseObject {
4
+ _construct() {
5
+ super._construct();
6
+
7
+ this._element = null;
8
+ this._startX = 0;
9
+ this._startY = 0;
10
+ this._startXParameter = 0;
11
+ this._startYParameter = 0;
12
+
13
+ this._callback_mouseMoveBound = this._callback_mouseMove.bind(this);
14
+ this._callback_mouseUpBound = this._callback_mouseUp.bind(this);
15
+ this._callback_startDragBound = this._callback_startDrag.bind(this);
16
+
17
+ this.item.requireProperty("element", null);
18
+ Dbm.flow.addUpdateCommand(this.item.properties.element, Dbm.commands.callFunction(this._elementUpdated.bind(this)));
19
+
20
+ let updateXCommand = Dbm.commands.callFunction(this._updateX.bind(this));
21
+ let updateYCommand = Dbm.commands.callFunction(this._updateY.bind(this));
22
+
23
+ let clampXCommand = Dbm.commands.callFunction(this._clampX.bind(this));
24
+ let clampYCommand = Dbm.commands.callFunction(this._clampY.bind(this));
25
+
26
+ this.item.requireProperty("minX", 0);
27
+ Dbm.flow.addUpdateCommand(this.item.properties.minX, updateXCommand);
28
+ Dbm.flow.addUpdateCommand(this.item.properties.minX, clampXCommand);
29
+ this.item.requireProperty("maxX", 0);
30
+ Dbm.flow.addUpdateCommand(this.item.properties.maxX, updateXCommand);
31
+ Dbm.flow.addUpdateCommand(this.item.properties.maxX, clampXCommand);
32
+
33
+ this.item.requireProperty("minY", 0);
34
+ Dbm.flow.addUpdateCommand(this.item.properties.minY, updateYCommand);
35
+ Dbm.flow.addUpdateCommand(this.item.properties.minY, clampYCommand);
36
+ this.item.requireProperty("maxY", 0);
37
+ Dbm.flow.addUpdateCommand(this.item.properties.maxY, updateYCommand);
38
+ Dbm.flow.addUpdateCommand(this.item.properties.maxY, clampYCommand);
39
+
40
+ this.item.requireProperty("xParameter", 0);
41
+ Dbm.flow.addUpdateCommand(this.item.properties.xParameter, updateXCommand);
42
+ this.item.requireProperty("yParameter", 0);
43
+ Dbm.flow.addUpdateCommand(this.item.properties.yParameter, updateYCommand);
44
+
45
+ this.item.requireProperty("scaleX", 1);
46
+ Dbm.flow.addUpdateCommand(this.item.properties.scaleX, updateXCommand);
47
+ this.item.requireProperty("scaleY", 1);
48
+ Dbm.flow.addUpdateCommand(this.item.properties.scaleY, updateYCommand);
49
+
50
+ this.item.requireProperty("invertX", 1);
51
+ this.item.requireProperty("invertY", 1);
52
+
53
+ this.item.requireProperty("x", 0);
54
+ this.item.requireProperty("y", 0);
55
+
56
+ this.item.requireProperty("isDragging", false);
57
+ }
58
+
59
+ _elementUpdated() {
60
+ console.log("_elementUpdated");
61
+
62
+ if(this._element) {
63
+ let element = this._element;
64
+ element.removeEventListener("mousedown", this._callback_startDragBound);
65
+ element.removeEventListener("touchstart", this._callback_startDragBound);
66
+ }
67
+
68
+ if(this.item.element) {
69
+ let element = this.item.element;
70
+ element.addEventListener("mousedown", this._callback_startDragBound);
71
+ element.addEventListener("touchstart", this._callback_startDragBound);
72
+ }
73
+ this._element = this.item.element;
74
+ }
75
+
76
+ _updateX() {
77
+ this.item.x = this.item.xParameter*this.item.scaleX;
78
+ }
79
+
80
+ _clampX() {
81
+ let minX = this.item.minX;
82
+ let maxX = this.item.maxX;
83
+
84
+ this.item.xParameter = Math.max(minX, Math.min(this.item.xParameter, maxX));
85
+ }
86
+
87
+ _clampY() {
88
+ let minY = this.item.minY;
89
+ let maxY = this.item.maxY;
90
+
91
+ this.item.yParameter = Math.max(minY, Math.min(this.item.yParameter, maxY));
92
+ }
93
+
94
+ _updateY() {
95
+ this.item.y = this.item.yParameter*this.item.scaleY;
96
+ }
97
+
98
+
99
+ _startMove(aX, aY) {
100
+ //console.log(aX, aY);
101
+
102
+ this._startXParameter = this.item.xParameter;
103
+ this._startYParameter = this.item.yParameter;
104
+ this._startX = aX;
105
+ this._startY = aY;
106
+ }
107
+
108
+ _updateMove(aX, aY) {
109
+ console.log("_updateMove");
110
+ //console.log(aX, aY);
111
+
112
+ let x = this._startXParameter + this.item.invertX*(aX-this._startX)/this.item.scaleX;
113
+ let y = this._startYParameter + this.item.invertY*(aY-this._startY)/this.item.scaleY;
114
+
115
+ let minX = this.item.minX;
116
+ let maxX = this.item.maxX;
117
+
118
+ let minY = this.item.minY;
119
+ let maxY = this.item.maxY;
120
+
121
+ this.item.xParameter = Math.max(minX, Math.min(x, maxX));
122
+ this.item.yParameter = Math.max(minY, Math.min(y, maxY));
123
+
124
+ console.log(this.item.xParameter);
125
+ console.log(this.item.yParameter);
126
+ }
127
+
128
+ _callback_mouseUp(aEvent) {
129
+ console.log("_callback_mouseUp");
130
+ //console.log(aEvent);
131
+
132
+ if(aEvent.type === "touchend") {
133
+ this._updateMove(aEvent.touches[0].pageX, aEvent.touches[0].pageY);
134
+ }
135
+ else {
136
+ this._updateMove(aEvent.pageX, aEvent.pageY);
137
+ }
138
+
139
+ document.removeEventListener("mousemove", this._callback_mouseMoveBound, false);
140
+ document.removeEventListener("mouseup", this._callback_mouseUpBound, false);
141
+
142
+ document.removeEventListener("touchmove", this._callback_mouseMoveBound, false);
143
+ document.removeEventListener("touchup", this._callback_mouseUpBound, false);
144
+
145
+ this.item.isDragging = false;
146
+ }
147
+
148
+ _callback_mouseMove(aEvent) {
149
+ console.log("_callback_mouseMove");
150
+ //console.log(aEvent);
151
+
152
+ if(aEvent.type === "touchmove") {
153
+ this._updateMove(aEvent.touches[0].pageX, aEvent.touches[0].pageY);
154
+ }
155
+ else {
156
+ this._updateMove(aEvent.pageX, aEvent.pageY);
157
+ }
158
+ }
159
+
160
+ _callback_startDrag(aEvent) {
161
+ console.log("_callback_startDrag");
162
+ //console.log(aEvent, aEvent.type);
163
+
164
+ if(aEvent.type === "touchstart") {
165
+ this._startMove(aEvent.touches[0].pageX, aEvent.touches[0].pageY);
166
+ }
167
+ else {
168
+ this._startMove(aEvent.pageX, aEvent.pageY);
169
+ }
170
+
171
+ document.addEventListener("mousemove", this._callback_mouseMoveBound, false);
172
+ document.addEventListener("mouseup", this._callback_mouseUpBound, false);
173
+
174
+ document.addEventListener("touchmove", this._callback_mouseMoveBound, false);
175
+ document.addEventListener("touchup", this._callback_mouseUpBound, false);
176
+
177
+ this.item.isDragging = true;
178
+ }
179
+ }
@@ -0,0 +1 @@
1
+ export {default as MoveElement} from "./MoveElement.js";
@@ -11,7 +11,7 @@ export default class ElementPosition extends Dbm.flow.FlowUpdateFunction {
11
11
 
12
12
  this.output.register("screenX", NaN);
13
13
  this.output.register("screenY", NaN);
14
-
14
+
15
15
  this.output.register("parameterX", NaN);
16
16
  this.output.register("parameterY", NaN);
17
17
 
@@ -0,0 +1,68 @@
1
+ import Dbm from "../../../index.js";
2
+
3
+ export default class PoisitonedItems extends Dbm.flow.FlowUpdateFunction {
4
+
5
+ _construct() {
6
+ super._construct();
7
+
8
+ this.input.register("elementWidth", 0);
9
+ this.input.register("itemWidth", 0);
10
+ this.input.register("itemSpacing", 0);
11
+ this.input.register("padding", 0);
12
+ this.input.register("numberOfItems", 0);
13
+
14
+ this.output.register("startPosition", 0);
15
+ this.output.register("parameterLength", 0);
16
+
17
+ this.output.register("minParameter", 0);
18
+ this.output.register("maxParameter", 0);
19
+
20
+ /*
21
+ let parameter = minParameter;
22
+
23
+ let x = padding+startPosition-parameter*parameterLength;
24
+
25
+ console.log(minParameter, maxParameter, fullWidth, startPosition);
26
+ console.log(x);
27
+
28
+ parameter = maxParameter;
29
+
30
+ x = padding+startPosition-parameter*parameterLength;
31
+
32
+ console.log(x);
33
+ */
34
+ }
35
+
36
+ _update() {
37
+ //console.log("_update");
38
+
39
+ let elementWidth = this.input.elementWidth;
40
+ let itemWidth = this.input.itemWidth;
41
+ let itemSpacing = this.input.itemSpacing;
42
+ let padding = this.input.padding;
43
+
44
+ let visualWidth = elementWidth-2*padding;
45
+ let startPosition = (visualWidth-itemWidth)/2;
46
+
47
+ let parameterLength = itemWidth+itemSpacing;
48
+ let fullWidth = this.input.numberOfItems*parameterLength-itemSpacing;
49
+
50
+ let minParameter = 0;
51
+ let maxParameter = 0;
52
+
53
+ if(fullWidth > visualWidth) {
54
+ minParameter = startPosition/parameterLength;
55
+ maxParameter = (fullWidth-(visualWidth-startPosition))/parameterLength;
56
+ }
57
+ else {
58
+ startPosition = (visualWidth-fullWidth)/2;
59
+ parameterLength = 0;
60
+ }
61
+
62
+ this.output.startPosition = startPosition;
63
+ this.output.parameterLength = parameterLength;
64
+
65
+ this.output.minParameter = minParameter;
66
+ this.output.maxParameter = maxParameter;
67
+ }
68
+ }
@@ -11,6 +11,7 @@ export {default as Any} from "./Any.js";
11
11
  export {default as AllAtValue} from "./AllAtValue.js";
12
12
  export {default as WhenMatched} from "./WhenMatched.js";
13
13
  export {default as Invert} from "./Invert.js";
14
+ export {default as PositionedItems} from "./PositionedItems.js";
14
15
 
15
16
  export let subtract = function(aInput1 = 0, aInput2 = 0) {
16
17
  let updateFunction = new Dbm.flow.updatefunctions.logic.Subtraction();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dbm",
3
- "version": "1.1.5",
3
+ "version": "1.1.6",
4
4
  "main": "index.js",
5
5
  "type": "module",
6
6
  "scripts": {},
@@ -112,6 +112,10 @@ export default class BaseObject extends Component {
112
112
  return refToProperty;
113
113
  }
114
114
 
115
+ componentWillUnmount() {
116
+
117
+ }
118
+
115
119
  render() {
116
120
  return this._renderMainElement();
117
121
  }
@@ -4,7 +4,8 @@ export default class MetaPixelTracker extends Dbm.core.BaseObject {
4
4
  _construct() {
5
5
  super._construct();
6
6
 
7
- this.item.requireProperty("pixelId")
7
+ this._isStarted = false;
8
+ this.item.requireProperty("pixelId");
8
9
  }
9
10
 
10
11
  _setupFunction() {
@@ -45,6 +46,7 @@ export default class MetaPixelTracker extends Dbm.core.BaseObject {
45
46
 
46
47
  startMarketingTracking() {
47
48
 
49
+ this._isStarted = true;
48
50
  this._setupFunction();
49
51
  Dbm.loading.loadScript("https://connect.facebook.net/en_US/fbevents.js");
50
52
 
@@ -85,6 +87,8 @@ export default class MetaPixelTracker extends Dbm.core.BaseObject {
85
87
  console.log("trackEvent");
86
88
  console.log(aEventName, aData);
87
89
 
90
+ if(!this._isStarted) return;
91
+
88
92
  if(aEventName === "Purchase") {
89
93
  window.fbq('track', 'Purchase', this._convertGooogleAnalyctisData(aData), {eventID: aData.transaction_id});
90
94
  }
@@ -103,10 +107,12 @@ export default class MetaPixelTracker extends Dbm.core.BaseObject {
103
107
  }
104
108
 
105
109
  trackCurrentPage() {
110
+ if(!this._isStarted) return;
106
111
  window.fbq("track", "PageView");
107
112
  }
108
113
 
109
114
  trackPage(aUrl) {
115
+ if(!this._isStarted) return;
110
116
  window.fbq("track", "PageView");
111
117
  }
112
118
  }
@@ -0,0 +1,58 @@
1
+ import Dbm from "../index.js";
2
+
3
+ export default class TagManagerTracker extends Dbm.core.BaseObject {
4
+ _construct() {
5
+ super._construct();
6
+
7
+ this.item.requireProperty("tagManagerId");
8
+ this.item.requireProperty("customDataLayerName");
9
+
10
+ }
11
+
12
+ loadTagManager() {
13
+
14
+ let id = this.item.tagManagerId;
15
+
16
+ let url = "https://www.googletagmanager.com/gtm.js?id="+id;
17
+ if(this.item.customDataLayerName) {
18
+ url += "&l=" + this.customDataLayerName;
19
+ }
20
+ Dbm.loading.loadScript(url);
21
+
22
+ return this;
23
+ }
24
+
25
+ startTracking() {
26
+
27
+ }
28
+
29
+ startStatisticsTracking() {
30
+ console.log("TagManagerTracker::startStatisticsTracking");
31
+ this.loadTagManager();
32
+
33
+ return this;
34
+ }
35
+
36
+ startMarketingTracking() {
37
+
38
+ this.loadTagManager();
39
+
40
+ return this;
41
+ }
42
+
43
+ stopTracking() {
44
+
45
+ }
46
+
47
+ trackEvent(aEventName, aData) {
48
+
49
+ }
50
+
51
+ trackCurrentPage() {
52
+
53
+ }
54
+
55
+ trackPage(aUrl) {
56
+
57
+ }
58
+ }
package/tracking/index.js CHANGED
@@ -3,6 +3,7 @@ import Dbm from "../index.js";
3
3
  export {default as Controller} from "./Controller.js";
4
4
  export {default as DataLayerTracker} from "./DataLayerTracker.js";
5
5
  export {default as MetaPixelTracker} from "./MetaPixelTracker.js";
6
+ export {default as TagManagerTracker} from "./TagManagerTracker.js";
6
7
 
7
8
  export const setup = function() {
8
9
 
@@ -24,4 +25,11 @@ export const addMetaPixel = function(aPixelId) {
24
25
 
25
26
  export const setCurrency = function(aCurrency) {
26
27
  Dbm.getInstance().repository.getItem("trackingController").currency = aCurrency;
28
+ }
29
+
30
+ export const addTagManagerTracking = function(aId) {
31
+ console.log("addTagManagerTracking");
32
+ let tracker = new Dbm.tracking.TagManagerTracker();
33
+ tracker.item.tagManagerId = aId;
34
+ Dbm.getInstance().repository.getItem("trackingController").controller.addTracker(tracker.item);
27
35
  }