targetj 1.0.63 → 1.0.65

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "targetj",
3
- "version": "1.0.63",
3
+ "version": "1.0.65",
4
4
  "keywords": [
5
5
  "targetj"
6
6
  ],
package/src/App.js CHANGED
@@ -113,7 +113,7 @@ function AppFn(firstChild) {
113
113
  my.start = function () {
114
114
  my.runningFlag = false;
115
115
 
116
- my.events.clear();
116
+ my.events.clearAll();
117
117
  my.troot.getChildren().forEach(function(child) {
118
118
  child.deleteTargetValue('addEventHandler');
119
119
  });
@@ -141,7 +141,7 @@ function AppFn(firstChild) {
141
141
  }
142
142
  });
143
143
 
144
- my.events.clear();
144
+ my.events.clearAll();
145
145
 
146
146
  my.resetRuns();
147
147
 
@@ -190,7 +190,7 @@ function App(tmodel) {
190
190
 
191
191
  function isRunning() {
192
192
  return tapp ? tapp.runningFlag : false;
193
- };
193
+ }
194
194
 
195
195
  function troot() {
196
196
  return tapp ? tapp.troot : null;
@@ -15,48 +15,55 @@ function EventListener() {
15
15
  manualMomentumFlag: false,
16
16
  orientation: "none" ,
17
17
  dir: "",
18
- source: "",
19
- timeStamp: 0
18
+ source: ""
20
19
  };
21
20
 
22
- this.bindedHandleEvent = this.bindedHandleEvent ? this.bindedHandleEvent : this.handleEvent.bind(this);
23
-
24
- this.eventMap = {
25
- touchstart: { to: 'touchstart', windowEvent: false },
26
- touchmove: { to: 'touchmove', windowEvent: false },
27
- touchend: { to: 'touchend', windowEvent: false },
28
- touchcancel: { to: 'touchend', windowEvent: false },
29
- mousedown: { to: 'mousedown', windowEvent: false },
30
- mousemove: { to: 'mousemove', windowEvent: false },
31
- pointerup: { to: 'mouseup', windowEvent: false },
32
- MSPointerUp: { to: 'mouseup', windowEvent: false },
33
- mouseup: { to: 'mouseup', windowEvent: false },
34
- pointercancel: { to: 'mouseup', windowEvent: false },
35
- MSPointerCancel: { to: 'mouseup', windowEvent: false },
36
- mousecancel: { to: 'mouseup', windowEvent: false },
37
- wheel: { to: 'wheel', windowEvent: false },
38
- DOMMouseScroll: { to: 'wheel', windowEvent: false },
39
- mousewheel: { to: 'wheel', windowEvent: false },
40
- keyup: { to: 'key', windowEvent: true },
41
- resize: { to: 'resize', windowEvent: true },
42
- orientationchange: { to: 'resize', windowEvent: true }
43
- };
44
-
45
- var self = this;
46
- this.domEvents = Object.keys(this.eventMap).filter(function(key) { return self.eventMap[key].windowEvent === false; });
47
- this.windowEvents = Object.keys(this.eventMap).filter(function(key) { return self.eventMap[key].windowEvent; });
48
-
49
- this.lastEvents = [];
50
-
21
+ this.touchTimeStamp = 0;
22
+
51
23
  this.cursor = { x: 0, y: 0};
52
24
  this.start0 = undefined;
53
25
  this.start1 = undefined;
54
26
  this.end0 = undefined;
55
27
  this.end1 = undefined;
56
- this.touchCount = 0;
28
+ this.touchCount = 0;
57
29
 
58
30
  this.currentEvent = "";
59
31
  this.currentHandlers = { touch: null, scrollLeft: null, scrollTop: null, pinch: null };
32
+
33
+ this.eventQueue = [];
34
+
35
+ this.eventMap = {
36
+ touchstart: { to: 'touchstart', inputType: 'touch', eventType: 'start', order: 1, windowEvent: false },
37
+ touchmove: { to: 'touchmove', inputType: 'touch', eventType: 'move', order: 1, windowEvent: false },
38
+ touchend: { to: 'touchend', inputType: 'touch', eventType: 'end', order: 1, windowEvent: false },
39
+ touchcancel: { to: 'touchend', inputType: 'touch', eventType: 'cancel', order: 1, windowEvent: false },
40
+
41
+ mousedown: { to: 'mousedown', inputType: 'mouse', eventType: 'start', order: 2, windowEvent: false },
42
+ mousemove: { to: 'mousemove', inputType: 'mouse', eventType: 'move', order: 2, windowEvent: false },
43
+ mouseup: { to: 'mouseup', inputType: 'mouse', eventType: 'end', order: 2, windowEvent: false },
44
+ mousecancel: { to: 'mouseup', inputType: 'mouse', eventType: 'cancel', order: 2, windowEvent: false },
45
+
46
+ pointerdown: { to: 'mousedown', inputType: 'pointer', eventType: 'start', order: 3, windowEvent: false },
47
+ pointermove: { to: 'mousemove', inputType: 'pointer', eventType: 'move', order: 3, windowEvent: false },
48
+ pointerup: { to: 'mouseup', inputType: 'pointer', eventType: 'end', order: 3, windowEvent: false },
49
+ pointercancel: { to: 'mousecancel', inputType: 'pointer', eventType: 'cancel', order: 3, windowEvent: false },
50
+
51
+ wheel: { to: 'wheel', inputType: '', eventType: 'wheel', order: 1, windowEvent: false },
52
+ DOMMouseScroll: { to: 'wheel', inputType: '', eventType: 'wheel', order: 1, windowEvent: false },
53
+ mousewheel: { to: 'wheel', inputType: '', eventType: 'wheel', order: 1, windowEvent: false },
54
+
55
+ keyup: { to: 'key', inputType: '', eventType: 'key', order: 1, windowEvent: true },
56
+ keydown: { to: 'key', inputType: '', eventType: 'key', order: 1, windowEvent: true },
57
+ resize: { to: 'resize', inputType: '', eventType: 'resize', order: 1, windowEvent: true },
58
+ orientationchange: { to: 'resize', inputType: '', eventType: 'resize', order: 1, windowEvent: true }
59
+ };
60
+
61
+ var self = this;
62
+ this.domEvents = Object.keys(this.eventMap).filter(function(key) { return self.eventMap[key].windowEvent === false; });
63
+ this.windowEvents = Object.keys(this.eventMap).filter(function(key) { return self.eventMap[key].windowEvent; });
64
+
65
+ this.bindedHandleEvent = this.bindedHandleEvent ? this.bindedHandleEvent : this.handleEvent.bind(this);
66
+
60
67
  }
