dbm 1.1.16 → 1.1.18

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,18 @@
1
+ import Dbm from "../index.js";
2
+ import CommandBaseObject from "./CommandBaseObject.js"
3
+
4
+ export default class TrackEvent extends CommandBaseObject {
5
+ _construct() {
6
+ super._construct();
7
+
8
+ this.item.setValue("eventName", null);
9
+ this.item.setValue("additionalData", {});
10
+ }
11
+
12
+ perform(aFromObject, aData) {
13
+ let trackingController = Dbm.getInstance().repository.getItem("trackingController").controller;
14
+
15
+ trackingController.trackEvent(this.item.eventName, this.item.additionalData);
16
+
17
+ }
18
+ }
package/commands/index.js CHANGED
@@ -4,6 +4,7 @@ export {default as CommandBaseObject} from "./CommandBaseObject.js";
4
4
  export {default as CallFunction} from "./CallFunction.js";
5
5
  export {default as SetProperty} from "./SetProperty.js";
6
6
  export {default as ResolvePromise} from "./ResolvePromise.js";
7
+ export {default as TrackEvent} from "./TrackEvent.js";
7
8
 
8
9
 
9
10
  export const callScopedFunction = function(aScopeObject, aFunction, aArguments = []) {
@@ -38,6 +39,14 @@ export const setProperty = function(aProperty, aValue) {
38
39
  return newCommand;
39
40
  }
40
41
 
42
+ export const trackEvent = function(aEventName, aAdditionalData = {}) {
43
+ let newCommand = new Dbm.commands.TrackEvent();
44
+ newCommand.item.setValue("eventName", aEventName);
45
+ newCommand.item.setValue("additionalData", aAdditionalData);
46
+
47
+ return newCommand;
48
+ }
49
+
41
50
  export const performCommands = function(aCommands, aFromObject = null, aEventData = null) {
42
51
  let currentArray = aCommands;
43
52
  let currentArrayLength = currentArray.length;
@@ -48,6 +48,12 @@ export default class FlowProperty extends Dbm.flow.FlowBaseObject {
48
48
  return this;
49
49
  }
50
50
 
51
+ addAddionalAnimation(aFromValue, aToValue, aTime = 0.5, aDelay = 0, aEasing = null) {
52
+ Dbm.getInstance().repository.getItem("propertyUpdater").controller.addPropertyAnimation(this, aFromValue, aToValue, aTime, aDelay, aEasing);
53
+
54
+ return this;
55
+ }
56
+
51
57
  delayValue(aToValue, aDelay = 0) {
52
58
  Dbm.getInstance().repository.getItem("propertyUpdater").controller.delayUpdateProperty(this, aToValue, aDelay);
53
59
 
@@ -24,21 +24,57 @@ export default class ElementPosition extends Dbm.flow.FlowUpdateFunction {
24
24
  start() {
25
25
  window.addEventListener("resize", this._callback_scrollBound, false);
26
26
  window.addEventListener("scroll", this._callback_scrollBound, false);
27
+ this.output.properties.prepare.startUpdating();
27
28
 
28
29
  return this;
29
30
  }
30
31
 
31
32
  _update() {
32
- //console.log("_update");
33
+ console.log("_update");
33
34
 
34
35
  let element = this.input.element;
35
36
 
37
+ console.log(element, this.input.prepareX, this.input.prepareY);
38
+
36
39
  if(element) {
37
- console.log(element);
40
+
38
41
  //this.output.width = element.clientWidth;
39
42
  //this.output.height = element.clientHeight;
40
43
 
41
- //METODO
44
+ //let thePageXOffset = window.pageXOffset;
45
+ let theInnerWidth = window.innerWidth;
46
+ //let thePageYOffset = window.pageYOffset;
47
+ let theInnerHeight = window.innerHeight;
48
+
49
+ //console.log(theInnerWidth, theInnerHeight);
50
+
51
+ let rect = element.getBoundingClientRect();
52
+ //console.log(rect);
53
+
54
+ let prepareX = this.input.prepareX;
55
+ let prepareY = this.input.prepareY;
56
+
57
+ let screenX = rect.x;
58
+ let screenY = rect.y;
59
+
60
+ let elementWidth = rect.width;
61
+ let elementHeight = rect.height;
62
+
63
+ let visible = ((screenX < theInnerWidth) && (screenX+elementWidth > 0)) && ((screenY < theInnerHeight) && (screenY+elementHeight > 0));
64
+ let prepare = ((screenX-prepareX < theInnerWidth) && (screenX+elementWidth+prepareX > 0)) && ((screenY-prepareY < theInnerHeight) && (screenY+elementHeight+prepareY > 0));
65
+
66
+ let parameterX = (screenX+elementWidth)/(theInnerWidth+elementWidth);
67
+ let parameterY = (screenY+elementHeight)/(theInnerHeight+elementHeight);
68
+
69
+ this.output.screenX = screenX;
70
+ this.output.screenY = screenY;
71
+
72
+ this.output.parameterX = parameterX;
73
+ this.output.parameterY = parameterY;
74
+
75
+ this.output.visible = visible;
76
+ this.output.prepare = prepare;
77
+
42
78
  }
43
79
  else {
44
80
  //this.output.width = 0;
@@ -49,7 +85,7 @@ export default class ElementPosition extends Dbm.flow.FlowUpdateFunction {
49
85
  }
50
86
 
51
87
  _callback_scroll(aEvent) {
52
- //console.log("_callback_scroll");
88
+ console.log("_callback_scroll");
53
89
 
54
90
  let element = this.input.element;
55
91
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dbm",
3
- "version": "1.1.16",
3
+ "version": "1.1.18",
4
4
  "main": "index.js",
5
5
  "type": "module",
6
6
  "scripts": {},
@@ -105,8 +105,10 @@ export default class SiteNavigation extends Dbm.core.BaseObject {
105
105
  if(aEvent.defaultPrevented) {
106
106
  return true;
107
107
  }
108
+ let shouldSkip = false;
109
+
108
110
  if(this._hasSpecialKey(aEvent)) {
109
- return true;
111
+ shouldSkip = true;
110
112
  }
111
113
 
112
114
  let link = null;
@@ -123,7 +125,7 @@ export default class SiteNavigation extends Dbm.core.BaseObject {
123
125
  link = hrefAttribute.toString();
124
126
  let hardNavigation = currentNode.getAttribute("data-not-spa-link");
125
127
  if(hardNavigation) {
126
- return true;
128
+ shouldSkip = true;
127
129
  }
128
130
  break;
129
131
  }
@@ -134,6 +136,21 @@ export default class SiteNavigation extends Dbm.core.BaseObject {
134
136
  if(!link) {
135
137
  return true;
136
138
  }
139
+
140
+ let trackingController = Dbm.getInstance().repository.getItem("trackingController").controller;
141
+ if(trackingController) {
142
+ if(link.indexOf("mailto:") === 0) {
143
+ trackingController.trackEvent("link / email", {});
144
+ }
145
+ else if(link.indexOf("tel:") === 0) {
146
+ trackingController.trackEvent("link / phone", {});
147
+ }
148
+ }
149
+
150
+ if(shouldSkip) {
151
+ return true;
152
+ }
153
+
137
154
  if(link.indexOf("#") === 0) {
138
155
  return true;
139
156
  }
@@ -122,6 +122,26 @@ export default class PropertyUpdater extends Dbm.core.BaseObject {
122
122
  return this;
123
123
  }
124
124
 
125
+ addPropertyAnimation(aProperty, aFromValue, aToValue, aTime, aDelay = 0, aEasing = null) {
126
+
127
+ let tweenObject = {"envelope": aFromValue};
128
+ if(!aEasing) {
129
+ aEasing = Easing.Quadratic.Out;
130
+ }
131
+
132
+ let tween = new Tween(tweenObject).to({"envelope": aToValue}, 1000*aTime).delay(1000*aDelay).easing(aEasing).onUpdate(function(aData) {
133
+ aProperty.value = aData.envelope;
134
+ }).onComplete(() => {this.removeTween(tween)}).start();
135
+
136
+ let tweens = [].concat(this.item.tweens);
137
+ tweens.push(tween);
138
+ this.item.tweens = tweens;
139
+
140
+ this._currentTweens.set(aProperty, tween);
141
+
142
+ return this;
143
+ }
144
+
125
145
  delayUpdateProperty(aProperty, aToValue, aDelay = 0) {
126
146
  if(this._currentTweens.has(aProperty)) {
127
147
  this._currentTweens.get(aProperty).stop();