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 :

Supprimer et restaurer un élément du DOM avec des effets de fondu


Sujet :

jQuery

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Futur Membre du Club
    Homme Profil pro
    Développeur Web
    Inscrit en
    Novembre 2021
    Messages
    10
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 31
    Localisation : Côte d'Ivoire

    Informations professionnelles :
    Activité : Développeur Web
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Novembre 2021
    Messages : 10
    Points : 9
    Points
    9
    Par défaut Supprimer et restaurer un élément du DOM avec des effets de fondu
    J'essaie de créer un modal personnalisé, ce qui fonctionne bien car ce que je veux obtenir, c'est de cliquer sur X qui supprime complètement l'élément du DOM, je veux pas cacher l'élément dans le DOM, puis de cliquer sur ajouter pour le restaurer, mais je veux maintenant ajouter des effets de fondu et de fondu lors de la restauration et de la fermeture ou suppression du modal, ajouté à cela, le modal s'affiche déjà lors du chargement de la page, je souhaite qu'il ne s'affiche que lorsque vous cliquez sur le bouton "add". Quelqu'un peut-il m'aider s'il vous plaît, je suis un apprenant et un débutant ainsi, s'il vous plaît.
    J'ai un exemple de ce que je veux sur http://jsfiddle.net/dLdFZ/16/

    JS
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    $(document).ready(function() {
      var toBeDeleted = $('.modal-backdrop');
      $('.blu-modal__close').on('click', function(event) {
        event.preventDefault();
        $(toBeDeleted).detach();
      });
      $('#buttonAdd').on('click', function(event) {
        event.preventDefault();
        if ($('body').find('.modal-backdrop').length == 0) {
          $('body').append(toBeDeleted);
        }
      });
    });
    Code CSS : 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
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    .modal-backdrop {
      z-index: 4000;
    }
     
    .blu-modal__container {
      -webkit-transition: opacity .3s ease;
      transition: opacity .3s ease;
      width: 90%;
      max-width: 500px;
      height: auto;
      background: #fff;
      position: fixed;
      z-index: 1000;
    }
     
    @media screen and (min-width: 769px),
    print {
      .blu-modal__container {
        top: 50%;
        left: 50%;
        -webkit-transform: translate(-50%, -50%);
        transform: translate(-50%, -50%);
      }
    }
     
    .blu-modal.b-page .blu-modal__container {
      max-height: calc(100% - 50px);
      padding-top: 16px;
    }
     
    @media screen and (min-width: 769px),
    print {
      .blu-modal.b-page .blu-modal__container {
        border-radius: 16px;
      }
    }
     
    .blu-modal.b-page .blu-modal__container {
      width: 480px;
    }
     
    .b-page .blu-modal__close {
      position: absolute;
      top: -20px;
      right: 20px;
    }
     
    .b-page .blu-modal__close i:before,
    .b-page .blu-modal__close i:after {
      content: '';
      width: 20px;
      height: 4px;
      border-radius: 4px;
      background-color: #f1f1f1;
      position: absolute;
    }
     
    .b-page .blu-modal__close i:before {
      -webkit-transform: rotate(45deg);
      transform: rotate(45deg);
    }
     
    .b-page .blu-modal__close i:after {
      -webkit-transform: rotate(-45deg);
      transform: rotate(-45deg);
    }
     
    @media screen and (min-width: 769px),
    print {
      .blu-modal.b-page .blu-modal__header {
        padding: 0 32px;
      }
    }
     
    .blu-modal__heading {
      font-family: "efframedium", Helvetica, Arial, sans-serif;
      margin-bottom: 10px;
    }
     
    .modal-backdrop .modal__header {
      display: -ms-flexbox;
      display: flex;
    }
     
    .modal-backdrop .modal__header__image {
      margin-right: 20px;
      width: 100px;
      height: 100px;
      border-radius: 10px;
      background-color: #ffffff;
    }
     
    .modal-backdrop .modal__header__image img {
      max-height: 100px;
      min-width: 100px;
    }
     
    .modal-backdrop .modal__header__name-attr {
      -ms-flex-direction: column;
      flex-direction: column;
      margin: auto 0;
    }
     
    .modal-backdrop .modal__header__name-attr__attribute {
      font-size: 1.4rem;
      font-weight: 500;
      color: #BDBDBD;
    }
     
    .blu-modal__body {
      overflow-x: auto;
      color: rgba(0, 0, 0, 0.6);
    }
     
    @media screen and (min-width: 769px),
    print {
      .blu-modal__body {
        max-height: calc(100vh - 230px);
      }
    }
     
    .blu-modal.b-page .blu-modal__body {
      color: rgba(0, 0, 0, 0.6);
    }
     
    @media screen and (min-width: 769px),
    print {
      .blu-modal.b-page .blu-modal__body {
        padding: 0 32px;
      }
    }
     
    .modal-backdrop .modal__body {
      display: -ms-flexbox;
      display: flex;
      -ms-flex-direction: column;
      flex-direction: column;
      padding-top: 10px;
    }
     
    .modal-backdrop .modal__body__detail {
      margin-bottom: 15px;
    }
     
    .attributes__section {
      width: 100%;
      margin-bottom: 5px;
    }
     
    .attributes--label-with-value {
      display: -ms-flexbox;
      display: flex;
    }
     
    .attributes--label {
      -webkit-backdrop-filter: blur(4px);
      backdrop-filter: blur(4px);
      color: rgba(0, 0, 0, 0.48);
      font-size: 16px;
      font-weight: bold;
      vertical-align: top;
      line-height: normal;
    }
     
    .attributes--value {
      overflow: scroll;
      vertical-align: top;
      font-size: 16px;
      padding: 6px;
      color: #0095da;
    }
     
    .b-flex {
      display: -webkit-box;
      display: -ms-flexbox;
      display: flex;
    }
     
    @media only screen and (min-width: 63.75em) {
      .product-variant__color__thumb__wrapper {
        overflow: auto;
      }
    }
     
    .product-variant__color__thumb {
      cursor: pointer;
      margin: 2px;
      display: -ms-inline-flexbox;
      display: inline-flex;
    }
     
    @media only screen and (min-width: 63.75em) {
      <style>.product-variant__color__thumb {
        min-width: 60px;
        margin: 8px;
        display: -ms-inline-grid;
        display: inline-grid;
      }
    }
     
    .product-variant__image {
      background-color: #fff;
      border: 2px solid #E0E0E0;
      border-radius: 8px;
    }
     
    @media only screen and (min-width: 63.75em) {
      .product-variant__image {
        overflow: auto;
        width: 60px;
        height: 60px;
      }
    }
     
    .product-variant__image__selected {
      border-color: #41C3FF;
    }
     
    .modal-backdrop .modal__body__price-qty {
      display: -ms-flexbox;
      display: flex;
      margin-bottom: 15px;
    }
     
    .modal-backdrop .modal__body__price-qty__price__display {
      font-size: 20px;
      font-weight: 600;
      font-style: normal;
      font-stretch: normal;
      line-height: normal;
      letter-spacing: normal;
      color: #f37021;
    }
     
    .modal-backdrop .modal__body__price-qty__price__display__list {
      color: rgba(0, 0, 0, 0.48);
      font-size: 15px;
      text-decoration: line-through;
    }
     
    .modal-backdrop .modal__body__price-qty__quantity {
      display: -ms-flexbox;
      display: flex;
      margin-left: auto;
    }
     
    .blu-modal__footer {
      text-align: right;
    }
     
    @media screen and (min-width: 769px),
    print {
      .blu-modal.b-page .blu-modal__footer {
        padding: 16px 32px;
      }
    }
     
    .blu-modal__mask {
      -webkit-transition: opacity .3s ease;
      transition: opacity .3s ease;
      position: fixed;
      z-index: 999;
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;
      background-color: rgba(0, 0, 0, 0.64);
      display: -webkit-box;
      display: -ms-flexbox;
      display: flex;
      -webkit-box-orient: vertical;
      -webkit-box-direction: normal;
      -ms-flex-direction: column;
      flex-direction: column;
      -webkit-box-pack: center;
      -ms-flex-pack: center;
      justify-content: center;
      -webkit-box-align: center;
      -ms-flex-align: center;
      align-items: center;
    }

    Code html : 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
    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
     
    <body>
     
      <button type="button" class="" id="buttonAdd">Add</button>
     
      <div class="blu-modal modal-backdrop b-page">
        <div class="blu-modal__container">
          <button class="blu-modal__close">
                <i></i>
            </button>
          <div class="blu-modal__header">
            <div class="blu-modal__icon"></div>
            <h3 class="blu-modal__heading">
              <div class="modal__header">
                <div class="modal__header__image">
                  <img src="https://www.static-src.com/wcsstore/Indraprastha/images/catalog/full//90/MTA-11741139/apple_iphone_12_mini_128gb_resmi_full05_mz4v26r0.jpg?output-format=webp" data-src="https://www.static-src.com/wcsstore/Indraprastha/images/catalog/full//90/MTA-11741139/apple_iphone_12_mini_128gb_resmi_full05_mz4v26r0.jpg?output-format=webp"
                    alt="iPhone 12 Mini 128GB Resmi" class="lazyImage" draggable="false" data-loaded="true">
                </div>
                <div class="modal__header__name-attr">
                  <div class="modal__header__name-attr__name"> iPhone 12 Mini 128GB Resmi </div>
                  <div class="modal__header__name-attr__attribute"> Red </div>
                </div>
              </div>
            </h3>
          </div>
          <div class="blu-modal__body">
            <div class="modal__body">
              <div class="modal__body__detail">
                <div class="modal__body__detail__attribute">
                  <div>
                    <!---->
                  </div>
                  <div>
                    <div id="attributes">
                      <div>
                        <div class="attributes__section">
                          <div class="attributes--label-with-value">
                            <div class="attributes--label">Warna</div>
                            <div class="attributes--label"> : Red </div>
                            <!---->
                          </div>
                          <div class="attributes--value">
                            <div>
                              <div class="product-variant__color__thumb__wrapper b-flex">
                                <figure class="product-variant__color__thumb">
                                  <img src="https://www.static-src.com/wcsstore/Indraprastha/images/catalog/thumbnail//90/MTA-11741139/apple_iphone_12_mini_128gb_resmi_full06_s5xmq8zt.jpg" alt="White" class="product-variant__image">
                                </figure>
                                <figure class="product-variant__color__thumb">
                                  <img src="https://www.static-src.com/wcsstore/Indraprastha/images/catalog/thumbnail//90/MTA-11741139/apple_iphone_12_mini_128gb_resmi_full05_mz4v26r0.jpg" alt="Red" class="product-variant__image product-variant__image__selected">
                                </figure>
                                <figure class="product-variant__color__thumb">
                                  <img src="https://www.static-src.com/wcsstore/Indraprastha/images/catalog/thumbnail//90/MTA-11741139/apple_iphone_12_mini_128gb_resmi_full03_tdkcqg4k.jpg" alt="Green" class="product-variant__image">
                                </figure>
                                <figure class="product-variant__color__thumb">
                                  <img src="https://www.static-src.com/wcsstore/Indraprastha/images/catalog/thumbnail//90/MTA-11741139/apple_iphone_12_mini_128gb_resmi_full02_ftornd3v.jpg" alt="Blue" class="product-variant__image">
                                </figure>
                                <figure class="product-variant__color__thumb">
                                  <img src="https://www.static-src.com/wcsstore/Indraprastha/images/catalog/thumbnail//90/MTA-11741139/apple_iphone_12_mini_128gb_resmi_full01_ee17vwzj.jpg" alt="Black" class="product-variant__image">
                                </figure>
                              </div>
                              <div></div>
                            </div>
                          </div>
                        </div>
                      </div>
                    </div>
                  </div>
                </div>
                <hr>
              </div>
              <div 2f0="" class="modal__body__price-qty">
                <div class="modal__body__price-qty__price">
                  <div>
                    <strong class="modal__body__price-qty__price__display"> Rp11.548.000 </strong>
                  </div>
                  <div>
                    <strong class="modal__body__price-qty__price__display__list"> Rp16.999.000 </strong>
                  </div>
                </div>
                <div class="modal__body__price-qty__quantity">
                  <button type="button" class="quantity-input-btn qtyminus btn-number input-box" field="quantity" data-id="1696">
                                <span class="fa fa-minus"></span>
                            </button>
                  <input type="number" min="1" class="quantity-input-value input-box" id="qty_1697" value="1">
                  <button type="button" class="quantity-input-btn qtyplus btn-number input-box" field="quantity" data-id="1696">
                                <span class="fa fa-plus"></span>
                            </button>
                </div>
              </div>
              <div class="modal__body__add-to-cart">
                <button type="button" class="blu-btn modal__body__add-to-cart__button b-full-width b-secondary">
                            <div class="blu-ripple">Tambah ke Bag </div>
                        </button>
              </div>
            </div>
          </div>
          <div class="blu-modal__footer"></div>
        </div>
        <div class="blu-modal__mask"></div>
      </div>
    </body>

  2. #2
    Rédacteur/Modérateur

    Avatar de SpaceFrog
    Homme Profil pro
    Développeur Web Php Mysql Html Javascript CSS Apache - Intégrateur - Bidouilleur SharePoint
    Inscrit en
    Mars 2002
    Messages
    39 640
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 74
    Localisation : Royaume-Uni

    Informations professionnelles :
    Activité : Développeur Web Php Mysql Html Javascript CSS Apache - Intégrateur - Bidouilleur SharePoint
    Secteur : Industrie

    Informations forums :
    Inscription : Mars 2002
    Messages : 39 640
    Points : 66 665
    Points
    66 665
    Billets dans le blog
    1
    Par défaut
    Regarde plus simplement du coté de fadeIn(), fadeOut() de JQuery
    https://api.jquery.com/fadein/
    https://api.jquery.com/fadeout/

  3. #3
    Membre éclairé
    Homme Profil pro
    Webdesigner
    Inscrit en
    Juin 2014
    Messages
    427
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 64
    Localisation : France, Hautes Pyrénées (Midi Pyrénées)

    Informations professionnelles :
    Activité : Webdesigner
    Secteur : Associations - ONG

    Informations forums :
    Inscription : Juin 2014
    Messages : 427
    Points : 859
    Points
    859
    Par défaut
    Bonjour. Ce que tu désires se fait simplement par un changement de classe en JS

    Un exemple :

    Code html : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    <style type="text/css">
    #evolution {
        background-color: #fde;
        transform: scaleX(1);
        transition: all 0.5s;
    } 
    #evolution.hide {  transform: scaleX(0); }
    </style>

    Code html : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    <div id=evolution>
        Mon div évolue !
    </div>
    <input type=button onclick="document.getElementById('evolution').classList.toggle('hide')" value="change mon div">

Discussions similaires

  1. [Python 3.X] Générer un DOM avec des attributes "class"
    Par totoro73 dans le forum Général Python
    Réponses: 3
    Dernier message: 01/02/2019, 09h57
  2. Récupération élément du DOM avec getElementById
    Par paulolol dans le forum Général JavaScript
    Réponses: 3
    Dernier message: 18/10/2015, 15h02
  3. Réponses: 0
    Dernier message: 07/03/2013, 11h27
  4. GWT avec des effets mootools ?
    Par pigpen dans le forum GWT et Vaadin
    Réponses: 2
    Dernier message: 23/12/2009, 14h30

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