targetj 1.0.65 → 1.0.67

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.
package/Exports.js CHANGED
@@ -4,3 +4,4 @@ export * from "./src/SearchUtil.js"
4
4
  export * from "./src/TargetUtil.js"
5
5
  export * from "./src/TUtil.js"
6
6
  export * from "./src/Browser.js"
7
+ export * from "./src/Bracket.js"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "targetj",
3
- "version": "1.0.65",
3
+ "version": "1.0.67",
4
4
  "keywords": [
5
5
  "targetj"
6
6
  ],
package/src/$Dom.js CHANGED
@@ -50,12 +50,21 @@ $Dom.prototype.attr = function(name, value) {
50
50
  }
51
51
  };
52
52
 
53
- $Dom.prototype.opacity = function(opacity) {
54
- if (TUtil.isDefined(opacity)) {
55
- this.element.style.opacity = opacity;
53
+ $Dom.prototype.value = function(value) {
54
+ if (!this.element) return;
55
+
56
+ if (TUtil.isDefined(value)) {
57
+ this.element.value = value;
56
58
  } else {
57
- return this.element.style.opacity;
58
- }
59
+ return this.element.value;
60
+ }
61
+ };
62
+
63
+ $Dom.prototype.select = function() {
64
+ if (!this.element || typeof this.element.select !== 'function') return;
65
+
66
+
67
+ this.element.select();
59
68
  };
60
69
 
61
70
  $Dom.prototype.width = function(width) {
@@ -74,14 +83,6 @@ $Dom.prototype.height = function(height) {
74
83
  }
75
84
  };
76
85
 
77
- $Dom.prototype.zIndex = function(zIndex) {
78
- if (TUtil.isDefined(zIndex)) {
79
- this.element.style.zIndex = zIndex;
80
- }
81
-
82
- return this.element.style.zIndex;
83
- };
84
-
85
86
  $Dom.prototype.css = function(css) {
86
87
  if (TUtil.isDefined(css)) {
87
88
  this.attr('class', css);
@@ -106,35 +107,31 @@ $Dom.prototype.setStyleByMap = function(attrMap) {
106
107
  case 'height':
107
108
  self.height(value);
108
109
  break;
109
-
110
- case 'zIndex':
111
- self.zIndex(value);
112
- break;
113
-
114
- case 'opacity':
115
- self.opacity(value);
116
- break;
117
110
 
118
111
  default:
119
- self.setStyle(key, value);
112
+ self.style(key, value);
120
113
  }
121
114
  });
122
115
  };
123
116
 
