我有一个任务,其中通过iFrame添加jsxgraph。我们在点击/单击jsxgraph板上添加点。问题是当我们在iPad中放大/缩小时,这些点会冻结。 此任务具有InitialArcadixNoofVertices变量,该变量设置最大点数。结果ArcadixCoords记录每个点的X和Y位置。
我们添加了JSX.touchProperty,因为它不起作用。 请参阅下面的A点。 enter image description here
JXG.Options.ticks.useUnicodeMinus = false;
JXG.Options.axis.ticks.strokeColor = 'white';
JXG.Options.axis.ticks.strokeOpacity = 0;
JXG.Options.point.showInfobox = false;
var icol = 0;
var col = [247, 70, 287, 35, 360, 100, 200, 20, 300, 50, 315, 30, 225, 95, 330, 65, 269];
var A = 3;
var InitialArcadixNoofVertices = "";
function main(){
board = JXG.JSXGraph.initBoard('box', { boundingbox: [-1, 11, 11, -1],
zoom : {
factorX : 0,
factorY : 0,
wheel : false,
needshift : false,
eps : 0.0
},
pan: {enabled: false},
showCopyright:false,axis: true, grid: true, showNavigation:false });
board.attr.pan.enabled = false;
board.attr.pan.needtwofingers = false;
board.registerevents = false;
if (InitialArcadixNoofVertices !== null && InitialArcadixNoofVertices !== undefined && InitialArcadixNoofVertices !== "") {
A = parseInt(InitialArcadixNoofVertices);
}
var arrCollection = [];
var points = [];
var getMouseCoords = function (e, i) {
var cPos = board.getCoordsTopLeftCorner(e, i),
absPos = JXG.getPosition(e, i),
dx = absPos[0] - cPos[0],
dy = absPos[1] - cPos[1];
return new JXG.Coords(JXG.COORDS_BY_SCREEN, [dx, dy], board);
},
down = function (e) {
var canCreate = true, i, coords, el;
if (e[JXG.touchProperty]) {i = 0}
coords = getMouseCoords(e, i);
if (canCreate) {
var strCoOrdinates = coords.usrCoords[1] + "," + coords.usrCoords[2]
if (arrCollection.length < A) {
arrCollection.push(strCoOrdinates);
points.push(board.create('point', [coords.usrCoords[1], coords.usrCoords[2]], { snapToGrid: true, color: JXG.hsv2rgb(col[icol],1,1) }));
icol++;
}
if (arrCollection.length == A) {
var poly = board.create('polygon', points, {withLines: false, fillColor:'transparent' });
var ds= [];
for(var k=0; k <A; k++){
ds.push(poly.vertices[k].X());
ds.push(poly.vertices[k].Y());
}
ResultArcadixCoords = ds;
}
}
}
board.on('up', down);
board.update();
}
function resetTask() {
JXG.JSXGraph.freeBoard(board);
main();
}
main();