61
68
 
62
69
  EventListener.prototype.removeHandlers = function ($dom) {
@@ -90,12 +97,12 @@ EventListener.prototype.addWindowHandlers = function () {
90
97
 
91
98
  EventListener.prototype.captureEvents = function() {
92
99
 
93
- if (this.lastEvents.length === 0) {
100
+ if (this.eventQueue.length === 0) {
94
101
  this.currentEvent = "";
95
102
  this.currentKey = "";
96
103
  return;
97
104
  }
98
- var lastEvent = this.lastEvents.pop();
105
+ var lastEvent = this.eventQueue.shift();
99
106
 
100
107
  if (lastEvent.eventName === 'resize') {
101
108
  tapp.dim.measureScreen();
@@ -105,29 +112,73 @@ EventListener.prototype.captureEvents = function() {
105
112
  this.currentKey = this.currentTouch.key;
106
113
  this.currentTouch.key = "";
107
114
  }
115
+
116
+ tapp.manager.scheduleRun(10, 'captureEvents' + '-' + lastEvent);
117
+
108
118
  };
109
119
 
110
120
  EventListener.prototype.handleEvent = function (event) {
121
+ if (!event) return;
122
+
123
+ var eventName, inputType, eventType, eventOrder;
124
+
125
+ var originalName = event.type;
126
+ var eventItem = this.eventMap[originalName];
127
+
128
+ if (eventItem) {
129
+ eventName = eventItem.to;
130
+ inputType = eventItem.inputType;
131
+ eventType = eventItem.eventType;
132
+ eventOrder = eventItem.order;
133
+ }
111
134
 
112
- var eventName = this.eventMap[event.type] ? this.eventMap[event.type].to : null;
135
+ var now = browser.now();
136
+ this.touchTimeStamp = now > this.touchTimeStamp ? now : this.touchTimeStamp;
137
+
113
138
  var tmodel = this.getTModelFromEvent(event);
114
-
139
+
140
+ var lastEvent = this.eventQueue.length > 0 ? this.eventQueue[this.eventQueue.length - 1] : null;
141
+
142
+ if (lastEvent) {
143
+
144
+ var lastEventItem = lastEvent.eventItem;
145
+ var rate = now - lastEvent.timeStamp;
146
+
147
+ if ((inputType && lastEventItem.inputType && lastEventItem.inputType !== inputType && eventOrder > lastEventItem.order)) {
148
+ return;
149
+ } else if (this.eventQueue.length > 10 && rate < 50) {
150
+ var capacity = 0, i;
151
+ for (i = this.eventQueue.length - 1; i >= 0 && this.eventQueue[i].eventItem.eventType === eventType; i--) {
152
+ if (++capacity > 5) {
153
+ return;
154
+ }
155
+ }
156
+ }
157
+ }
158
+
159
+ this.eventQueue.push({ eventName: eventName, eventItem: eventItem, originalName: originalName, tmodel: tmodel, timeStamp: now });
160
+
115
161
  switch (eventName) {
116
162
 
117
163
  case 'mousedown':
118
- case 'touchstart':
119
- this.lastEvents.push({ eventName: eventName, tmodel: tmodel });
164
+ case 'touchstart':
165
+ this.clearStart();
166
+ this.clearTouch();
120
167
 
121
- this.clear();
122
168
  this.touchCount = this.countTouches(event);
123
169
  if (this.preventDefault(tmodel, eventName)) event.preventDefault();
124
- this.start(event);
170
+
171
+ this.start0 = this.getTouch(event);
172
+ this.start1 = this.getTouch(event, 1);
173
+
174
+ this.cursor.x = this.start0.x;
175
+ this.cursor.y = this.start0.y;
176
+
125
177
  event.stopPropagation();
126
178
  break;
127
179
 
128
180
  case 'mousemove':
129
181
  case 'touchmove':
130
- this.lastEvents.push({ eventName: eventName, tmodel: tmodel });
131
182
 
132
183
  var touch = this.getTouch(event);
133
184
  this.cursor.x = touch.x;
@@ -141,37 +192,42 @@ EventListener.prototype.handleEvent = function (event) {
141
192
 
142
193
  case 'mouseup':
143
194
  case 'touchend':
144
- this.lastEvents.push({ eventName: eventName, tmodel: tmodel });
145
-
195
+
146
196
  if (this.preventDefault(tmodel, eventName)) event.preventDefault();
147
197
  this.end(event);
198
+
199
+ if (this.start0) {
200
+ var deltaX = 0, deltaY = 0, period = now - this.start0.timeStamp;
201
+
202
+ if (this.end0) {
203
+ deltaX = Math.abs(this.end0.originalX - this.start0.originalX);
204
+ deltaY = Math.abs(this.end0.originalY - this.start0.originalY);
205
+ period = Math.abs(this.end0.timeStamp - this.start0.timeStamp);
206
+ }
207
+
208
+ if (deltaX <= 1 && deltaY <= 1 && period <= 300) {
209
+ this.eventQueue.push({ eventName: 'click', eventItem: eventItem, originalName: originalName, tmodel: tmodel, timeStamp: now });
210
+ }
211
+ }
212
+
213
+ this.clearStart();
214
+ this.touchCount = 0;
215
+
148
216
  event.stopPropagation();
149
217
  break;
150
218
 
151
219
  case 'wheel':
152
- this.lastEvents.push({ eventName: eventName, tmodel: tmodel });
153
220
 
154
221
  if (this.preventDefault(tmodel, eventName)) event.preventDefault();
155
222
  this.wheel(event);
156
223
  break;
157
224
 
158
225
  case 'key':
159
- this.lastEvents.push({ eventName: eventName, tmodel: tmodel });
160
-
161
- this.keyUpHandler(event);
162
- break;
163
-
164
- case 'resize':
165
- if (this.lastEvents.length === 0 || this.lastEvents[this.lastEvents.length - 1].eventName !== 'resize') {
166
- this.lastEvents.push({ eventName: eventName, tmodel: tmodel });
167
- }
168
- break;
169
-
226
+ this.currentTouch.key = event.which || event.keyCode;
227
+ break;
170
228
  }
171
229
 
172
- tapp.manager.scheduleRun(0, event.type + '-' + eventName + '-' + (event.target.tagName || "").toUpperCase());
173
- tapp.manager.scheduleRun(20, event.type + '-' + eventName + '-' + (event.target.tagName || "").toUpperCase());
174
-
230
+ tapp.manager.scheduleRun(0, originalName + '-' + eventName + '-' + (event.target.tagName || "").toUpperCase());
175
231
  };
176
232
 
177
233
  EventListener.prototype.findEventHandlers = function(tmodel) {
@@ -206,16 +262,15 @@ EventListener.prototype.getTModelFromEvent = function(event) {
206
262
  return tapp.manager.visibleOidMap[oid];
207
263
  };
208
264
 
209
- EventListener.prototype.clear = function () {
265
+ EventListener.prototype.clearStart = function() {
210
266
  this.start0 = undefined;
211
267
  this.start1 = undefined;
212
268
  this.end0 = undefined;
213
269
  this.end1 = undefined;
214
270
  this.touchCount = 0;
215
- this.resetCurrentTouch();
216
271
  };
217
272
 
218
- EventListener.prototype.resetCurrentTouch = function() {
273
+ EventListener.prototype.clearTouch = function() {
219
274
  this.currentTouch.deltaY = 0;
220
275
  this.currentTouch.deltaX = 0;
221
276
  this.currentTouch.pinchDelta = 0;
@@ -226,12 +281,19 @@ EventListener.prototype.resetCurrentTouch = function() {
226
281
  this.currentTouch.source = '';
227
282
  };
228
283
 
229
- EventListener.prototype.resetEvents = function () {
230
- if (this.currentTouch.timeStamp > 0) {
284
+ EventListener.prototype.clearAll = function() {
285
+ this.clearStart();
286
+ this.clearTouch();
287
+ this.eventQueue.length = 0;
288
+ this.touchTimeStamp = 0;
289
+ };
290
+
291
+ EventListener.prototype.resetEventsOnTimeout = function () {
292
+ if (this.touchTimeStamp > 0) {
231
293
 
232
- var diff = browser.now() - this.currentTouch.timeStamp;
294
+ var diff = browser.now() - this.touchTimeStamp;
233
295
  var runDelay = 0;
234
-
296
+
235
297
  if (Math.abs(this.currentTouch.deltaY) > 0.001
236
298
  || Math.abs(this.currentTouch.deltaX) > 0.001
237
299
  || Math.abs(this.currentTouch.pinchDelta) > 0.001)
@@ -242,15 +304,15 @@ EventListener.prototype.resetEvents = function () {
242
304
  this.currentTouch.source = '';
243
305
  this.currentTouch.pinchDelta = 0;
244
306
  } else if (this.currentTouch.manualMomentumFlag) {
245
- this.currentTouch.deltaY *= 0.95;
246
- this.currentTouch.deltaX *= 0.95;
307
+ this.currentTouch.deltaY *= 0.85;
308
+ this.currentTouch.deltaX *= 0.85;
247
309
  this.currentTouch.source = '';
248
310
 
249
311
  runDelay = 10;
250
312
  }
251
313
  } else if (diff > 600) {
252
- this.clear();
253
- this.currentTouch.timeStamp = 0;
314
+ this.clearTouch();
315
+ this.touchTimeStamp = 0;
254
316
  }
255
317
 
256
318
  tapp.manager.scheduleRun(runDelay, "scroll decay");
@@ -335,38 +397,23 @@ EventListener.prototype.countTouches = function(event) {
335
397
 
336
398
  return count;
337
399
  };
338
-
339
- EventListener.prototype.keyUpHandler = function (e) {
340
- e = e || window.event;
341
- var key = e.which || e.keyCode;
342
-
343
- this.currentTouch.key = key;
344
- };
345
400
 
346
- EventListener.prototype.getTouch = function (event, index) {
347
- if (!event) return undefined;
401
+ EventListener.prototype.getTouch = function (event, index) {
348
402
  index = index || 0;
349
- var e = event.touches && event.touches[index] ? event.touches[index] : event;
350
- if (e.originalEvent && e.originalEvent.touches) {
351
- e = e.originalEvent.touches[index];
352
- }
353
-
403
+ var e = event.touches && event.touches[index] ? event.touches[index] : event.originalEvent && event.originalEvent.touches && event.originalEvent.touches[index] ? event.originalEvent.touches[index] : event;
404
+
405
+ var x = TUtil.isDefined(e.clientX) ? e.clientX : e.pageX || 0;
406
+ var y = TUtil.isDefined(e.clientY) ? e.clientY : e.pageY || 0;
354
407
  return {
355
- x: e.pageX || e.clientX || 0,
356
- y: e.pageY || e.clientY || 0,
408
+ x: x,
409
+ y: y,
410
+ originalX: x,
411
+ originalY: y,
357
412
  target: e.target,
358
413
  timeStamp: browser.now()
359
414
  };
360
415
  };
361
416
 
362
- EventListener.prototype.start = function (event) {
363
- this.start0 = this.getTouch(event);
364
- this.start1 = this.getTouch(event, 1);
365
-
366
- this.cursor.x = this.start0.x;
367
- this.cursor.y = this.start0.y;
368
- };
369
-
370
417
  EventListener.prototype.move = function (event) {
371
418
 
372
419
  var deltaX, deltaY;
@@ -394,50 +441,39 @@ EventListener.prototype.move = function (event) {
394
441
  var length1 = TUtil.distance(this.start0.x, this.start0.y, this.start1.x, this.start1.y);
395
442
  var length2 = TUtil.distance(this.end0.x, this.end0.y, this.end1.x, this.end1.y);
396
443
 
397
- this.currentTouch.diff = length2 - length1;
444
+ var diff = length2 - length1;
398
445
 
399
- this.setCurrentTouchParam('pinchDelta', this.currentTouch.diff > 0 ? 0.3 : this.currentTouch.diff < 0 ? -0.3 : 0);
446
+ this.currentTouch.pinchDelta = diff > 0 ? 0.3 : diff < 0 ? -0.3 : 0;
400
447
  }
401
448
  };
402
449
 
403
- EventListener.prototype.end = function (event) {
404
- var momentum;
405
-
406
- if (!TUtil.isDefined(this.end0)) {
407
- this.end0 = this.getTouch(event);
408
- }
409
-
410
- var startToEndTime = TUtil.isDefined(this.end0) && TUtil.isDefined(this.start0) ? this.end0.timeStamp - this.start0.timeStamp : 0;
450
+ EventListener.prototype.end = function () {
451
+
452
+ if (this.touchCount <= 1 && this.start0) {
411
453
 
412
- if (this.touchCount <= 1) {
413
-
414
- if (TUtil.isDefined(this.end0) && TUtil.isDefined(this.start0)) {
454
+ var deltaX = 0, deltaY = 0, period = 0;
455
+
456
+ if (this.end0) {
457
+ deltaX = this.start0.x - this.end0.x;
458
+ deltaY = this.start0.y - this.end0.y;
459
+ period = this.end0.timeStamp - this.start0.timeStamp;
460
+ }
415
461
 
416
- var deltaX = this.start0.x - this.end0.x;
417
- var deltaY = this.start0.y - this.end0.y;
418
-
419
- var period = this.end0.timeStamp - this.start0.timeStamp;
420
-
421
-
422
- if (this.currentTouch.orientation === "horizontal" && Math.abs(deltaX) > 1) {
423
- momentum = TUtil.momentum(0, deltaX, period);
424
- this.setCurrentTouchParam('deltaX', momentum.distance, browser.now() + momentum.duration);
425
- this.currentTouch.manualMomentumFlag = true;
426
- } else if (this.currentTouch.orientation === "vertical" && Math.abs(deltaY) > 1) {
427
- momentum = TUtil.momentum(0, deltaY, period);
428
- this.setCurrentTouchParam('deltaY', momentum.distance, browser.now() + momentum.duration);
429
- this.currentTouch.manualMomentumFlag = true;
430
- }
431
- }
432
- }
433
-
434
- if (!momentum && this.touchCount === 1 && startToEndTime <= 300) {
435
- this.lastEvents.push({ eventName: 'click', tmodel: this.getTModelFromEvent(event) });
436
- this.clear();
437
- this.currentTouch.timeStamp = 0;
462
+ var momentum;
463
+
464
+ if (this.currentTouch.orientation === "horizontal" && Math.abs(deltaX) > 1) {
465
+ momentum = TUtil.momentum(0, deltaX, period);
466
+ this.currentTouch.deltaX = momentum.distance;
467
+ this.currentTouch.manualMomentumFlag = true;
468
+ this.touchTimeStamp = browser.now() + momentum.duration;
469
+ } else if (this.currentTouch.orientation === "vertical" && Math.abs(deltaY) > 1) {
470
+ momentum = TUtil.momentum(0, deltaY, period);
471
+ this.currentTouch.deltaY = momentum.distance;
472
+ this.currentTouch.manualMomentumFlag = true;
473
+ this.touchTimeStamp = browser.now() + momentum.duration;
474
+ }
475
+
438
476
  }
439
-
440
- this.touchCount = 0;
441
477
  };
442
478
 
443
479
  EventListener.prototype.setDeltaXDeltaY = function(deltaX, deltaY, source) {
@@ -448,26 +484,21 @@ EventListener.prototype.setDeltaXDeltaY = function(deltaX, deltaY, source) {
448
484
  this.currentTouch.orientation = "horizontal";
449
485
  this.currentTouch.dir = deltaX <= -1 ? "left" : deltaX >= 1 ? "right" : this.currentTouch.dir;
450
486
  this.currentTouch.source = source;
451
- this.setCurrentTouchParam('deltaX', deltaX);
487
+ this.currentTouch.deltaX = deltaX;
452
488
  this.currentTouch.deltaY = 0;
453
489
  }
454
490
  } else if (this.currentTouch.orientation === "none" || (this.currentTouch.orientation === "horizontal" && diff < -3) || this.currentTouch.orientation === "vertical") {
455
491
  this.currentTouch.orientation = "vertical";
456
492
  this.currentTouch.dir = deltaY <= -1 ? "up" : deltaY >= 1 ? "down" : this.currentTouch.dir;
457
493
  this.currentTouch.source = source;
458
- this.setCurrentTouchParam('deltaY', deltaY);
494
+ this.currentTouch.deltaY = deltaY;
459
495
  this.currentTouch.deltaX = 0;
460
496
  } else {
461
- this.currentTouch.deltaX = 0;
462
497
  this.currentTouch.deltaY = 0;
498
+ this.currentTouch.deltaX = 0;
463
499
  }
464
500
  };
465
501
 
466
- EventListener.prototype.setCurrentTouchParam = function(name, value, timeStamp) {
467
- this.currentTouch[name] = value;
468
- this.currentTouch.timeStamp = TUtil.isDefined(timeStamp) ? timeStamp : Math.max(this.currentTouch.timeStamp, browser.now());
469
- };
470
-
471
502
  EventListener.prototype.wheel = function (event) {
472
503
  var deltaX = 0, deltaY = 0;
473
504
 
@@ -476,7 +507,7 @@ EventListener.prototype.wheel = function (event) {
476
507
  this.start0 = this.getTouch(event);
477
508
 
478
509
  if (event.ctrlKey && 'deltaY' in event) {
479
- this.setCurrentTouchParam('pinchDelta', -event.deltaY / 10);
510
+ this.currentTouch.pinchDelta = -event.deltaY / 10;
480
511
  } else if ('deltaX' in event) {
481
512
  deltaX = event.deltaX;
482
513
  deltaY = event.deltaY;
package/src/TModel.js CHANGED
@@ -548,7 +548,7 @@ TModel.prototype.updateTargetStatus = function(key) {
548
548
  };
549
549
 
550
550
  TModel.prototype.getTargetStatus = function(key) {
551
- return this.targetValues[key] ? this.targetValues[key].status : 0;
551
+ return this.targetValues[key] ? this.targetValues[key].status : '';
552
552
  };
553
553
 
554
554
  TModel.prototype.isTargetActive = function(key) {
@@ -345,7 +345,7 @@ TModelManager.prototype.run = function(oid, delay) {
345
345
  });
346
346
  }
347
347
 
348
- tapp.events.resetEvents();
348
+ tapp.events.resetEventsOnTimeout();
349
349
 
350
350
  break;
351
351
 
package/src/TUtil.js CHANGED
@@ -78,7 +78,7 @@ TUtil.momentum = function (past, current, time) {
78
78
  distance -= momentumDistance;
79
79
  }
80
80
 
81
- return {distance: Math.round(distance) / 50, duration: duration, momentumDistance: momentumDistance, time: time * 5 };
81
+ return {distance: Math.round(distance) / 50, duration: Math.floor(duration), momentumDistance: momentumDistance, time: time * 5 };
82
82
  };
83
83
 
84
84
  TUtil.isDefined = function (obj) {
@@ -8,9 +8,9 @@ function TargetManager() {
8
8
  }
9
9
 
10
10
  TargetManager.prototype.setTargetValues = function(tmodel, activeKeys) {
11
- tmodel.targetUpdatingMap = {};
12
- tmodel.targetUpdatingList = [];
13
- tmodel.targetMethodMap = {};
11
+ tmodel.targetUpdatingMap = {};
12
+ tmodel.targetUpdatingList = [];
13
+ tmodel.targetMethodMap = {};
14
14
 
15
15
  for (var i = 0; i < activeKeys.length; i++) {
16
16
  var key = activeKeys[i];
@@ -58,6 +58,10 @@ TargetManager.prototype.setTargetValue = function(tmodel, key) {
58
58
  return;
59
59
  }
60
60
 
61
+ if (typeof target.enabledOn === 'function') {
62
+ tmodel.setTargetMethodName(key, 'enabledOn');
63
+ }
64
+
61
65
  if (tmodel.isTargetEnabled(key)) {
62
66
  if (tmodel.getScheduleTimeStamp(key) && tmodel.isTargetActive(key) && tmodel.getTargetStepInterval(key) > 0
63
67
  && tmodel.getScheduleTimeStamp(key) + tmodel.getTargetStepInterval(key) <= browser.now()) {
@@ -69,6 +73,7 @@ TargetManager.prototype.setTargetValue = function(tmodel, key) {
69
73
  if (!newChange) {
70
74
  tmodel.targetValues[key].executionCount++;
71
75
  }
76
+
72
77
  tmodel.setTargetMethodName(key, 'value');
73
78
  }
74
79
 
@@ -76,8 +81,6 @@ TargetManager.prototype.setTargetValue = function(tmodel, key) {
76
81
  if (schedulePeriod > 0) {
77
82
  tapp.manager.scheduleRun(schedulePeriod, "actualInterval__" + tmodel.oid + "__" + key);
78
83
  }
79
- } else {
80
- tmodel.setTargetMethodName(key, 'enabledOn');
81
84
  }
82
85
  };
83
86
 
package/src/TargetUtil.js CHANGED
@@ -38,7 +38,7 @@ TargetUtil.getValueStepsCycles = function(tmodel, key) {
38
38
  var _target = tmodel.targets[key];
39
39
  var valueOnly = _target && _target.valueOnly ? true : false;
40
40
  var cycle = tmodel.getTargetCycle(key);
41
- var value = undefined, steps = 0, stepInterval = 0, cycles = 0;
41
+ var value, steps = 0, stepInterval = 0, cycles = 0;
42
42
  var lastValue = tmodel.getValue(key);
43
43
 
44
44
  function getValue(target) {
package/src/Viewport.js CHANGED
@@ -155,7 +155,7 @@ Viewport.prototype.appendNewLine = function() {
155
155
  var height = this.currentChild.getHeight() * this.currentChild.getMeasuringScale();
156
156
 
157
157
  this.xNext = this.xOverflow;
158
- this.yNext = this.ySouth + height + this.currentChild.getTopMargin() + this.currentChild.getBottomMargin() + this.currentChild.getValue('appendNewLine');
158
+ this.yNext = this.ySouth + height + this.currentChild.getValue('appendNewLine');
159
159
 
160
160
  this.yEast = this.yNext;
161
161
  this.xSouth = this.xNext;