124
- $Dom.prototype.setStyle = function(name, value) {
125
- this.element.style[name] = value;
126
- };
127
-
128
- $Dom.prototype.getStyle = function(name) {
129
- return this.element.style[name];
117
+ $Dom.prototype.style = function(name, value) {
118
+ if (TUtil.isDefined(value)) {
119
+ this.element.style[name] = value;
120
+ } else {
121
+ return this.element.style[name];
122
+ }
130
123
  };
131
124
 
132
125
  $Dom.prototype.getStyleValue = function(name) {
133
- var styleValue = this.getStyle(name);
126
+ var styleValue = this.style(name);
134
127
  var numericValue = TUtil.isDefined(styleValue) ? styleValue.replace(/[^-\d.]/g, '') : 0;
135
128
  return parseFloat(numericValue);
136
129
  };
137
130
 
131
+ $Dom.prototype.getBoundingClientRect = function() {
132
+ return this.element.getBoundingClientRect();
133
+ };
134
+
138
135
  $Dom.prototype.parent = function() {
139
136
  return this.element ? this.element.parentElement : null;
140
137
  };
package/src/Bracket.js CHANGED
@@ -7,7 +7,7 @@ function Bracket(parent) {
7
7
 
8
8
  var tm = new TModel("BI", {
9
9
  canHaveDom: false,
10
- outerXEast: 0
10
+ outerXEast: 0
11
11
  });
12
12
 
13
13
  tm.parent = parent;
@@ -43,6 +43,17 @@ function Bracket(parent) {
43
43
  return this.getRealParent().getScrollLeft();
44
44
  };
45
45
 
46
+ tm.getBoundingRect = function() {
47
+ this.initParents();
48
+ return TUtil.getBoundingRect(this.getRealParent());
49
+ };
50
+
51
+ tm.calculateAbsolutePosition = function(x, y) {
52
+ var rect = this.getBoundingRect();
53
+ this.absX = rect.left + x;
54
+ this.absY = rect.top + y;
55
+ };
56
+
46
57
  tm.isVisible = function () {
47
58
  return this.yVisible;
48
59
  };
@@ -140,7 +140,6 @@ EventListener.prototype.handleEvent = function (event) {
140
140
  var lastEvent = this.eventQueue.length > 0 ? this.eventQueue[this.eventQueue.length - 1] : null;
141
141
 
142
142
  if (lastEvent) {
143
-
144
143
  var lastEventItem = lastEvent.eventItem;
145
144
  var rate = now - lastEvent.timeStamp;
146
145
 
@@ -237,6 +236,10 @@ EventListener.prototype.findEventHandlers = function(tmodel) {
237
236
  var scrollTopHandler = tmodel ? SearchUtil.findFirstScrollTopHandler(tmodel) : null;
238
237
  var pinchHandler = tmodel ? SearchUtil.findFirstPinchHandler(tmodel) : null;
239
238
 
239
+ if (this.currentHandlers.scrollLeft !== scrollLeftHandler || this.currentHandlers.scrollTop !== scrollTopHandler) {
240
+ this.clearTouch();
241
+ }
242
+
240
243
  this.currentHandlers.touch = touchHandler;
241
244
  this.currentHandlers.scrollLeft = scrollLeftHandler;
242
245
  this.currentHandlers.scrollTop = scrollTopHandler;
@@ -320,6 +323,34 @@ EventListener.prototype.resetEventsOnTimeout = function () {
320
323
 
321
324
  };
322
325
 
326
+ EventListener.prototype.deltaX = function() {
327
+ return this.currentTouch.deltaX;
328
+ };
329
+
330
+ EventListener.prototype.deltaY = function() {
331
+ return this.currentTouch.deltaY;
332
+ };
333
+
334
+ EventListener.prototype.pinchDelta = function() {
335
+ return this.currentTouch.pinchDelta;
336
+ };
337
+
338
+ EventListener.prototype.dir = function() {
339
+ return this.currentTouch.dir;
340
+ };
341
+
342
+ EventListener.prototype.getScrollLeftHandler = function() {
343
+ return this.currentHandlers.scrollLeft;
344
+ };
345
+
346
+ EventListener.prototype.getScrollTopHandler = function() {
347
+ return this.currentHandlers.scrollTop;
348
+ };
349
+
350
+ EventListener.prototype.getPinchHandler = function() {
351
+ return this.currentHandlers.pinch;
352
+ };
353
+
323
354
  EventListener.prototype.getTouchHandler = function() {
324
355
  return this.currentHandlers.touch;
325
356
  };
@@ -1,7 +1,7 @@
1
1
  import { Bracket } from "./Bracket.js";
2
2
  import { TUtil } from "./TUtil.js";
3
3
  import { TargetUtil } from "./TargetUtil.js";
4
- import { tapp } from "./App.js";
4
+ import { tapp, getEvents, getScreenWidth, getScreenHeight } from "./App.js";
5
5
  import { browser } from "./Browser.js";
6
6
 
7
7
  function LocationManager() {
@@ -10,6 +10,10 @@ function LocationManager() {
10
10
 
11
11
  this.bracketThreshold = 6;
12
12
  this.locationCount = [];
13
+
14
+ this.screenWidth = getScreenWidth();
15
+ this.screenHeight = getScreenHeight();
16
+ this.resizeFlag = false;
13
17
  }
14
18
 
15
19
  LocationManager.prototype.calculateAll = function() {
@@ -17,7 +21,14 @@ LocationManager.prototype.calculateAll = function() {
17
21
  this.hasLocationMap = {};
18
22
  this.locationCount.length = 0;
19
23
  this.startTime = browser.now();
24
+ this.resizeFlag = false;
20
25
 
26
+ if (this.screenWidth !== getScreenWidth() || this.screenHeight !== getScreenHeight()) {
27
+ this.resizeFlag = true;
28
+ this.screenWidth = getScreenWidth();
29
+ this.screenHeight = getScreenHeight();
30
+ }
31
+
21
32
  this.calculate();
22
33
  };
23
34
 
@@ -43,7 +54,7 @@ LocationManager.prototype.isProlificContainer = function(container) {
43
54
  LocationManager.prototype.calculateContainer = function(container) {
44
55
  var allChildren = this.getChildren(container);
45
56
 
46
- var viewport = container.createViewport();
57
+ var viewport = container.createViewport();
47
58
  container.resetVisibleList();
48
59
 
49
60
  var i = 0, length = allChildren.length;
@@ -62,6 +73,7 @@ LocationManager.prototype.calculateContainer = function(container) {
62
73
 
63
74
  viewport.setCurrentChild(child);
64
75
  child.setLocation(viewport);
76
+ child.calculateAbsolutePosition(child.x, child.y);
65
77
 
66
78
  innerXEast = TUtil.isDefined(container.getValue('innerXEast')) ? container.getValue('innerXEast') : container.getInnerXEast();
67
79
  outerXEast = TUtil.isDefined(child.getValue('outerXEast')) ? child.getValue('outerXEast') : child.getOuterXEast();
@@ -72,27 +84,31 @@ LocationManager.prototype.calculateContainer = function(container) {
72
84
  } else {
73
85
  child.setLocation(viewport);
74
86
  }
75
-
87
+
76
88
  if (child.isIncluded() && !this.hasLocationMap[child.oid]) {
77
89
  this.addToLocationList(child);
78
90
  }
79
91
 
80
92
  if (!child.targetUpdatingMap.x) {
81
- if (TUtil.isDefined(child.targets.x)) {
82
- //tapp.targetManager.setTargetValue(child, 'x');
93
+ if (child.isTargetEnabled('x')) {
94
+ TargetUtil.assignValueArray(child, 'x');
95
+ tapp.targetManager.setJustActualValue(child, 'x');
83
96
  } else if (!TUtil.isDefined(child.targetValues.x)) {
84
97
  child.setValue('x', child.x);
85
98
  }
86
99
  }
87
100
 
88
101
  if (!child.targetUpdatingMap.y) {
89
- if (TUtil.isDefined(child.targets.y)) {
90
- //tapp.targetManager.setTargetValue(child, 'y');
102
+ if (child.isTargetEnabled('y')) {
103
+ TargetUtil.assignValueArray(child, 'y');
104
+ tapp.targetManager.setJustActualValue(child, 'y');
91
105
  } else if (!TUtil.isDefined(child.targetValues.y)) {
92
106
  child.setValue('y', child.y);
93
107
  }
94
108
  }
95
-
109
+
110
+ child.calculateAbsolutePosition(child.getX(), child.getY());
111
+
96
112
  viewport.isVisible(child);
97
113
 
98
114
  child.addToParentVisibleList();
@@ -119,15 +135,15 @@ LocationManager.prototype.calculateContainer = function(container) {
119
135
  }
120
136
  }
121
137
 
122
- if (child.getHeight() !== childLastHeight && tapp.events.isScrollTopHandler(child.getParent())
123
- && tapp.events.currentTouch.dir === 'up') {
138
+ if (child.getHeight() !== childLastHeight && getEvents().isScrollTopHandler(child.getParent())
139
+ && getEvents().dir() === 'up') {
124
140
  this.calculateContainer(child);
125
141
  }
126
142
 
127
143
  if (TUtil.isNumber(child.getValue('appendNewLine'))) {
128
144
  viewport.appendNewLine();
129
145
  } else {
130
- viewport.nextLocation();
146
+ viewport.nextLocation();
131
147
  }
132
148
  }
133
149
 
@@ -137,12 +153,23 @@ LocationManager.prototype.calculateContainer = function(container) {
137
153
  viewport.calcContentWidthHeight();
138
154
  };
139
155
 
140
- LocationManager.prototype.calculateTargets = function(tmodel) {
156
+ LocationManager.prototype.calculateTargets = function(tmodel) {
157
+ if (this.resizeFlag && Array.isArray(tmodel.getValue('onResize'))) {
158
+ tmodel.getValue('onResize').forEach(function(key) {
159
+ if (tmodel.targets[key] && typeof tmodel.targets[key] !== 'number' && tmodel.targetValues[key] && !tmodel.isTargetActive(key)) {
160
+ tmodel.activeTargetMap[key] = true;
161
+ tmodel.targetValues[key].status = '';
162
+ }
163
+ });
164
+ }
165
+
141
166
  tapp.targetManager.setTargetValues(tmodel, Object.keys(tmodel.activeTargetMap));
142
167
  tapp.targetManager.setActualValues(tmodel);
143
-
144
- if ((!TUtil.isDefined(tmodel.targetValues.width) || tmodel.getTargetValue('widthFromDom')) && tmodel.hasDom()) TargetUtil.setWidthFromDom(tmodel);
145
- if ((!TUtil.isDefined(tmodel.targetValues.height) || tmodel.getTargetValue('heightFromDom')) && tmodel.hasDom()) TargetUtil.setHeightFromDom(tmodel);
168
+
169
+ if (tmodel.hasDom()) {
170
+ if ((!TUtil.isDefined(tmodel.targetValues.width) && !TUtil.isDefined(tmodel.targets.width)) || tmodel.getTargetValue('widthFromDom')) TargetUtil.setWidthFromDom(tmodel);
171
+ if ((!TUtil.isDefined(tmodel.targetValues.height) && !TUtil.isDefined(tmodel.targets.height)) || tmodel.getTargetValue('heightFromDom')) TargetUtil.setHeightFromDom(tmodel);
172
+ }
146
173
  };
147
174
 
148
175
  LocationManager.prototype.addToLocationList = function(child) {
package/src/SearchUtil.js CHANGED
@@ -35,7 +35,7 @@ SearchUtil.findEventHandler = function(tmodel, eventName) {
35
35
  }
36
36
  };
37
37
 
38
- SearchUtil.findParentWithType = function(child, type) {
38
+ SearchUtil.findParentByType = function(child, type) {
39
39
  var parent;
40
40
 
41
41
  function search() {
@@ -61,7 +61,7 @@ SearchUtil.findParentWithType = function(child, type) {
61
61
  return SearchUtil.foundParentWithType[indexKey];
62
62
  };
63
63
 
64
- SearchUtil.findParentWithTarget = function(child, targetName) {
64
+ SearchUtil.findParentByTarget = function(child, targetName) {
65
65
  var parent;
66
66
 
67
67
  function search() {
package/src/TModel.js CHANGED
@@ -16,12 +16,13 @@ function TModel(type, targets) {
16
16
  this.type = type ? type : 'blank';
17
17
  this.targets = Object.assign({}, targets);
18
18
  this.activeTargetMap = {};
19
- this.resetActiveTargetMap();
19
+ this.styleTargets = [];
20
+ this.initTargets();
20
21
 
21
22
  var uniqueId = App.getOid(this.type);
22
23
  this.oid = uniqueId.oid;
23
24
  this.oidNum = uniqueId.num;
24
-
25
+
25
26
  this.targetValues = {};
26
27
 
27
28
  this.actualValues = {
@@ -58,7 +59,8 @@ function TModel(type, targets) {
58
59
  canBeBracketed: true,
59
60
  isDomDeletable: true,
60
61
  calculateChildren: undefined,
61
- isVisible: undefined
62
+ isVisible: undefined,
63
+ onResize: undefined
62
64
  };
63
65
 
64
66
  this.targetUpdatingMap = {};
@@ -87,8 +89,6 @@ function TModel(type, targets) {
87
89
  this.y = 0;
88
90
  this.absX = 0;
89
91
  this.absY = 0;
90
- this.deepY = 0;
91
- this.deepX = 0;
92
92
 
93
93
  this.inFlowVisibles = [];
94
94
 
@@ -108,20 +108,26 @@ TModel.prototype.getDomParent = function() {
108
108
  };
109
109
 
110
110
  TModel.prototype.getDomHolder = function() {
111
- return this.actualValues.domHolder ? this.actualValues.domHolder : this.getDomParent() ? this.getDomParent().$dom : SearchUtil.findParentWithTarget(this, 'domHolder') ? SearchUtil.findParentWithTarget(this, 'domHolder').$dom : null;
111
+ return this.actualValues.domHolder ? this.actualValues.domHolder : this.getDomParent() ? this.getDomParent().$dom : SearchUtil.findParentByTarget(this, 'domHolder') ? SearchUtil.findParentByTarget(this, 'domHolder').$dom : null;
112
112
  };
113
113
 
114
- TModel.prototype.resetActiveTargetMap = function() {
114
+ TModel.prototype.addToStyleTargets = function(key) {
115
+ if (TargetUtil.styleTargetMap[key] && !this.styleTargets.includes(key)) {
116
+ this.styleTargets.push(key);
117
+ }
118
+ };
119
+
120
+ TModel.prototype.initTargets = function() {
115
121
  var self = this;
116
122
  this.targetValues = {};
117
123
  this.activeTargetMap = {};
118
124
  Object.keys(this.targets).forEach(function(key) {
119
125
  self.activeTargetMap[key] = true;
126
+ self.addToStyleTargets(key);
120
127
  });
121
128
  };
122
129
 
123
130
  TModel.prototype.hasDomHolderChanged = function() {
124
-
125
131
  return this.getDomHolder() && this.getDomHolder().exists() && this.$dom.parent().getAttribute("id") !== this.getDomHolder().attr("id");
126
132
  };
127
133
 
@@ -211,7 +217,7 @@ TModel.prototype.findLastChild = function(type) {
211
217
  };
212
218
 
213
219
  TModel.prototype.getParentValue = function(targetName) {
214
- var parent = SearchUtil.findParentWithTarget(this, targetName);
220
+ var parent = SearchUtil.findParentByTarget(this, targetName);
215
221
  return parent ? parent.getValue(targetName) : undefined;
216
222
  };
217
223
 
@@ -292,23 +298,16 @@ TModel.prototype.createViewport = function() {
292
298
  TModel.prototype.setLocation = function(viewport) {
293
299
  this.x = viewport.getXNext();
294
300
  this.y = viewport.getYNext();
301
+ };
295
302
 
296
- this.absX = this.getDomParent() ? this.getDomParent().absX + this.x : this.x;
297
- this.absY = this.getDomParent() ? this.getDomParent().absY + this.y : this.y;
298
-
299
- var scrollTopHandler = SearchUtil.findFirstScrollTopHandler(this);
300
- var scrollLeftHandler = SearchUtil.findFirstScrollLeftHandler(this);
301
-
302
- this.deepX = this.absX + (scrollTopHandler ? scrollTopHandler.getScrollTop() : 0);
303
- this.deepY = this.absY + (scrollLeftHandler ? scrollLeftHandler.getScrollLeft() : 0);
303
+ TModel.prototype.calculateAbsolutePosition = function(x, y) {
304
+ var rect = this.getBoundingRect();
305
+ this.absX = rect.left + x;
306
+ this.absY = rect.top + y;
304
307
  };
305
308
 
306
- TModel.prototype.fixOpacity = function () {
307
- var opacity = this.getOpacity() ? this.getOpacity().toFixed(2) : 0;
308
-
309
- if (this.$dom.opacity() !== opacity) {
310
- this.$dom.opacity(opacity);
311
- }
309
+ TModel.prototype.getBoundingRect = function() {
310
+ return TUtil.getBoundingRect(this);
312
311
  };
313
312
 
314
313
  TModel.prototype.fixCss = function () {
@@ -323,7 +322,7 @@ TModel.prototype.fixStyle = function () {
323
322
  if (TUtil.isDefined(style) && this.domValues.style !== style) {
324
323
  this.$dom.setStyleByMap(style);
325
324
  this.domValues.style = style;
326
- }
325
+ }
327
326
  };
328
327
 
329
328
  TModel.prototype.fixXYRotateScale = function () {
@@ -349,12 +348,13 @@ TModel.prototype.fixDim = function () {
349
348
  }
350
349
  };
351
350
 
352
- TModel.prototype.fixZIndex = function () {
353
-
354
- var zIndex = Math.floor(this.getZIndex());
355
- if (this.$dom.zIndex() !== zIndex) {
356
- this.$dom.zIndex(zIndex);
357
- }
351
+ TModel.prototype.fixStyleAttributes = function() {
352
+ var self = this;
353
+ this.styleTargets.forEach(function(key) {
354
+ if (TUtil.isDefined(self.getValue(key)) && self.$dom.style(key) !== self.getValue(key)) {
355
+ self.$dom.style(key, self.getValue(key));
356
+ }
357
+ });
358
358
  };
359
359
 
360
360
  TModel.prototype.isMarkedDeleted = function() {
@@ -773,13 +773,18 @@ TModel.prototype.removeUpdatingChild = function(child) {
773
773
  TModel.prototype.removeTarget = function(key) {
774
774
  delete this.targets[key];
775
775
  delete this.activeTargetMap[key];
776
- delete this.targetValues[key];
776
+ delete this.targetValues[key];
777
+ var index = this.styleTargets.indexOf(key);
778
+ if (index !== -1) {
779
+ this.styleTargets.splice(index, 1);
780
+ }
777
781
  };
778
782
 
779
783
  TModel.prototype.addTarget = function(key, target) {
780
784
  this.targets[key] = target;
781
785
  this.activeTargetMap[key] = true;
782
786
  delete this.targetValues[key];
787
+ this.addToStyleTargets(key);
783
788
 
784
789
  tapp.manager.scheduleRun(10, 'addTarget-' + this.oid + "-" + key);
785
790
  };
@@ -787,8 +792,13 @@ TModel.prototype.addTarget = function(key, target) {
787
792
  TModel.prototype.addTargets = function(targets) {
788
793
  var self = this;
789
794
  Object.keys(targets).forEach(function(key) {
790
- self.addTarget(key, targets[key]);
795
+ self.targets[key] = targets[key];
796
+ self.activeTargetMap[key] = true;
797
+ delete self.targetValues[key];
798
+ self.addToStyleTargets(key);
791
799
  });
800
+
801
+ tapp.manager.scheduleRun(10, 'addTargets-' + this.oid);
792
802
  };
793
803
 
794
804
  TModel.prototype.deleteTargetValue = function(key) {
@@ -798,6 +808,17 @@ TModel.prototype.deleteTargetValue = function(key) {
798
808
  tapp.manager.scheduleRun(10, 'deleteTargetValue-' + this.oid + "-" + key);
799
809
  };
800
810
 
811
+ TModel.prototype.deleteTargetValues = function(keys) {
812
+ var self = this;
813
+ keys.forEach(function(key) {
814
+ delete self.targetValues[key];
815
+ self.activeTargetMap[key] = true;
816
+ });
817
+
818
+ tapp.manager.scheduleRun(10, 'deleteTargetValues-' + this.oid);
819
+
820
+ };
821
+
801
822
  TModel.prototype.setTargetMethodName = function(targetName, methodName) {
802
823
  if (!this.targetMethodMap[targetName]) {
803
824
  this.targetMethodMap[targetName] = [];
@@ -366,11 +366,11 @@ TModelManager.prototype.run = function(oid, delay) {
366
366
  var tmodel = tapp.manager.lists.visible[i];
367
367
  if (tmodel.hasDom()) {
368
368
  tmodel.fixXYRotateScale();
369
- tmodel.fixOpacity();
370
- tmodel.fixZIndex();
371
369
  tmodel.fixCss();
372
370
  tmodel.fixStyle();
373
371
  tmodel.fixDim();
372
+ tmodel.fixStyleAttributes();
373
+
374
374
  }
375
375
 
376
376
  }
package/src/TUtil.js CHANGED
@@ -1,7 +1,38 @@
1
1
  import { $Dom } from "./$Dom.js";
2
+ import { getScreenWidth, getScreenHeight } from "./App.js";
3
+ import { SearchUtil } from "./SearchUtil.js";
2
4
 
3
5
  function TUtil() {}
4
6
 
7
+ TUtil.getBoundingRect = function(tmodel) {
8
+ var left, top, right, bottom;
9
+
10
+ if (tmodel.actualValues.domHolder && tmodel.actualValues.domHolder.exists()) {
11
+ var rect = tmodel.actualValues.domHolder.getBoundingClientRect();
12
+ left = rect.left;
13
+ top = rect.top;
14
+ right = rect.right;
15
+ bottom = rect.bottom;
16
+ } else {
17
+ var parent = tmodel.getDomParent() ? tmodel.getDomParent() : SearchUtil.findParentByTarget(tmodel, 'domHolder');
18
+
19
+ if (parent) {
20
+ left = parent.absX;
21
+ top = parent.absY;
22
+ right = left + parent.getWidth();
23
+ bottom = top + parent.getHeight();
24
+ } else {
25
+ left = 0;
26
+ top = 0;
27
+ right = getScreenWidth();
28
+ bottom = getScreenHeight();
29
+ }
30
+ }
31
+
32
+ return { left: left, top: top, right: right, bottom: bottom };
33
+ };
34
+
35
+
5
36
  TUtil.initDoms = function(visibleList) {
6
37
 
7
38
  var elements = $Dom.findByClass('tgt');
package/src/TargetUtil.js CHANGED
@@ -4,6 +4,16 @@ import { TUtil } from "./TUtil.js";
4
4
 
5
5
  function TargetUtil() {}
6
6
 
7
+ TargetUtil.styleTargetMap = {
8
+ 'opacity': true,
9
+ 'zIndex': true,
10
+ 'fontSize': true,
11
+ 'borderRadius': true,
12
+ 'padding': true,
13
+ 'background': true,
14
+ 'color': true
15
+ };
16
+
7
17
  TargetUtil.extractInvisibles = function(tmodel, target, key) {
8
18
  if (typeof target === 'object' && target) {
9
19
  Object.keys(target).forEach(function(k) {
@@ -34,6 +44,20 @@ TargetUtil.emptyValue = function() {
34
44
  };
35
45
  };
36
46
 
47
+ TargetUtil.isValueStepsCycleArray = function(arr) {
48
+ if (arr.length > 4) {
49
+ return false;
50
+ }
51
+
52
+ for (var i = 0; i < arr.length; i++) {
53
+ if (typeof arr[i] !== 'number') {
54
+ return false;
55
+ }
56
+ }
57
+
58
+ return true;
59
+ };
60
+
37
61
  TargetUtil.getValueStepsCycles = function(tmodel, key) {
38
62
  var _target = tmodel.targets[key];
39
63
  var valueOnly = _target && _target.valueOnly ? true : false;
@@ -43,7 +67,7 @@ TargetUtil.getValueStepsCycles = function(tmodel, key) {
43
67
 
44
68
  function getValue(target) {
45
69
  if (Array.isArray(target)) {
46
- if (valueOnly) {
70
+ if (valueOnly || !TargetUtil.isValueStepsCycleArray(target)) {
47
71
  return [target, steps, stepInterval, cycles];
48
72
  } else {
49
73
  if (typeof target[0] === 'function') {
@@ -64,7 +88,7 @@ TargetUtil.getValueStepsCycles = function(tmodel, key) {
64
88
  stepInterval = typeof target.stepInterval === 'function' ? target.stepInterval.call(tmodel, key, cycle, tmodel.getTargetStepInterval(key)) : TUtil.isDefined(target.stepInterval) ? target.stepInterval : 0;
65
89
  cycles = typeof target.cycles === 'function' ? target.cycles.call(tmodel, key, cycle, tmodel.getTargetCycles(key)) : TUtil.isDefined(target.cycles) ? target.cycles : 0;
66
90
 
67
- if (Array.isArray(value) && valueOnly === false) {
91
+ if (Array.isArray(value)) {
68
92
  return getValue(value);
69
93
  } else {
70
94
  return [value, steps, stepInterval, cycles];
package/src/Viewport.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import { browser } from "./Browser.js";
2
2
  import { TUtil } from "./TUtil.js";
3
3
  import { tapp } from "./App.js";
4
+ import { getScreenWidth, getScreenHeight } from "./App.js";
4
5
 
5
6
  function Viewport(tmodel) {
6
7
 
@@ -90,51 +91,30 @@ Viewport.prototype.getYNext = function() {
90
91
  return this.yNext + this.currentChild.getTopMargin() + this.yOffset - this.tmodel.getScrollTop();
91
92
  };
92
93
 
93
- Viewport.prototype.isXVisible = function(child, x1, x2, minX, maxX) {
94
+ Viewport.prototype.isXVisible = function(x1, x2, minX, maxX) {
94
95
  return x1 <= maxX && x2 >= minX;
95
96
  };
96
97
 
97
- Viewport.prototype.isYVisible = function(child, y1, y2, minY, maxY) {
98
+ Viewport.prototype.isYVisible = function(y1, y2, minY, maxY) {
98
99
  return y1 <= maxY && y2 >= minY;
99
100
  };
100
101
 
101
102
  Viewport.prototype.isVisible = function(child) {
102
103
 
104
+ var x = child.absX;
105
+ var y = child.absY;
106
+
103
107
  var parentScale = child.getDomParent() ? child.getDomParent().getMeasuringScale() : 1;
104
-
105
- var minX = tapp.dim.screen.x;
106
- var minY = tapp.dim.screen.y;
107
- var maxX = tapp.dim.screen.width;
108
- var maxY = tapp.dim.screen.height;
109
-
110
- var x = child.getX();
111
- var y = child.getY();
112
-
113
- var domHolder = child.type === 'BI' ? child.getRealParent().getDomHolder() : child.getDomHolder();
114
- var domParent = child.type === 'BI' ? child.getRealParent().getDomParent() : child.getDomParent();
115
-
116
- if (domParent) {
117
- minX = domParent.isInFlow() ? domParent.absX : domParent.getX();
118
- minY = domParent.isInFlow() ? domParent.absY : domParent.getY();
119
-
120
- x = minX + child.getX();
121
- y = minY + child.getY();
122
-
123
- maxX = Math.min(maxX, minX + domParent.getWidth());
124
- maxY = Math.min(maxY, minY + domParent.getHeight());
125
- minX = Math.max(0, minX);
126
- minY = Math.max(0, minY);
127
- }
128
-
129
108
  var scale = parentScale * child.getMeasuringScale();
130
109
  var maxWidth = TUtil.isDefined(child.getWidth()) ? scale * child.getWidth() : 0;
131
110
  var maxHeight = TUtil.isDefined(child.getHeight()) ? scale * child.getHeight() : 0;
132
111
 
133
- child.xVisible = this.isXVisible(child, x, x + maxWidth, minX, maxX);
134
- child.yVisible = this.isYVisible(child, y, y + maxHeight, minY, maxY);
112
+ var rect = child.getBoundingRect();
113
+ child.xVisible = this.isXVisible(x, x + maxWidth, rect.left, rect.right);
114
+ child.yVisible = this.isYVisible(y, y + maxHeight, rect.top, rect.bottom);
135
115
 
136
- //browser.log(child.oid === 'BI199')("oid: " + child.oid + " in " + this.tmodel.oid + " min-maxX:" + Math.round(minX) + "-" + Math.round(maxX) + " x:" + Math.round(x) + " w:" + Math.floor(maxWidth) + " sc:" + scale + " vx:" + child.xVisible);
137
- //browser.log(child.oid === 'BI199')("oid: " + child.oid + " in " + this.tmodel.oid + " min-maxY:" + Math.round(minY) + "-" + Math.round(maxY) + " y:" + Math.round(y) + " h:" + Math.floor(maxHeight) + " sc:" + scale + " vy:" + child.yVisible);
116
+ //browser.log(child.oid === 'num')("oid: " + child.oid + " in " + this.tmodel.oid + " min-maxX:" + Math.round(rect.left) + "-" + Math.round(rect.right) + " x:" + Math.round(x) + " w:" + Math.floor(maxWidth) + " sc:" + scale + " vx:" + child.xVisible);
117
+ //browser.log(child.oid === 'docsPanel')("oid: " + child.oid + " in " + this.tmodel.oid + " min-maxY:" + Math.round(rect.top) + "-" + Math.round(rect.bottom) + " y:" + Math.round(y) + " h:" + Math.floor(maxHeight) + " sc:" + scale + " vy:" + child.yVisible);
138
118
 
139
119
  return child.isVisible();
140
120
  };