Visualizzazione dei risultati da 1 a 3 su 3

Hybrid View

  1. #1
    Utente di HTML.it
    Registrato dal
    Oct 2003
    Messaggi
    311

    aggiungere swipe a lightbox2

    ciao,
    premetto che non sono ferrato con questo linguaggio.. è per questo che vi chiedo aiuto.
    Ho utilizzato per molto tempo Lightbox per visualizzare immagini ingrandite etc... purtroppo però non è nativo per il swipe (per i dispositivi portatili).
    So che ci sono molte alternative, ma vorrei continuare ad utilizzare questo anche perchè con gli altri ho sempre qualche problema (compatibilità con altri script ed altro).
    Gira e rigira credo di aver trovato un post su un forum dove spiegano come implementare la funzione di swipe nello script... solo che io non so farlo...

    Non credo di poter postare il link della board perciò cerco di ritrascriverlo qui:
    _______________________________________

    To summary, you must hide the navigation buttons and implement swiping, moving and sliding effect on the image.
    You will need:
    - jquery.event.move (con link)
    - jquery.event.swipe (con link)
    - jquery ui slide effect, you can package it in the jquery ui download builder (con link)

    maybe there's a simplest way to get/implement all of these 3 small dependencies... but that way works for me.
    In the lightbox script, add a new LightboxOptions "enableSwipeOnTouchDevices" and set it to true:
    codice:
    this.enableSwipeOnTouchDevices   =true;
    add the following blocks after the "this.$lightbox.find('.lb-next').on('click'..." block to create the swiping events:
    codice:
    this.$lightbox.find('.lb-image').on("swiperight",function() {
         $('.lb-image').effect("slide", { "direction" : "right",  "mode" : "hide"} ,function(){
             if (self.currentImageIndex === 0) {
               self.changeImage(self.album.length - 1);
             } else {
               self.changeImage(self.currentImageIndex - 1);
             }
         })
     });
       this.$lightbox.find('.lb-image').on("swipeleft",function() {
           $('.lb-image').effect("slide", { "direction" : "left",  "mode" : "hide"} ,function(){
             if (self.currentImageIndex === self.album.length - 1) {
               self.changeImage(0);
             } else {
               self.changeImage(self.currentImageIndex + 1);
             }
         })
     });
    and rewrite the "updateNav" function like this to hide the navigation buttons:
    codice:
    Lightbox.prototype.updateNav = function() {
       // Check to see if the browser supports touch events. If so, we take the conservative approach
       // and assume that mouse hover events are not supported and always show prev/next navigation
       // arrows in image sets.
       var alwaysShowNav = false;
       var enableSwipe = false;
       try {
         document.createEvent("TouchEvent");
         alwaysShowNav = (this.options.alwaysShowNavOnTouchDevices)? true: false;
         enableSwipe =  (this.options.enableSwipeOnTouchDevices)? true: false;
       } catch (e) {}
           //if swiping is enable, hide the two navigation buttons
         if (! enableSwipe) {
           this.$lightbox.find('.lb-nav').show();
            if (this.album.length > 1) {
             if (this.options.wrapAround) {
               if (alwaysShowNav) {
                 this.$lightbox.find('.lb-prev, .lb-next').css('opacity', '1');
               }
               this.$lightbox.find('.lb-prev, .lb-next').show();
             } else {
               if (this.currentImageIndex > 0) {
                 this.$lightbox.find('.lb-prev').show();
                 if (alwaysShowNav) {
                   this.$lightbox.find('.lb-prev').css('opacity', '1');
                 }
               }
               if (this.currentImageIndex < this.album.length - 1) {
                 this.$lightbox.find('.lb-next').show();
                 if (alwaysShowNav) {
                   this.$lightbox.find('.lb-next').css('opacity', '1');
                 }
               }
             }
           }
       }
     };

  2. #2
    Utente di HTML.it
    Registrato dal
    Oct 2003
    Messaggi
    311
    nessuno può aiutarmi ?

  3. #3
    Moderatore di Annunci siti web, Offro lavoro/collaborazione, Cerco lavoro L'avatar di cavicchiandrea
    Registrato dal
    Aug 2001
    Messaggi
    26,133
    Quote Originariamente inviata da aux998 Visualizza il messaggio
    nessuno può aiutarmi ?
    L'integrazione richiedono conoscenze dei due script tempo e voglia devi avare tanta pazienza o passare ad altro (che ti consiglio se vuoi risolvere)
    Cavicchi Andrea
    Problemi con javascript, jquery, ajax clicca qui

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.