Commit 84a1ca50 authored by Jérémie Garcia's avatar Jérémie Garcia
Browse files

minor cleanups

parent 2fa726d4
WOB/qr_code.png

510 Bytes | W: | H:

WOB/qr_code.png

627 Bytes | W: | H:

WOB/qr_code.png
WOB/qr_code.png
WOB/qr_code.png
WOB/qr_code.png
  • 2-up
  • Swipe
  • Onion skin
......@@ -84,7 +84,7 @@ Traj.Events = {
},
handleMove : function(evt) {
if (Traj.View.touchState === '1touch') { // CAS 1 doigt
if (Traj.Events.drawing) { // CAS DESSIN
......@@ -104,16 +104,18 @@ Traj.Events = {
}
} else { // CAS TRANSLATION
if (Traj.Events.transformation == '1touch') {//Traj.Events.isTransforming) {
if (Traj.Events.transformation == '1touch')
{
var evt_pos = Traj.Utils.event2CanvasPos(evt.changedTouches[0]),
coords = Traj.Utils.convertCanvasPosIntoUnits(evt_pos),
lastCoords = Traj.Utils.convertCanvasPosIntoUnits(Traj.View.last_event_pos),
translateXY = [coords[0] - lastCoords[0], coords[1] - lastCoords[1]],
curve = Traj.Manager.trajectories[Traj.Manager.currentCurveIndex];
coords = Traj.Utils.convertCanvasPosIntoUnits(evt_pos),
lastCoords = Traj.Utils.convertCanvasPosIntoUnits(Traj.View.last_event_pos),
translateXY = [coords[0] - lastCoords[0], coords[1] - lastCoords[1]],
curve = Traj.Manager.trajectories[Traj.Manager.currentCurveIndex];
if(curve){
curve.translate(translateXY[0] + curve.X[0],translateXY[1] + curve.Y[0],curve.Z[0]);
}
Traj.View.current_repaint();
Traj.View.last_event_pos = evt_pos;
}
......@@ -159,60 +161,60 @@ Traj.Events = {
lastFactor = factor; // save last transformation factor
Traj.View.current_repaint();
evt.preventDefault();
return false;
}
evt.preventDefault();
return false;
}
},
handleEnd : function(evt) { // BUG POSSIBLE LORSQU'ON LACHE PLUSIEURS DOIGTS EN MÊME TEMPS (jamais arrivé pour l'instant...)
// L'iPad semble plus souvent regrouper les touchés que l'android
//if (Traj.Events.drawing) {
var touches = evt.changedTouches;
var nbTouch = evt.touches.length;
if (!Traj.Events.drawing && !Traj.Events.isTransforming) {
if (!Traj.Events.drawing && !Traj.Events.isTransforming) {
clearTimeout(Traj.Events.idSetTimeoutTransformation);
var evt_pos = Traj.Utils.event2CanvasPos(evt.changedTouches[0]);
var coords = Traj.Utils.convertCanvasPosIntoUnits(evt_pos);
Traj.View.traj_repaint();
var curveSelected = Traj.Manager.getClosestCurveFromTouch(coords);
var evt_pos = Traj.Utils.event2CanvasPos(evt.changedTouches[0]),
coords = Traj.Utils.convertCanvasPosIntoUnits(evt_pos),
curveSelected = Traj.Manager.getClosestCurveFromTouch(coords);
Traj.Manager.selectCurve(curveSelected);
}
for (var k=0; k<evt.changedTouches.length;k++) { // boucle sur tous les touchés
if (evt.changedTouches[k].identifier == Traj.Events.touchId) { // si c'est le 1e touché qui est laché (sert à ne pas prendre en compte le laché du zSlider par exemple)
var i = 0;
var coords = Traj.Utils.convertCanvasPosIntoUnits(Traj.Utils.event2CanvasPos(touches[i]));
var z = Traj.Events.getZSliderValue()||0;
var t = Math.floor(evt.timeStamp);
if (evt.changedTouches[k].identifier == Traj.Events.touchId) { // si c'est le 1e touché qui est laché (sert à ne pas prendre en compte le laché du zSlider par exemple)
var i = 0;
var coords = Traj.Utils.convertCanvasPosIntoUnits(Traj.Utils.event2CanvasPos(touches[i]));
var z = Traj.Events.getZSliderValue()||0;
var t = Math.floor(evt.timeStamp);
if (Traj.Events.drawing) { // CAS DESSIN
if (!Traj.Events.rangeSlider) {
if (Traj.Events.drawing) { // CAS DESSIN
if (!Traj.Events.rangeSlider) {
Traj.Manager.processEndCurve(coords[0], coords[1], z, t); // cas dessin normal
} else {
Traj.Manager.processModifyCurve(coords[0], coords[1], z, t); // cas "redraw"
}
}
Traj.View.touchState = 'wait';
if (Traj.Events.isTransforming) { // CAS TRANSFORMATION
Traj.Events.isTransforming = false;
Traj.Manager.currentCurve = null;
Traj.View.traj_repaint();
Traj.View.dyn_repaint();
}
}
Traj.View.touchState = 'wait';
} else if (Traj.View.touchState === '1touch') { // 1 doigt => passage à 0 doigt
Traj.Events.transformation = null;
Traj.View.touchState = 'wait';
if (Traj.Events.isTransforming) { // CAS TRANSFORMATION
Traj.Events.isTransforming = false;
Traj.Manager.currentCurve = null;
Traj.View.traj_repaint();
Traj.View.dyn_repaint();
} else if (Traj.View.touchState === '2touch') { // 2 doigt => passage à 1 doigt
Traj.View.touchState = '1touch';
} else if (Traj.View.touchState === '3touch') { // 3 doigt => passage à 2 doigt
Traj.View.touchState = '2touch';
}
}
} else if (Traj.View.touchState === '1touch') { // 1 doigt => passage à 0 doigt
Traj.Events.transformation = null;
Traj.View.touchState = 'wait';
Traj.View.dyn_repaint();
} else if (Traj.View.touchState === '2touch') { // 2 doigt => passage à 1 doigt
Traj.View.touchState = '1touch';
} else if (Traj.View.touchState === '3touch') { // 3 doigt => passage à 2 doigt
Traj.View.touchState = '2touch';
}
}
Traj.View.traj_repaint();
Traj.View.ongoingTouches = [];
evt.preventDefault();
......@@ -224,7 +226,7 @@ Traj.Events = {
},
handleCancel : function(evt) { // prévoir ce cas comme celui d'un touchEnd ?
evt.preventDefault();
evt.preventDefault();
},
// FOR LONG TOUCH MENU
......@@ -389,11 +391,11 @@ Traj.Events = {
Traj.Events.rangeSlider = range; // true si c'est un range slider
if (range) {this.setSliderValue('0,100')}
if (document.getElementById("flip-timeSlider").value == 'on') {
$("#slider-div").show();
} else {
$("#slider-div").hide();
}
if (document.getElementById("flip-timeSlider").value == 'on') {
$("#slider-div").show();
} else {
$("#slider-div").hide();
}
//this.sliderOnChange();
Traj.View.bg_repaint();
},
......@@ -411,7 +413,7 @@ Traj.Events = {
return values;
} else {
if (slider)
return Number(slider.getValue());
return Number(slider.getValue());
}
},
......@@ -467,7 +469,7 @@ Traj.Events = {
setZSliderValue : function(value) {
var slider = Traj.Events.zSlider;
if (slider) {
slider.setValue(value);
slider.setValue(value);
}
},
......@@ -642,8 +644,8 @@ Traj.Events = {
selectSourceButton : function(sourceNumber) {
// change the apparence of the sources buttons
var buttons = document.getElementsByClassName('sourceButton');
for (var k=0;k<buttons.length;k++) {
var buttons = document.getElementsByClassName('sourceButton');
for (var k=0;k<buttons.length;k++) {
buttons[k].style.borderColor='transparent';
}
if (sourceNumber<9) {
......@@ -658,23 +660,23 @@ Traj.Events = {
divMenu.style.zIndex = 4;
var circularButton = document.getElementById('circularButton'),
concatButton = document.getElementById('concatButton');
handleTouchCircular = function() {
Traj.Manager.processMakeCircular();
concatButton = document.getElementById('concatButton');
handleTouchCircular = function() {
Traj.Manager.processMakeCircular();
Traj.Events.hideContextMenu();
},
handleTouchConcat = function() {
var curve = Traj.Manager.trajectories[Traj.Manager.modifiedCurve];
if (curve) {
var length = curve.X.length-1;
Traj.Manager.clipboardCurve = Traj.Manager.trajectories[Traj.Manager.currentCurveIndex];
Traj.Manager.pasteInCurve(curve,length,length);
Traj.Events.hideContextMenu();
},
handleTouchConcat = function() {
var curve = Traj.Manager.trajectories[Traj.Manager.modifiedCurve];
if (curve) {
var length = curve.X.length-1;
Traj.Manager.clipboardCurve = Traj.Manager.trajectories[Traj.Manager.currentCurveIndex];
Traj.Manager.pasteInCurve(curve,length,length);
Traj.Events.hideContextMenu();
} else {
handleTouchNew();
}
};
} else {
handleTouchNew();
}
};
circularButton.addEventListener(Traj.Utils.getStartEventName(),handleTouchCircular,false);
concatButton.addEventListener(Traj.Utils.getStartEventName(),handleTouchConcat,false);
......@@ -688,8 +690,8 @@ Traj.Events = {
showContextMenu : function(circular, concat) {
if(circular||concat){
var divMenu = document.getElementById("contextMenu"),
curve = Traj.Manager.trajectories[Traj.Manager.currentCurveIndex],
pos = Traj.Utils.convertUnitsIntoCanvasPos([curve.X[curve.X.length-1],curve.Y[curve.X.length-1]]);
curve = Traj.Manager.trajectories[Traj.Manager.currentCurveIndex],
pos = Traj.Utils.convertUnitsIntoCanvasPos([curve.X[curve.X.length-1],curve.Y[curve.X.length-1]]);
if(circular&&concat){
......@@ -732,11 +734,11 @@ Traj.Events = {
!document.mozFullScreenElement && !document.webkitFullscreenElement) { // current working methods
if (document.documentElement.requestFullscreen) {
document.documentElement.requestFullscreen();
} else if (document.documentElement.mozRequestFullScreen) {
} else if (document.documentElement.mozRequestFullScreen) {
document.documentElement.mozRequestFullScreen();
} else if (document.documentElement.webkitRequestFullscreen) {
} else if (document.documentElement.webkitRequestFullscreen) {
document.documentElement.webkitRequestFullscreen(Element.ALLOW_KEYBOARD_INPUT);
}
}
// } else {
// if (document.cancelFullScreen) {
// document.cancelFullScreen();
......@@ -745,37 +747,37 @@ Traj.Events = {
// } else if (document.webkitCancelFullScreen) {
// document.webkitCancelFullScreen();
// }
}
},false);
},
addPlayPauseEvent : function() {
var playButton = document.getElementById('playButton');
var multiplayButton = document.getElementById('multiplayButton');
var playPause = function() {
if (playButton.innerHTML == 'Play') {
Traj.Player.play();
playButton.innerHTML = 'Pause';
} else {
Traj.Player.stopCurrentCurve();
playButton.innerHTML = 'Play';
}
};
var multiplay = function() {
if (multiplayButton.innerHTML == 'Multi') {
var indexes = Traj.Manager.getMultiPlayIndexes();
Traj.Player.playCurves(indexes);
multiplayButton.innerHTML = 'Pause';
} else {
Traj.Player.stopCurrentCurve();
multiplayButton.innerHTML = 'Multi';
}
}
},false);
},
addPlayPauseEvent : function() {
var playButton = document.getElementById('playButton');
var multiplayButton = document.getElementById('multiplayButton');
var playPause = function() {
if (playButton.innerHTML == 'Play') {
Traj.Player.play();
playButton.innerHTML = 'Pause';
} else {
Traj.Player.stopCurrentCurve();
playButton.innerHTML = 'Play';
}
};
var multiplay = function() {
if (multiplayButton.innerHTML == 'Multi') {
var indexes = Traj.Manager.getMultiPlayIndexes();
Traj.Player.playCurves(indexes);
multiplayButton.innerHTML = 'Pause';
} else {
Traj.Player.stopCurrentCurve();
multiplayButton.innerHTML = 'Multi';
}
}
playButton.addEventListener(Traj.Utils.getStartEventName(),playPause,false);
multiplayButton.addEventListener(Traj.Utils.getStartEventName(),multiplay,false);
},
playButton.addEventListener(Traj.Utils.getStartEventName(),playPause,false);
multiplayButton.addEventListener(Traj.Utils.getStartEventName(),multiplay,false);
},
////////////////////////////////////
////////// CALLED FROM HTML ////////
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment