0
0
mirror of https://github.com/Doodle3D/doodle3d-client.git synced 2024-11-21 17:07:55 +01:00

fixed bug which happened if you pressed the move up/down or twist left/right buttons after loading Doodle3D (before drawing anything). Somewhat related: after pressing 'new', the move up/down and twist left/right buttons would show the previous (cached) doodle. Cleared that as well.

This commit is contained in:
Adriaan Wormgoor 2013-10-29 22:08:08 +01:00
parent 176f8f4ae1
commit e7ef6eccc4
3 changed files with 41 additions and 25 deletions

View File

@ -64,7 +64,8 @@ function initButtonBehavior() {
e.preventDefault();
clearInterval(btnOopsInterval);
redrawDoodle(true);
redrawPreview();
renderToImageDataPreview();
// redrawPreview();
}
btnOops.on('touchstart', function(e) { startOops(e); });
btnOops.on('touchend', function(e) { stopOops(e); });
@ -74,17 +75,19 @@ function initButtonBehavior() {
function startMoveUp(e) {
e.preventDefault();
// console.log("btnMoveUp mouse down");
previewUp(true);
clearInterval(btnMoveUpInterval);
btnMoveUpInterval = setInterval( function() {
if (_points.length > 1) {
previewUp(true);
}, 1000/30);
clearInterval(btnMoveUpInterval);
btnMoveUpInterval = setInterval( function() {
previewUp(true);
}, 1000/30);
}
}
function stopMoveUp(e) {
e.preventDefault();
console.log("btnMoveUp mouse up");
// console.log("btnMoveUp mouse up");
clearInterval(btnMoveUpInterval);
previewUp();
if (_points.length > 1) previewUp();
}
btnMoveUp.mousedown(function(e) { startMoveUp(e) });
btnMoveUp.mouseup(function(e) { stopMoveUp(e) });
@ -94,17 +97,19 @@ function initButtonBehavior() {
function startMoveDown(e) {
e.preventDefault();
// console.log("btnMoveDown mouse down");
previewDown(true);
clearInterval(btnMoveDownInterval);
btnMoveDownInterval = setInterval( function() {
if (_points.length > 1) {
previewDown(true);
}, 1000/30);
clearInterval(btnMoveDownInterval);
btnMoveDownInterval = setInterval( function() {
previewDown(true);
}, 1000/30);
}
}
function stopMoveDown(e) {
e.preventDefault();
console.log("btnMoveDown mouse up");
// console.log("btnMoveDown mouse up");
clearInterval(btnMoveDownInterval);
previewDown();
if (_points.length > 1) previewDown();
}
btnMoveDown.mousedown(function(e) { startMoveDown(e) });
btnMoveDown.mouseup(function(e) { stopMoveDown(e) });
@ -114,17 +119,19 @@ function initButtonBehavior() {
function startTwistLeft(e) {
e.preventDefault();
// console.log("btnTwistLeft mouse down");
previewTwistLeft(true);
clearInterval(btnTwistLeftInterval);
btnTwistLeftInterval = setInterval( function() {
if (_points.length > 1) {
previewTwistLeft(true);
}, 1000/30);
clearInterval(btnTwistLeftInterval);
btnTwistLeftInterval = setInterval( function() {
previewTwistLeft(true);
}, 1000/30);
}
}
function stopTwistLeft(e) {
e.preventDefault();
// console.log("btnTwistLeft mouse up");
clearInterval(btnTwistLeftInterval);
previewTwistLeft();
if (_points.length > 1) previewTwistLeft();
}
btnTwistLeft.mousedown(function(e) { startTwistLeft(e) });
btnTwistLeft.mouseup(function(e) { stopTwistLeft(e) });
@ -134,17 +141,19 @@ function initButtonBehavior() {
function startTwistRight(e) {
e.preventDefault();
// console.log("btnTwistRight mouse down");
previewTwistRight(true);
clearInterval(btnTwistRightInterval);
btnTwistRightInterval = setInterval( function() {
if (_points.length > 1) {
previewTwistRight(true);
}, 1000/30);
clearInterval(btnTwistRightInterval);
btnTwistRightInterval = setInterval( function() {
previewTwistRight(true);
}, 1000/30);
}
}
function stopTwistRight(e) {
e.preventDefault();
// console.log("btnTwistRight mouse up");
clearInterval(btnTwistRightInterval);
previewTwistRight();
if (_points.length > 1) previewTwistRight();
}
btnTwistRight.mousedown(function(e) { startTwistRight(e) });
btnTwistRight.mouseup(function(e) { stopTwistRight(e) });
@ -267,6 +276,9 @@ function resetPreview() {
previewCtx.clearRect(0,0,canvas.width, canvas.height);
previewCtx.restore();
// also make new Image, otherwise the previously cached preview can be redrawn with move up/down or twist left/right
doodleImageCapture = new Image();
// reset height and rotation to default values
numLayers = previewDefaults.numLayers; // current number of preview layers
rStep = previewDefaults.rotation; // Math.PI/180; //Math.PI/40; //

View File

@ -22,7 +22,6 @@ function doOnResize() {
redrawDoodle();
redrawPreview();
}
function initLayouting() {

View File

@ -33,8 +33,13 @@ function initPreviewRendering() {
previewCtx_tmp = preview_tmp.getContext('2d');
// doodleImageCapture = new Image();
calcPreviewCanvasProperties();
redrawPreview();
// needed to
// doodleImageCapture = new Image();
}
function calcPreviewCanvasProperties() {
@ -226,7 +231,7 @@ function renderToImageDataPreview() {
// it is assumed that the preview has been rendered to an Image object, which will be used to draw the preview with (much better performance)
function redrawRenderedPreview(redrawLess) {
if (redrawLess == undefined) redrawLess = false;
console.log("f:redrawRenderedPreview()");
// console.log("f:redrawRenderedPreview()");
previewCtx.clearRect(0, 0, preview.width, preview.height);
previewCtx.lineWidth = strokeWidth;