So I've been trying to figure out the best way to use both of these libraries together, but I've been having a hard time.
The best thing I've found is this CodePen (https://codepen.io/ezra_siton/pen/XNpJaX) but it seems incredibly overcomplicated and I personally haven't been able to get it to work on my own project. Especially the function;
var initPhotoSwipeFromDOM = function(gallerySelector) {
... omitted this because the function is huge. This is here because
SO doesn't allow codepen links without a code block for some dumb reason.
}
I'm also using VueJS, but I don't think that really makes a difference.
All I want to happen is say I have a carousel of 6 images (3 on each "page"). I want it so that if you click the 3rd image, in Photoswipe it also goes to the 3rd image, and if you then go to the 4th image inside the lightbox gallery, it also makes the carousel go to the next page as well in the background if that makes sense.
I ideally want to do this all in native/es6 JS and I want to avoid dependencies like JQuery.
The codepen you provided is exactly how this needs to be done and it is explained well there. The function you mentioned is actually the basic setup from the photoswipe getting started page with one modification to make the swiper index match upon closing photoswipe:
/* EXTRA CODE (NOT FROM THE CORE) - UPDATE SWIPER POSITION TO THE CURRENT ZOOM_IN IMAGE (BETTER UI) */
// photoswipe event: Gallery unbinds events
// (triggers before closing animation)
gallery.listen("unbindEvents", function() {
// This is index of current photoswipe slide
var getCurrentIndex = gallery.getCurrentIndex();
// Update position of the slider
mySwiper.slideTo(getCurrentIndex, false);
});
Other than that part there isn't anything there that is out of the norm for setting up swiper and photoswipe independently. Just follow the normal instructions for each script, and make sure to structure the html correctly like done in the pen because that is what allows them to function together:
<!-- Slider main container -->
<div class="swiper-container">
<!-- Additional required wrapper -->
<ul class="swiper-wrapper my-gallery" itemscope itemtype="http://schema.org/ImageGallery">
<!-- Slides -->
<li class="swiper-slide" itemprop="associatedMedia" itemscope itemtype="http://schema.org/ImageObject">
<a title="click to zoom-in" href="https://picsum.photos/1200/602" itemprop="contentUrl" data-size="1200x600">
<img src="https://picsum.photos/1200/602" itemprop="thumbnail" alt="Image description" />
</a>
</li>
<li class="swiper-slide" itemprop="associatedMedia" itemscope itemtype="http://schema.org/ImageObject">
<a title="click to zoom-in" href="http://placehold.it/1200x600/AB47BC/ffffff?text=Zoom-image-2" itemprop="contentUrl" data-size="1200x600">
<img src="http://placehold.it/600x300/AB47BC/ffffff?text=Thumbnail-image-2" itemprop="thumbnail" alt="Image description" />
</a>
</li>
<li class="swiper-slide" itemprop="associatedMedia" itemscope itemtype="http://schema.org/ImageObject">
<a title="click to zoom-in" href="http://placehold.it/1200x600/EF5350/ffffff?text=Zoom-image-3" itemprop="contentUrl" data-size="1200x600">
<img src="http://placehold.it/600x300/EF5350/ffffff?text=Thumbnail-image-3" itemprop="thumbnail" alt="Image description" />
</a>
</li>
<li class="swiper-slide" itemprop="associatedMedia" itemscope itemtype="http://schema.org/ImageObject">
<a title="click to zoom-in" href="http://placehold.it/1200x600/1976D2/ffffff?text=Zoom-image-4" itemprop="contentUrl" data-size="1200x600">
<img src="http://placehold.it/600x300/1976D2/ffffff?text=Thumbnail-image-4" itemprop="thumbnail" alt="Image description" />
</a>
</li>
<li class="swiper-slide" itemprop="associatedMedia" itemscope itemtype="http://schema.org/ImageObject">
<a title="click to zoom-in" href="https://picsum.photos/1200/603" itemprop="contentUrl" data-size="1200x600">
<img src="https://picsum.photos/1200/603" itemprop="thumbnail" alt="Image description" />
</a>
</li>
</ul>
Related
Issue
I am making a website in php ,and in its home page i have a video at the top and a carousel below it . But every time when it loads the carousel loads first and then top video loads . I want to apply the lazy load on carousel, which is an html division . Now how can i ensure the sequential loading of content.
CODE FOR TOP VIDEO BELOW HEADER IS :-
#extends('front.layouts.main')
#section('content')
<div class="clearfix"></div>
<!-- <script src="<?php echo url('/'); ?>/js/particles.js/particles.js"></script> -->
<div class="tp-banner-container two">
<div class="tp-banner3">
<ul>
<li data-transition="fade" data-slotamount="1" data-masterspeed="500"
data-thumb="http://placehold.it/180x110" data-delay="13000" data-
saveperformance="on"
data-title="Slide 1">
<video playsinline loop muted autoplay class="fullscreen-bg__video">
<source src="/videos/HomePage/Jet_new.mp4" type="video/mp4">
</video>
</li>
</ul>
<!-- <div class="tp-bannertimer"></div> -->
</div>
</div>
CODE FOR CAROUSEL BELOW VIDEO IS :-
<div class="containerRevolvingBig" >
<div class="carousel" >
<a target="_blank" href="/accessControlPage" loading="lazy">
<div id="image1" class="carousel__face"><span class="spanRevolving">Access Control</span></div>
</a>
<a target="_blank" href="/perimeterSurveillancePage">
<div id="image2" class="carousel__face"><span class="spanRevolving">Perimeter Surveillance</span></div>
</a>
<a target="_blank" href="/antiDronePage">
<div id="image3" class="carousel__face"><span class="spanRevolving">Anti-Drone</span></div>
</a>
<a target="_blank" href="/peopleVehicleMonitoringPage">
<div id="image4" class="carousel__face"><span class="spanRevolving">People & Vehicle Monitoring</span></div>
</a>
<div id="image5" class="carousel__face"><span class="spanRevolving">APPLICATIONS</span></div>
<a target="_blank" href="/borderSurveillancePage">
<div id="image6" class="carousel__face"><span class="spanRevolving">Border Surveillance</span></div>
</a>
<a target="_blank" href="/spaceAerialSurveillancePage">
<div id="image7" class="carousel__face"><span class="spanRevolving">Space & Aerial Surveillance</span></div>
</a>
<a target="_blank" href="/weaponSightsPage">
<div id="image8" class="carousel__face"><span class="spanRevolving">Weapon Sights</span></div>
</a>
<a target="_blank" href="/vechileMountedPage">
<div id="image9" class="carousel__face"><span class="spanRevolving">Vehicle Mounted Surveillance</span>
</div>
</a>
</div>
</div>
Now I want that, this complete CAROUSEL div should load when the top video loads completely.How should I apply lazy load in this div.
I would suggest your page to have just the video loaded and add a listener to get to know when the video is loaded (Wait until an HTML5 video loads) . Then inside the listener generate the carrousel with javascript. (https://www.javascripttutorial.net/dom/manipulating/create-a-dom-element/). Finally if you are using a carrousel plugin this will need to be call once the carrousel html has been included into the page.
Other solution but i consider is not ideal, could be set creating a view in the backend that just includes the carousel, then in the frontend, inside the same listener described above, you:
send an ajax request to get that view,
in the front-end you will need to parse the html to extract the carrousel.
Inject the carrousel html into the page.
Initialise the carrousel
Hope this is clear.
I am working on a bootstrap with node.js express project. Upon getting variables installed into the theme where the username is (as shown below), There is some sort of invisible gap in the viewing of the code.
<!-- User Account: style can be found in dropdown.less -->
<li class="dropdown user user-menu">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
<img id='picture2' src="dist/img/user2-160x160.jpg" class="user-image" alt="User Image">
<span id="name" class="hidden-xs">Firstname Lastname</span>
</a>
<ul class="dropdown-menu">
<!-- User image -->
<li class="user-header">
<img id='picture' src="dist/img/user2-160x160.jpg" class="img-circle" alt="User Image">
<p><div id="name2">Firstname Lastname</div>
<div id="companytitle"><small>Member</div>since<div id='signupdate'>Nov. 2012</small></div>
</p>
</li>
<!-- Menu Body -->
This image shows the original bootstrap before i added the multiple tags to change the text with ajax. As soon as i added the <div> tags, the visuals of the profile tab parted and started to look like the first image.
I am unsure of how exactly to get these items to align right on the page, as you can see, it almost appears that the data has some breaks in it.
Can anyone point me in the right direction to fix this?
Here is the original boostrap snipped for the profile tab
<!-- User Account: style can be found in dropdown.less -->
<li class="dropdown user user-menu">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
<img src="dist/img/user2-160x160.jpg" class="user-image" alt="User Image">
<span class="hidden-xs">Alexander Pierce</span>
</a>
<ul class="dropdown-menu">
<!-- User image -->
<li class="user-header">
<img src="dist/img/user2-160x160.jpg" class="img-circle" alt="User Image">
<p>
Alexander Pierce - Web Developer
<small>Member since Nov. 2012</small>
</p>
</li>
<!-- Menu Body -->
I am trying to customize Sorgalla carousel styles but experiencing some difficulties - more exactly, with the right border of the last list item which is shown in the viewport of the carousel. It is simply disappearing, please take a look at it:
http://jsfiddle.net/orinoco_omi/cy7y9j7x/
Here is HTML Code:
<div class="wrapper">
<div class="jcarousel-wrapper">
<div class="jcarousel">
<ul>
<li>
<img src="img/img1.jpg" alt="Image 1">
<h4>Check-up and evaluation services</h4>
<p>A nice & short description of the service </p>
</li>
<li><img src="img/img2.jpg" alt="Image 2">
<h4>Check-up and evaluation services</h4>
<p>A nice & short description of the service </p>
</li>
<li><img src="img/img3.jpg" alt="Image 3">
<h4>Check-up and evaluation services</h4>
<p>A nice & short description of the service </p>
<p>A nice & short description of the service </p>
</li>
<li><img src="img/img4.jpg" alt="Image 4">
<h4>Check-up and evaluation services</h4>
<p>A nice & short description of the service </p>
</li>
<li><img src="img/img5.jpg" alt="Image 5"></li>
<li><img src="img/img6.jpg" alt="Image 6"></li>
</ul>
</div>
‹
›
<p class="jcarousel-pagination"></p>
</div>
</div>
Any margin I set out for the li items (I want them to be separated like here, http://comtechguys.com/slider1/index.html) causes the disappearing of the right border. I guess the problem is in .jcarousel div. I tried to set padding to it, so that my list could fit in, but useless. I also tried to change it's size, set margins... didn't help. Is there anything I am missing out?
I have made on the basis of the script BxSlider slider on its website.
Structure slider is as such:
<ul class="slider-cont">
<li>
<img src="images/slide-1.jpg" alt="">
<div class="caption">caption1.</div>
</li>
<li>
<img src="images/slide-2.jpg" alt="">
<div class="caption">caption2</div>
</li>
<li>
<img src="images/slide-3.jpg" alt="">
<div class="caption">caption3</div>
</li>
</ul>
Caption is over the image and is the way to the left of the slider. My question is whether it is possible using CSS3 or JS to do the same animation to make the text more quickly, "rolling off" and "rode" than the picture? I tried using the tool in the bxslider. OnSlideBefore or OnSlideAfter but I managed to get this effect.
I've been implementing the code for the flex slider which allows links/buttons outside of the flex slider to target specific slides with rel tags as provided by LJ902 here:
jQuery FlexSlider hide Slider but retain visibility of Manual Controls
Now I'm curious how I would be able to change the css state of the targeting link/button (giving it a different colored background to indicate it's active state), when the flex slider is positioned within a section of slides.
So for instance in the example below, when the slider at a state between the images images/section2-Image01.jpg thru images/section2-Image03, the css state of slide-thumb link for Section 2 is changed , for the slides in section 3 the css state of slide-thumb link for Section 3 is changed and the styling for section 2 goes back to it's previous state. In essence creating tab like functionality that flows over when the users slides/clicks though into the next section
<a rel="0" class="slide_thumb" href="#">Section 1</a>
<a rel="3" class="slide_thumb" href="#">Section 2</a>
<a rel="6" class="slide_thumb" href="#">Section 3</a>
<div class="flexslider">
<ul class="slides">
<li>
<img src="images/section1-Image01.jpg" />
</li>
<li>
<img src="images/section1-Image02.jpg" />
</li>
<li>
<img src="images/section1-Image03.jpg" />
</li>
<li>
<img src="images/section2-Image01.jpg" />
</li>
<li>
<img src="images/section2-Image02.jpg" />
</li>
<li>
<img src="images/section2-Image03.jpg" />
</li>
<li>
<img src="images/section3-Image01.jpg" />
</li>
<li>
<img src="images/section3-Image02.jpg" />
</li>
<li>
<img src="images/section3-Image03.jpg" />
</li>
</ul>
</div>
Could anyone help me out with this? My mediocre development skills have been stumped by this over the last day or so.Thanks!