IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

jQuery Discussion :

Fluidité dans mon slider


Sujet :

jQuery

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre habitué
    Profil pro
    Inscrit en
    Janvier 2011
    Messages
    8
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Janvier 2011
    Messages : 8
    Par défaut Fluidité dans mon slider
    bonjour,
    j'ai créer un slider et je rencontre un problème que je n'arrive pas résoudre.
    j'ai utiliser la fonction animate(marginLeft:XX) pour le faire défiler le problème rencontrer au retour en arrière la photo apparaissait directement sans glisser.
    j'ai donc changé de fonction pour utiliser la fonction show(slide),hide(slide) le soucis que j'ai c'est que les photos apparaissent sans glissement, je voudrais le rendre plus fluide.
    visible ici : http://www.larosedelorient.com/slider.php
    merci
    mon code suis
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
     
    <!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.2//EN" "http://www.openmobilealliance.org/tech/DTD/xhtml-mobile12.dtd">
    <html>
    <head>
             <title>slider</title>
             <meta name="viewport" content="width=device-width, initial-scale=1.0" />
             <meta http-equiv="content-type" content="text/html; charset=utf-8" />
             <style type="text/css">
     * {margin:0;padding0;}
         .photo {
     position:relative;
            width: 1170px;  
            height: 640px;
            overflow: hidden;  
     background-color:#777777;margin-left:auto;margin-right:auto;
         }  
     
         .photo ul {  
             /* nombre de photo x 100% */  
            width: 300px;  
            height: 100%;  
            padding:0; margin:0;  
            list-style: none;  
         }  
         .photo li { 
     
            float: left;  
         }  
     img.slider{margin-left:345px;margin-right:345px}
    </style>
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.js"></script>
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.11.2/jquery-ui.js"></script>
    <link rel="stylesheet" type="text/css" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.11.2/themes/smoothness/jquery-ui.css" />
    <script type="text/javascript">
    var numerique=2;
    var chaine='k';
    var identifiant=0;
    var identifiant1='p';
    var identifiant2='l';
    var hautfenetre=640;
    var largfenetre=1170;
    var largmarge=345;
    var largmargephoto=345;
    var largphoto=480;
    var couleurfond="#777777";
     if(window.innerWidth<1190){
    hautfenetre=Math.round((640*(window.innerWidth-20))/1170);
    largmarge=Math.round(345*((640*(window.innerWidth-20))/1170)/640);
    largmargephoto=largmarge;
    largfenetre=window.innerWidth-20;
    largphoto=largfenetre-((345*((640*(window.innerWidth-20))/1170)/640)*2);
    } 
    if(largfenetre<480){
    largmargephoto=0;
    largphoto=largfenetre;
    hautfenetre=Math.round((640*largfenetre)/480);
    couleurfond="#FFFFFF";
    }
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
    $(function(){  
    	$(".photo").css({width:largfenetre,'background-color':couleurfond});
    	$(".photo,.precsuiv").css({height:hautfenetre});
    	$(".precsuiv").css({width:largmarge});
    	$(".slider").css({'margin-left':largmargephoto,'margin-right':largmargephoto,width:largphoto});
     
     
     
     
     
     
     
     
     
     
     
     
     
     
           var refreshIntervalId = setInterval(function(){
    if(identifiant<1 || identifiant>3){
    identifiant=1;
    }
    numerique=identifiant;
    chaine=numerique;
    identifiant1=identifiant;
    identifiant1=identifiant2+numerique;
     
     
     
     
    if(identifiant==1){
    identifiant1=identifiant2+identifiant;
    }
    		$("#"+identifiant1).hide("slide",{direction:"left"},500); /* li cacher */ 
    identifiant=identifiant+1;
    if(identifiant>3){
    identifiant=1;
    }
     
     
    identifiant1=identifiant2+identifiant;
     
    			$("#"+identifiant1).show("slide",{direction:"right"},500); /* li suivante afficher */
     
     
     
     
     
     
    		/* find("li:last").after($(".photo ul").find("li:first")); */
           }, 5000); 
     
     
     
    		/* $(".photo ul li").show("slide",{direction:"right"},500);} */
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
              /*  $('.precsuiv').on('click', function(e) { */
             /*           e.preventDefault(e); */
             /*           clearInterval(refreshIntervalId); */     /* On arrete le setInterval */
             /*           var _width = $(this).attr('data-width'); */
             /*           $(".photo ul").animate({marginLeft: _width},800,function(){  */ 
              /*                        $(this).css({marginLeft:0}).find("li:last").after($(this).find("li:first"));  */ 
               /*         }); */
         /*  refreshIntervalId = setInterval(function(){   */
          /*     $(".photo ul").animate({marginLeft:-1170},800,function(){   */
          /*        $(this).css({marginLeft:0}).find("li:last").after($(this).find("li:first")); */
           /*    })   */
         /*   }, 5000);  */
    /* }); */
        });
    </script>
     
    </head>
    <body>
    <script>document.write("Cette fen&ecirc;tre fait " +largfenetre+ " de large et "+hautfenetre+" de haut la largeur de la marge "+largmarge+" pixel");</script>
             <div id="photo" class="photo">
             <span data-width="-1170" class="precsuiv" style="background: url(images/fleche-gauche.gif) no-repeat 10px center;width:345px;height:100%;position:absolute;z-index:2;cursor:pointer;"></span>
                     <ul id="ul_photo">
                            <li id="l1"><img class="slider" src="images/costume-danse-orientale-voile-rouge-profile.jpg" title="" alt="" /></li>
                            <li id="l2"><img class="slider" src="images/costume-danse-orientale-voile-rouge-dos.jpg" title="" alt="" /></li>
                            <li id="l3"><img class="slider" src="images/costume-danse-orientale-voile-rouge.jpg" title="" alt="" /></li>
                     </ul>
             <span data-width="1170" class="precsuiv" style="background: url(images/fleche-droite.gif) no-repeat 323px center;width:345px;height:100%;position:absolute;top:0;right:0;z-index:2;cursor:pointer;"></span>
             </div>
    </body>
    </html>

  2. #2
    Modérateur

    Avatar de NoSmoking
    Homme Profil pro
    Inscrit en
    Janvier 2011
    Messages
    17 211
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Isère (Rhône Alpes)

    Informations forums :
    Inscription : Janvier 2011
    Messages : 17 211
    Par défaut
    Bonjour,
    je dirais que c’est ton approche qui n'est pas tout à fait la bonne.

    Tes LI doivent restées apparentes mais masquées par le overflow:hidden du conteneur, ensuite tu peux jouer sur la propriété left de l'UL pour déplacer cette "galerie".

    On a discuté sur le forum CSS et j'ai fait une proposition de code qui devrait mieux te montrer l'approche.
    http://www.developpez.net/forums/d14...e/#post8049442

  3. #3
    Membre habitué
    Profil pro
    Inscrit en
    Janvier 2011
    Messages
    8
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Janvier 2011
    Messages : 8
    Par défaut
    merci mais c'est encore pire anim(Left) ne fait aucun glissement

  4. #4
    Modérateur

    Avatar de NoSmoking
    Homme Profil pro
    Inscrit en
    Janvier 2011
    Messages
    17 211
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Isère (Rhône Alpes)

    Informations forums :
    Inscription : Janvier 2011
    Messages : 17 211
    Par défaut
    as tu essayé le code que je t’ai proposé en l'adaptant ?

  5. #5
    Membre habitué
    Profil pro
    Inscrit en
    Janvier 2011
    Messages
    8
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Janvier 2011
    Messages : 8
    Par défaut
    pas le code que tu as essayé mais ton aide m'as permis de me poser les bonnes questions.
    en retirant le overflow:hidden je me suis rendu compte que le glissement avait lieu en dessous dans la zone invisible.
    il manquait un position:absolute; dans mes balise li.
    encore merci.
    sans ton aide je n'aurais pas fait cette vérification.

    à présent reste plus qu'a adapter précédente suivant et faire un drop-drag

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Réponses: 6
    Dernier message: 30/12/2011, 09h35
  2. [Lien]erreur dans mon programme python
    Par durnambule dans le forum Général Python
    Réponses: 11
    Dernier message: 29/01/2004, 14h59
  3. [langage] algo de bissection dans mon code
    Par killy dans le forum Langage
    Réponses: 5
    Dernier message: 19/01/2004, 18h35
  4. Réponses: 7
    Dernier message: 26/06/2003, 09h11
  5. [] Utiliser AVI d'une DLL dans mon programme
    Par seb.49 dans le forum VB 6 et antérieur
    Réponses: 5
    Dernier message: 02/05/2003, 14h52

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo