Das FOTOSWIPE-Plug-In kann den Vollbildmotor auf dem Mobiltelefon vergrößern und auf das Bild doppelklicken, um das Bild zu vergrößern.
FOTOSWIPE Plugin Offizielle Website http://www.photoswipe.com/
Aber eines ist nicht gut. Nachdem Sie das Bild vergrößert haben, können Sie das Browsen nicht schließen. Sie müssen auf die Schaltfläche Schließen oder schieben, um sie zu schließen. Nach langer Zeit haben Sie diesen Punkt immer noch nicht erwähnt. Sie können es nur selbst ändern.
Öffnen Sie fotoswipe.js, es gibt eine Funktionsdefinition zu TAP in Zeile 3179
Definieren Sie am Anfang eine Variable
var tap_num = 0;
Fügen Sie es dann in die Definition von OnTapstart hinzu
// Hinzufügen zu den s, die Sie selbst hinzufügen, entsprechend den Anforderungen // Dokumentieren Sie, ob Sie klicken oder doppelklicken sollen, um Doppelklick zu schließen, um TAP_NUM ++ zu vergrößern. if(tap_num < 2){ setTimeout(function(){ if(tap_num > 1){ tap_num = 0; return; }else{ tap_num = 0; //Defend whether there is drag or not. If there is dragging, close if(_isDragging){ return; }else{ self.close(); } } } },200);}//Add to the E you add by sich selbst nach BedürfnissenWahrscheinlich ist das das Ganze
var taptimer, tapreleaspoint = {}, _dispatchTapeVent = function (OriginEvent, releasepoint, pointertype) {var e = document.creeEvent ('CustOMEvent'), edetail = {original: 'berühren' }; e.initcustomEvent ('pswptap', true, true, edetail); originEvent.target.dispatchEvent (e); }; var tap_num = 0; _registerModule ('tap', {PublicMethods: {Inittap: function () {_listen ('firsttouchstart', self.ontapstart); _Listen ('touchRelease', self.ontaprelease); }); 1) {TAP_NUM = 0; if (! releaspoint) {return; _Shout ('Doubletap', p0); pswp__single-tap if (clickedTagname === 'Taste' || Framework _DispatchTapeVent (E, releasepoint);Komprimieren Sie die modifizierten fotoswipe.js, um die gewünschten Funktionen zu erkennen
Darüber hinaus erfordert die Verwendung von FotosWipe -Plugin das Einfügen von Frameworks und JavaScript -Code, der in einen JS integriert und dann eingeführt werden kann, damit die Seite viel einfacher aussieht.
Schreiben Sie zuerst die Bildalbumstruktur auf die HTML und passen Sie den Stil an
<div id = "Demo-test-galery"> <a href = "https://farm4.staticflickr.com/3894/15008518202_c265dfa55f_h.jpg" datensize = "1600x1600" data-med = "https://farm4.staticflickr.com/3894/15008518202_B016D7D289_B.JPG" data-med-size = "1024x1024"> <img src = "https://farm4.staticflickr.com/3894/15008518202_B016D7D289_M.JPG"/> </a> <a href = "https Data-Size = "1600x1068" data-med = "https://farm6.staticflickr.com/5591/15008867125_68a8ed88cc_b.jpg" data-med-size = "1024x1024"> <imggggg " src = "https://farm6.staticflickr.com/5591/15008867125_68a8ed88cc_m.jpg"/> </a> </div>
Organisierte JS
document.WriteLN ("<!-Root-Element von fotosWipe. Muss die Klasse PSWP. Animation Opacity ist schneller als rgba (). class =/"pswp__Scroll-wrap/"> "); document.writeLn (" <!-Container, der Folien hält. "); document.writeln (" fotoswipe hält nur 3 davon im DOM, um Speicher zu speichern. "); document.writeln (" Don/'t ändern diese 3 Pswp__item. class =/"pswp__Item/"> </div> "); document.writeln (" <div class =/"pswp__Item/"> </div> "); document.writeln (" <div class =/"pswp__Item/"> </div> "); document.writeln (" <<divn ("<divdem (" <divdem/"> </div>"); class =/"pswp__Item/"> </div> "); document.writeLn (" "); document.writeln (" "); document.writeln (" "); document.writeLn (" "); document.writeln (" <!-Standard (fotothywipeui_default). class =/"pswp__ui pswp__Ui-hidden/"> "); document.writeln (" "); document.writeln (" <!-Kontrollen sind selbsterklärend. Order kann geändert werden. class =/"pswp__counter/"> </div> "); document.writeln (" "); document.writeln (" <button class =/"pswp__button pswp__button-closet/" title =/"close (ESC)/"> <// "); pswp__button-share/"title =/" share/"> <// button>"); document.writeln (""); document.writeln ("<button class =/" pswp__button pswp__button-fs/"title Demo http:///codepen.io//dimenov//pen//yybwor-"); document.writeln (" <!-Element wird Klasse PSWP__Preloader-aktiv, wenn Preloader ausgeführt wird-> "); Dokument.WriteLn (" <divritel = "PSWP__Preln/"; class=/"pswp__preloader__icn/">");document.writeln(" <div class=/"pswp__preloader__cut/">");document.writeln(" <div class=/"pswp__preloader__cut/">");document.writeln(" <div class =/"pswp__Preloader__donut/"> </div> "); document.writeLn (" </div> "); document.writeln (" </div> "); document.writeLn (" </div> "); document.writeln (" </divitel "); class =/"pswp__Share-modal pswp__single-tap/"> "); document.writeln (" <div class =/"pswp__Share-modal pswp__single-tap/"); document.writeln ("<div class =/" pswp__share-toolTip/"</"); </div> "); document.writeLn (" "); document.writeLn (" <button class =/"pswp__button pswp__button-arrow-links/" title =/"vorher (Arrow links)/"> "); document.writeln (" </</</</"); pswp__button-arrow- right/"title =/" next (arrow rechts)/">"); document.writeln ("</div>"); document.writeln (""); document.writeln ("<div class =/" pswp__caption/">"); document.writeln ("<div-class =/" pswp__caption/">"); class =/"pswp__Caption__Center/"> </div> "); document.writeln (" "); document.writeln (" "); document.writeln (" "); document Ent.WriteLN (""); document.writeln (""); document.writeln (""); document.writeln (""); document.writeln (""); document.writeln (""); document.writeln (""); document.writeln ("); riteln (""); document.writeln (""); document.writeln (""); document.writeln (""); document.writeln (""); document.writeln (""); document.writeln ("); document.writeln (" "); ln (""); document.writeln (""); document.writeln (""); document.writeln (""); document.writeln (""); document.writeln (""); document.writeln (""); document.writeln (""); Dokument.WriteLn ("" "" ""). <//div>");document.writeln("");document.writeln("</div>");(function() { var initPhotoSwipeFromDOM = function(gallerySelector) { var parseThumbnailElements = function(el) { var thumbElements = el.childNodes, numNodes = thumbElements.length, items = [], el, childElements, Thumbnailel, Größe; El.GetAttribute ('HREF'), W: ParseInt (Größe [0], 10), H: ParseInt (Größe [1], 10), Autor: El.Getattribute ('Data-author')} item.el = el; Childelements [0] .Getattribute ('SRC'); El.GetAttribute ('Data-Med-Size'). Split ('x'); items.push (item); = false; numchildnodes = childnodes.length, nodeIndex = 0, für (var i = 0; i <numchildnodes; {OpenPHOTOSWIPE (INDEX, CLICKEDGALE); varsgth; Funktion (Index, Galerie, Behinderung, Fromurl) {var pswpelement = document.querySelectorAll ('. PSWP') [0], Galerie, Optionen, Elemente Funktion (Index) {// Siehe Optionen-> GetThumbBoundSFN-Abschnitt von DOCs für weitere Info var Thumbnail = Elemente [Index] .el.Children [0], pageyscroll = Fenster. W: RECT.WIDTH}; '</small>'; 0; FotosWipe und initialisieren Sie es Galerie = new fotosWipe (pswpelement, fotoswipeui_default, Elemente, Optionen); function () {var dpiratio = Fenster.DevicePixelRatio? 800) ||. Galerie.inValidateCurritems (); item.src = item.m.src; GalleryElements [i] .Setattribute ('data-pswp-uid', i+1); openPhotoswipe (Hashdata.pid, GalerieElements [Hashdata.gid - 1], wahr, wahr);Das obige ist der gesamte Inhalt dieses Artikels. Ich hoffe, es wird für das Lernen aller hilfreich sein und ich hoffe, jeder wird Wulin.com mehr unterstützen.