targetj 1.0.47 → 1.0.48

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
@@ -2,3 +2,4 @@ export * from "./src/App.js"
2
2
  export * from "./src/TModel.js"
3
3
  export * from "./src/SearchUtil.js"
4
4
  export * from "./src/TUtil.js"
5
+ export * from "./src/Browser.js"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "targetj",
3
- "version": "1.0.47",
3
+ "version": "1.0.48",
4
4
  "keywords": [
5
5
  "targetj"
6
6
  ],
package/src/Browser.js CHANGED
@@ -195,9 +195,7 @@ var browser = {
195
195
  nextRun = { timeStamp: this.delayProcess.timeStamp, oid: this.delayProcess.oid, delay: this.delayProcess.delay };
196
196
 
197
197
  clearTimeout(this.delayProcess.id);
198
-
199
- //console.log("clearing: " + oid + ", " + (this.delayProcess.timeStamp) + " vs " + timeStamp);
200
-
198
+
201
199
  this.delayProcess.oid = oid;
202
200
  this.delayProcess.timeStamp = timeStamp;
203
201
  this.delayProcess.delay = delay;
@@ -20,19 +20,18 @@ function EventListener() {
20
20
  };
21
21
 
22
22
  this.eventMap = {
23
- mousedown: 'touchstart',
24
23
  touchstart: 'touchstart',
25
- mousemove: 'touchmove',
26
24
  touchmove: 'touchmove',
27
25
  touchend: 'touchend',
28
26
  touchcancel: 'touchend',
29
- pointerup: 'touchend',
30
- MSPointerUp: 'touchend',
31
- mouseup: 'touchend',
32
- pointercancel: 'touchend',
33
- MSPointerCancel: 'touchend',
34
- mousecancel: 'touchend',
35
- mouseleave: 'touchleave',
27
+ mousedown: 'mousedown',
28
+ mousemove: 'mousemove',
29
+ pointerup: 'mouseup',
30
+ MSPointerUp: 'mouseup',
31
+ mouseup: 'mouseup',
32
+ pointercancel: 'mouseup',
33
+ MSPointerCancel: 'mouseup',
34
+ mousecancel: 'mouseup',
36
35
  wheel: 'wheel',
37
36
  DOMMouseScroll: 'wheel',
38
37
  mousewheel: 'wheel',
@@ -100,58 +99,52 @@ EventListener.prototype.handleEvent = function (event) {
100
99
  this.eventTagName = (event.target.tagName || "").toUpperCase();
101
100
  this.eventName = this.eventMap[event.type];
102
101
 
103
- var tmodel = this.getTModelFromEvent(event);
104
-
105
- if (tmodel && tmodel.keepEventDefault()
106
- && (tmodel.keepEventDefault() === true || (Array.isArray(tmodel.keepEventDefault()) && tmodel.keepEventDefault().includes(this.eventName)))) {
107
- tapp.manager.scheduleRun(0, "ignoring=" + this.eventName + '-' + this.eventTagName);
108
- } else {
109
- switch (this.eventName) {
110
- case 'touchstart':
111
- this.clear();
112
- this.touchCount = this.countTouches(event);
113
- event.preventDefault();
114
- this.start(event);
115
-
116
- break;
117
-
118
- case 'touchmove':
119
- var touch = this.getTouch(event);
120
-
121
- this.cursor.x = touch.x;
122
- this.cursor.y = touch.y;
123
-
124
- event.preventDefault();
125
-
126
- if (this.touchCount > 0) {
127
- this.move(event);
128
- }
129
-
130
- break;
102
+ switch (this.eventName) {
103
+
104
+ case 'mousedown':
105
+ case 'touchstart':
106
+ this.clear();
107
+ this.touchCount = this.countTouches(event);
108
+ if (this.preventDefault(event, this.eventName)) event.preventDefault();
109
+ this.start(event);
110
+ event.stopPropagation();
111
+ break;
112
+
113
+ case 'mousemove':
114
+ case 'touchmove':
115
+ var touch = this.getTouch(event);
116
+ this.cursor.x = touch.x;
117
+ this.cursor.y = touch.y;
118
+ if (this.preventDefault(event, this.eventName)) event.preventDefault();
119
+ if (this.touchCount > 0) {
120
+ this.move(event);
121
+ event.stopPropagation();
122
+ }
123
+ break;
131
124
 
132
- case 'touchend':
133
- event.preventDefault();
134
- this.end(event);
135
- break;
125
+ case 'mouseup':
126
+ case 'touchend':
127
+ if (this.preventDefault(event, this.eventName)) event.preventDefault();
128
+ this.end(event);
129
+ event.stopPropagation();
130
+ break;
136
131
 
137
- case 'wheel':
138
- event.preventDefault();
139
- this.wheel(event);
140
- break;
132
+ case 'wheel':
133
+ if (this.preventDefault(event, this.eventName)) event.preventDefault();
134
+ this.wheel(event);
135
+ break;
141
136
 
142
- case 'key':
143
- this.keyUpHandler(event);
144
- break;
137
+ case 'key':
138
+ this.keyUpHandler(event);
139
+ break;
145
140
 
146
- case 'resize':
147
- tapp.dim.measureScreen();
148
- break;
141
+ case 'resize':
142
+ tapp.dim.measureScreen();
143
+ break;
149
144
 
150
- }
151
- tapp.manager.scheduleRun(0, this.eventName + '-' + this.eventTagName);
152
145
  }
153
-
154
-
146
+
147
+ tapp.manager.scheduleRun(0, this.eventName + '-' + this.eventTagName);
155
148
  };
156
149
 
157
150
  EventListener.prototype.findEventHandlers = function(event) {
@@ -169,6 +162,16 @@ EventListener.prototype.findEventHandlers = function(event) {
169
162
  this.currentHandlers.pinch = pinchHandler;
170
163
  };
171
164
 
165
+ EventListener.prototype.preventDefault = function(event, eventName) {
166
+ var tmodel = this.getTModelFromEvent(event);
167
+
168
+ if (tmodel && (tmodel.keepEventDefault() === true || (Array.isArray(tmodel.keepEventDefault()) && tmodel.keepEventDefault().includes(eventName)))) {
169
+ return false;
170
+ }
171
+
172
+ return true;
173
+ };
174
+
172
175
  EventListener.prototype.getTModelFromEvent = function(event) {
173
176
  var oid = typeof event.target.getAttribute === 'function' ? event.target.getAttribute('id') : '';
174
177
 
@@ -346,9 +349,7 @@ EventListener.prototype.start = function (event) {
346
349
  this.start1 = this.getTouch(event, 1);
347
350
 
348
351
  this.cursor.x = this.start0.x;
349
- this.cursor.y = this.start0.y;
350
-
351
- return event.stopPropagation();
352
+ this.cursor.y = this.start0.y;
352
353
  };
353
354
 
354
355
  EventListener.prototype.move = function (event) {
@@ -382,8 +383,6 @@ EventListener.prototype.move = function (event) {
382
383
 
383
384
  this.setCurrentTouchParam('pinchDelta', this.currentTouch.diff > 0 ? 0.3 : this.currentTouch.diff < 0 ? -0.3 : 0);
384
385
  }
385
-
386
- return event.stopPropagation();
387
386
  };
388
387
 
389
388
  EventListener.prototype.end = function (event) {
@@ -424,7 +423,6 @@ EventListener.prototype.end = function (event) {
424
423
  }
425
424
 
426
425
  this.touchCount = 0;
427
- return event.stopPropagation();
428
426
  };
429
427
 
430
428
  EventListener.prototype.setDeltaXDeltaY = function(deltaX, deltaY, isWheel) {