Valid XHTML     Valid CSS2    

Listing du fichier bouger.js

 

00001     var appui=false , cible="" , xd2=0 , yd2=0 , xd1=0 , yd1=0 , coeffs = new Array();
00002     
00003     function deplacer(evt) {
00004      if (!appui)
00005      return
00006      var xm = evt.clientX;
00007      var ym = evt.clientY;
00008      if ((xm<=5)||(xm>=495)||(ym<=5)||(ym>=395))
00009      {
00010      appui=false;
00011      return;
00012      }
00013      if ((cible != "rectangle")&&(cible != "cercle"))
00014      return
00015      svgdoc = evt.target.ownerDocument;
00016      coeffs[4] = xm + xd1 - xd2;
00017      coeffs[5] = ym + yd1 - yd2;
00018      if (cible=="rectangle")
00019      {
00020      if (coeffs[4] < 0)
00021      coeffs[4] = 0
00022      if (coeffs[4] > 400)
00023      coeffs[4] = 400
00024      if (coeffs[5] < 0)
00025      coeffs[5] = 0
00026      if (coeffs[5] > 350)
00027      coeffs[5] = 350
00028      };
00029      if (cible=="cercle")
00030      {
00031      if (coeffs[4] < 50)
00032      coeffs[4] = 50
00033      if (coeffs[4] > 450)
00034      coeffs[4] = 450
00035      if (coeffs[5] < 50)
00036      coeffs[5] = 50
00037      if (coeffs[5] > 350)
00038      coeffs[5] = 350
00039      }
00040      var chaine = "matrix(" + coeffs.join(" ") + ")";
00041      svgdoc.getElementById(cible).setAttributeNS(null , "transform" , chaine)
00042     } ; // fin de fonction deplacer
00043     
00044     function cliquer(evt) {
00045      cible=evt.target.getAttributeNS(null , "id");
00046      if ((cible=="rectangle")||(cible=="cercle")) {
00047      appui=true;
00048      xd2 = evt.clientX;
00049      yd2 = evt.clientY;
00050      var transfo = evt.target.getAttributeNS(null , "transform")
00051      transfo = transfo.substring(7 , transfo.length - 1)
00052     // Firefox return , as separator in transform attribute
00053      if (transfo.indexOf(",") > 0)
00054      coeffs = transfo.split(",")
00055      else
00056      coeffs = transfo.split(" ")
00057      xd1 = parseInt(coeffs[4]);
00058      yd1 = parseInt(coeffs[5]);
00059      }
00060     } ; // fin de fonction cliquer

Pour ne pas voir les numéros de ligne, ajoutez &nl=non à la suite du nom du fichier.

 

 

retour gH    Retour à la page principale de   (gH)