Skip to content

Commit a3a2dd0

Browse files
committed
incorporating integer lastdrag from Physlets
1 parent 2ff380c commit a3a2dd0

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

sources/net.sf.j2s.java.core/srcjs/js/README.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
This directory contains:
22

33

4-
js/*.js a set of files needed for all SwingJS pagees
4+
js/*.js a set of files needed for all SwingJS pages
55

66
js/make.bat a script that concatenates the *.js files in the right order to make swingjs2.js
77

sources/net.sf.j2s.java.core/srcjs/js/j2sApplet.js

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// j2sCore.js (based on JmolCore.js)
22

3+
// BH 3/16/2018 5:25:09 AM fixes for dragging on phones
34
// BH 2/20/2018 12:08:08 AM adds J2S._getKeyModifiers
45
// BH 1/8/2018 10:27:46 PM SwingJS2
56
// BH 12/22/2017 1:18:42 PM adds j2sargs for setting arguments
@@ -1287,8 +1288,11 @@ J2S._getDefaultLanguage = function(isAll) { return (isAll ? J2S.featureDetection
12871288

12881289
J2S.$bind(who, 'mousedown touchstart', function(ev) {
12891290

1291+
12901292
// System.out.println(["j2sApplet DOWN",ev.type,doIgnore(ev),ev.target.id,ev.target.getAttribute("role"),ev.target["data-ui"]]);
12911293

1294+
lastDragx = lastDragy = 99999;
1295+
12921296
if (doIgnore(ev))
12931297
return true;
12941298

@@ -1472,6 +1476,9 @@ J2S._getDefaultLanguage = function(isAll) { return (isAll ? J2S.featureDetection
14721476
var getMouseModifiers = function(ev) {
14731477
var modifiers = 0;
14741478
switch (ev.button) {
1479+
default:
1480+
ev.button = 0;
1481+
// fall through
14751482
case 0:
14761483
modifiers = (1<<4)|(1<<10);//InputEvent.BUTTON1 + InputEvent.BUTTON1_DOWN_MASK;
14771484
break;
@@ -1561,6 +1568,9 @@ J2S._getDefaultLanguage = function(isAll) { return (isAll ? J2S.featureDetection
15611568
return true;
15621569
}
15631570

1571+
var lastDragx = 99999;
1572+
var lastDragy = 99999;
1573+
15641574
J2S._drag = function(who, ev) {
15651575

15661576
ev.stopPropagation();
@@ -1572,7 +1582,12 @@ J2S._getDefaultLanguage = function(isAll) { return (isAll ? J2S.featureDetection
15721582
var xym = J2S._jsGetXY(who, ev);
15731583
if(!xym) return false;
15741584

1575-
if (!who.isDragging)
1585+
if (lastDragx == xym[0] && lastDragy == xym[1])
1586+
return false;
1587+
lastDragx = xym[0];
1588+
lastDragy = xym[1];
1589+
1590+
if (!who.isDragging)
15761591
xym[2] = 0;
15771592

15781593
var ui = ev.target["data-ui"];

0 commit comments

Comments
 (0)