Hier je me suis lancer dans la création d'une petit application album photo, je voulais en très peu de code obtenir un beau résultat sans pour autant passé par du JQuery, j'ai presque réussi mais j'ai un conflit entre mes fonctions et en plus un très vilain effet pendant le zoom, comme si l'image etait coupé en deux.
Code : Tout sélectionner
<script type="text/javascript">
var centi=0
var secon=0
document.getElementById('ImgZoomCadre').style.height= 0 +'px';
function voirimg(url){
/* je réinitialise les paramètres */
document.getElementById('ImgZoomCadre').style.height= 0 +'px';
document.getElementById('ImgZoomCadre').style.width = 0 + 'px';
document.getElementById('ImgZoomCadre').style.visibility='visible';
document.getElementById('imagevoir').src = url;
relaiZoom();
if (stop) return;
}
function relaiZoom(){
centi++;
var h = document.getElementById('ImgZoomCadre').style.height;
var valeur = h.split (/[a-z]/);
var new_h = parseFloat (valeur[0]) + 5;
document.getElementById('ImgZoomCadre').style.height = new_h + 'px';
var w = document.getElementById('ImgZoomCadre').style.width;
var valeur = w.split (/[a-z]/);
var new_w = parseFloat (valeur[0]) + 5;
document.getElementById('ImgZoomCadre').style.width = new_w + 'px';
if (centi>100){
clearTimeout();
centi=0;
}else{
compte = setTimeout('relaiZoom()',10);
}
}
function cacheimg(){
stop = true;
relaiDeZoom();
}
function relaiDeZoom(){
centi++;
var h = document.getElementById('ImgZoomCadre').style.height;
var valeur = h.split (/[a-z]/);
var new_h = parseFloat (valeur[0]) - 5;
document.getElementById('ImgZoomCadre').style.height = new_h + 'px';
var w = document.getElementById('ImgZoomCadre').style.width;
var valeur = w.split (/[a-z]/);
var new_w = parseFloat (valeur[0]) - 5;
document.getElementById('ImgZoomCadre').style.width = new_w + 'px';
if (centi>100){
clearTimeout();
centi=0;
document.getElementById('ImgZoomCadre').style.visibility='hidden';
}else{
compte = setTimeout('relaiDeZoom()',5);
}
}
</script>
millle merci d'avance pour les améliorations que vous pourriez m'apporter