Fancybox with Owl carousel (lazyLoad) - fancybox

I'm using Fancybox v3.5.4 and Owl carousel v2.3.4 with lazyLoad option
When we click on a photo, Fancybox makes the photo pop up. Then if we click on "Next" few times to get the next photos on Fancybox and then close it, the photos on the owl carousel have disappeared.
It seems that the carousel has changed its background position and displays photos not loaded yet because of the lazyLoad option. Does anyone understand what is going on here? I spent lot of time on this.. Thank you
You can see an example here:
https://codepen.io/Philippe_12/pen/bOVOrK
$('.owl-carousel').owlCarousel({
items: 4,
loop:true,
pagination: false,
slideSpeed: 700,
paginationSpeed: 700,
rewindSpeed: 700,
lazyLoad: true
});
$().fancybox({
selector : '.owl-item:not(.cloned) a',
hash : false,
thumbs : {
autoStart : true
},
buttons : [
'zoom',
'download',
'close'
]
});
.img_container{ width:50%}
<link href="https://cdnjs.cloudflare.com/ajax/libs/OwlCarousel2/2.3.4/assets/owl.theme.default.css" rel="stylesheet"/>
<link href="https://cdnjs.cloudflare.com/ajax/libs/OwlCarousel2/2.3.4/assets/owl.carousel.css" rel="stylesheet"/>
<link href="https://cdnjs.cloudflare.com/ajax/libs/fancybox/3.5.4/jquery.fancybox.css" rel="stylesheet"/>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/fancybox/3.5.4/jquery.fancybox.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/OwlCarousel2/2.3.4/owl.carousel.min.js"></script>
<h2>fancyBox v3.2 - OwlCarousel2 lazyLoad</h2>
<div class="img_container owl-carousel owl-theme">
<a href="https://placehold.it/350x250&text=1" data-fancybox="images">
<img class="owl-lazy" data-src="https://placehold.it/350x250&text=1" alt="">
</a>
<a href="https://placehold.it/350x250&text=2" data-fancybox="images">
<img class="owl-lazy" data-src="https://placehold.it/350x250&text=2" alt="">
</a>
<a href="https://placehold.it/350x250&text=3" data-fancybox="images">
<img class="owl-lazy" data-src="https://placehold.it/350x250&text=3" alt="">
</a>
<a href="https://placehold.it/350x250&text=4" data-fancybox="images">
<img class="owl-lazy" data-src="https://placehold.it/350x250&text=4" alt="">
</a>
<a href="https://placehold.it/350x250&text=5" data-fancybox="images">
<img class="owl-lazy" data-src="https://placehold.it/350x250&text=5" alt="">
</a>
<a href="https://placehold.it/350x250&text=6" data-fancybox="images">
<img class="owl-lazy" data-src="https://placehold.it/350x250&text=6" alt="">
</a>
<a href="https://placehold.it/350x250&text=7" data-fancybox="images">
<img class="owl-lazy" data-src="https://placehold.it/350x250&text=7" alt="">
</a>
<a href="https://placehold.it/350x250&text=8" data-fancybox="images">
<img class="owl-lazy" data-src="https://placehold.it/350x250&text=8" alt="">
</a>
<a href="https://placehold.it/350x250&text=9" data-fancybox="images">
<img class="owl-lazy" data-src="https://placehold.it/350x250&text=9" alt="">
</a>
<a href="https://placehold.it/350x250&text=10" data-fancybox="images">
<img class="owl-lazy" data-src="https://placehold.it/350x250&text=10" alt="">
</a>
<a href="https://placehold.it/350x250&text=11" data-fancybox="images">
<img class="owl-lazy" data-src="https://placehold.it/350x250&text=11" alt="">
</a>
<a href="https://placehold.it/350x250&text=12" data-fancybox="images">
<img class="owl-lazy" data-src="https://placehold.it/350x250&text=12" alt="">
</a>
<a href="https://placehold.it/350x250&text=13" data-fancybox="images">
<img class="owl-lazy" data-src="https://placehold.it/350x250&text=13" alt="">
</a>
<a href="https://placehold.it/350x250&text=14" data-fancybox="images">
<img class="owl-lazy" data-src="https://placehold.it/350x250&text=14" alt="">
</a>
</div>

Looks like that issue is caused by "place-focus-back" feature of fancybox and you can disable that by adding backFocus : false while initializing.
Another issue that you might not have noticed is that you have initialized fancybox on "non-cloned" items only. That means, if you swipe enough and click on one of cloned slide, fancybox will start with default options (because clones will have data-fancybox="images" attribute, too). There is a sample of solving this issue for other slider - https://fancyapps.com/fancybox/3/docs/#faq-6 - but, you need a couple of tweaks for owlCarousel, because it does not add any attribute indicating what index each slide has.
Here is a possible solution - https://codepen.io/fancyapps/pen/yGYWNy?editors=1010 (note that I have removed data-fancybox="images" and added data-index attributes).

Related

Problem with change direction to rtl in Bulma

good evening everyone
recently i have use Bulma framework and now i want to try design my theme in RTL mode , I've install all the required thing like bulma rtl and ... , but when i try to use it export that show in browser is like the below image , I've tried use body direction but it doesn't work, and one more thing i use laravel and install all of this with npm
and here is my code :
<nav class="navbar " role="navigation" aria-label="main navigation">
<div class="navbar-brand">
<a class="navbar-item" href="https://bulma.io">
<img src="https://bulma.io/images/bulma-logo.png" width="112" height="28">
</a>
<a role="button" class="navbar-burger burger" aria-label="menu" aria-expanded="false" data-
target="navbarBasicExample">
<span aria-hidden="true"></span>
<span aria-hidden="true"></span>
<span aria-hidden="true"></span>
</a>
</div>
<div id="navbarBasicExample" class="navbar-menu">
<div class="navbar-start">
<a class="navbar-item">
Home
</a>
<a class="navbar-item">
Documentation
</a>
<div class="navbar-item has-dropdown is-hoverable">
<a class="navbar-link">
More
</a>
<div class="navbar-dropdown">
<a class="navbar-item">
About
</a>
<a class="navbar-item">
Jobs
</a>
<a class="navbar-item">
Contact
</a>
<hr class="navbar-divider">
<a class="navbar-item">
Report an issue
</a>
</div>
</div>
</div>
<div class="navbar-end">
<div class="navbar-item">
<div class="buttons">
<a class="button is-primary">
<strong>Sign up</strong>
</a>
<a class="button is-light">
Log in
</a>
</div>
</div>
</div>
</div>
</nav>
<nav class="navbar is-dark " role="navigation" aria-label="main navigation">
<div class="navbar-brand">
<a class="navbar-item" href="https://bulma.io">
<img src="https://bulma.io/images/bulma-logo.png" width="112" height="28">
</a>
<a role="button" class="navbar-burger burger" aria-label="menu" aria-expanded="false" data-
target="navbarBasicExample">
<span aria-hidden="true"></span>
<span aria-hidden="true"></span>
<span aria-hidden="true"></span>
</a>
</div>
<div id="navbarBasicExample" class="navbar-menu">
<div class="navbar-start">
<a class="navbar-item">
Home
</a>
<a class="navbar-item">
Documentation
</a>
<div class="navbar-item has-dropdown is-hoverable">
<a class="navbar-link">
More
</a>
<div class="navbar-dropdown">
<a class="navbar-item">
About
</a>
<a class="navbar-item">
Jobs
</a>
<a class="navbar-item">
Contact
</a>
<hr class="navbar-divider">
<a class="navbar-item">
Report an issue
</a>
</div>
</div>
</div>
<div class="navbar-end">
<div class="navbar-item">
<div class="buttons">
<a class="button is-primary">
<strong>Sign up</strong>
</a>
<a class="button is-light">
Log in
</a>
</div>
</div>
</div>
</div>
</nav>
Now Bulma framework (from version : 0.9.0) supports RTL languages.
You do not need to do anything special.
Just download new version of Bulma and use Bulma-rtl.css file.
Example on codepen
after apply bulma-rtl, you have to make this class and add that to your navbar,navbarBasicExample and navbar-start classes.
.flex-direction-row{
flex-direction: row;
};
like this
hope help you.
If you are using ReactJs
Check Bluma framework version . Your version >= 0.90
In the Index.js file imports you must use bluma-rtl.min.css :
By default :
import React from 'react';
import ReactDOM from 'react-dom';
import App from './App';
import 'bulma/css/bulma.min.css';
ReactDOM.render( <App/> , document.getElementById('root') );
Change to:
import React from 'react';
import ReactDOM from 'react-dom';
import App from './App';
import 'bulma/css/bulma-rtl.min.css';
ReactDOM.render( <App/> , document.getElementById('root') );
add dir="rtl" to the innermost html tag that includes RTL text
example:
<div class="columns is-mobile">
<div class="card">
<div class="card-content">
<div class="content is-large">
<p dir="rtl">
یه متن به زبان فارسی
</p>
</div>
</div>
</div>
</div>

Bootstrap Horizontal Navbar Toggle

I prepared simple navbar menu with BS 4 documents. The toggle menu displays vertical when I clicked. Is it possible make horizontal with BS?
This is my navbar and codepen.io: vertical toggle
body {
margin: 0 auto;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js"></script>
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js"></script>
<nav class="navbar navbar-expand-md navbar-dark bg-dark">
<a class="nav-brand" href="#">
<img class="img-responsive" src="https://cdn2.iconfinder.com/data/icons/camping-outline-flat-pt-2/100/069_-_snowboard_snowboarding_board_1-128.png" width="55" height="55" alt="logo">
</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#mainNav">
<span class="navbar-toggler-icon"</span>
</button>
<div class="collapse navbar-collapse" id="mainNav">
<div class="navbar-nav ml-auto">
<a class="nav-item nav-link active" href="#">ABOUT<span class="sr-only">(current)</span></a>
<a class="nav-item nav-link " href="#">PORTFOLIO</a>
<a class="nav-item nav-link " href="#">CONTACT</a>
</div>
</div>
</nav>
This is as I want but I couldn't figured out with source code: horizontal toggle
It's fairly simple to do that. Bootstrap has flex class options, so there's no need to create your own code.
Simply change:
<div class="navbar-nav ml-auto">
To:
<div class="navbar-nav flex-row ml-md-auto d-md-flex">
Also make sure to add p-2 to your nav-item that will give you some padding space between the elements.
That makes your code look like this:
<nav class="navbar navbar-expand-md navbar-dark bg-dark">
<a class="nav-brand" href="#">
<img class="img-responsive" src="https://cdn2.iconfinder.com/data/icons/camping-outline-flat-pt-2/100/069_-_snowboard_snowboarding_board_1-128.png" width="55" height="55" alt="logo">
</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#mainNav">
<span class="navbar-toggler-icon"</span>
</button>
<div class="collapse navbar-collapse" id="mainNav">
<div class="navbar-nav flex-row ml-md-auto d-md-flex">
<a class="nav-item nav-link p-2 active" href="#">ABOUT<span class="sr-only">(current)</span></a>
<a class="nav-item nav-link p-2" href="#">PORTFOLIO</a>
<a class="nav-item nav-link p-2" href="#">CONTACT</a>
</div>
</div>
</nav>

make the image displayed smaller in ionic

<div class="list card">
<div class="item item avatar item-icon-right">
<img src="https://pbs.twimg.com/profile_images/598205061232103424/3j5HUXMY.png">
<h2>Simran Kaur</h2>
<p>November 06, 1992</p>
</div>
I have this piece of code in ionic and whatsoever image I add here takes up most of the space. Why is that and how do I fix this?
It looks like this:
Here is my complete code:
<div class="list card">
<div class="item item avatar item-icon-right">
<img src="https://pbs.twimg.com/profile_images/598205061232103424/3j5HUXMY.png">
<h2>Simran Kaur</h2>
<p>November 06, 1992</p>
</div>
<div class="item item-body">
<p>
This is a "Facebook" styled Card. The header is created from a Thumbnail List item,
the content is from a card-body consisting of an image and paragraph text. The footer
consists of tabs, icons aligned left, within the card-footer.
</p>
<p>
1 Like
5 Comments
</p>
</div>
<div class="item tabs tabs-secondary tabs-icon-left">
<a class="tab-item" href="#">
<i class="icon ion-thumbsup"></i>
Like
</a>
<a class="tab-item" href="#">
<i class="icon ion-chatbox"></i>
Comment
</a>
<a class="tab-item" href="#">
<i class="icon ion-share"></i>
Share
</a>
</div>
</div>
There is an example of how card should be coded. Avatar is renderd small on the left side, cover is rendered big, and occupy whole space.
Here is codepen with your image rendered both small and big: http://codepen.io/anon/pen/RPvYpp
<div class="list card">
<div class="item item-avatar">
<img src="https://pbs.twimg.com/profile_images/598205061232103424/3j5HUXMY.png">
<h2>Marty McFly</h2>
<p>November 05, 1955</p>
</div>
<div class="item item-body">
<img class="full-image" src="https://pbs.twimg.com/profile_images/598205061232103424/3j5HUXMY.png">
<p>
This is a "Facebook" styled Card. The header is created from a Thumbnail List item,
the content is from a card-body consisting of an image and paragraph text. The footer
consists of tabs, icons aligned left, within the card-footer.
</p>
<p>
1 Like
5 Comments
</p>
</div>
<div class="item tabs tabs-secondary tabs-icon-left">
<a class="tab-item" href="#">
<i class="icon ion-thumbsup"></i>
Like
</a>
<a class="tab-item" href="#">
<i class="icon ion-chatbox"></i>
Comment
</a>
<a class="tab-item" href="#">
<i class="icon ion-share"></i>
Share
</a>
</div>
</div>

Ionic list: How to edit the style of the list items?

I used the following code inside my side menu:
<ion-side-menu side="left">
<ion-content>
<div class="list">
<a class="item" menu-close href="#/app/products">
<img src="img/home.png" width="30px" />
<!-- <i class="icon ion-home"></i> -->
<h2>YourPhoto24</h2>
</a>
<a class="item" menu-close href="#/app/account">
<img src="img/profile.png" width="30px" />
<h2>mein Konto</h2>
</a>
<a class="item" menu-close href="#/app/orders">
<img src="img/orders.png" width="30px" />
<h2>meine Bestellungen</h2>
</a>
<a class="item" menu-close href="#/app/receivers">
<img src="img/receivers.png" width="30px" />
<h2>meine Empfänger</h2>
</a>
<a class="item" menu-close href="#/app/email">
<img src="img/email.png" width="30px" />
<h2>Email an uns</h2>
</a>
<a class="item" menu-close href="#/app/recommend">
<img src="img/recommend.png" width="30px" />
<h2>Empfehlen Sie uns weiter
<p>mein Guthaben beträgt zur Zeit: </p>
</h2>
</a>
<a class="item" menu-close href="#/app/siteNotice">
<img src="img/laws.png" width="30px" />
<h2>AGB & Impressung</h2>
</a>
</div>
</ion-content>
</ion-side-menu>
So i wanted an icon at the left and the text to the right centered vertically. Unfortunately i did not get the result i expected:
1: How can i manage to get more space between the image and the text and how can i vertically center the text?
2: How can i hide the dividers?
3: How can i increase the top and bottom padding of the list items? I want them to be 40px.
I added the following to my css file:
.menu.menu-left, .list a {
border-color: transparent;
padding-top: 30px;
padding-bottom: 30px;
}
.menu.menu-left, .list img {
float: left;
vertical-align: middle;
}
.menu.menu-left, .list h2 {
display: inline-block;
}
The padding and the hiding of the divider works with that code. but i cant manage to pretty align the text next to the image centered vertically (both should be centered vertically, the image and the text!)
So whats left is: How can i manage to get more space between the image and the text and how can i vertically center the text?
Ionic already provides a lot to do something like this with stylings they already made. Take a look at this example in their docs.:
<div class="list">
<a class="item item-icon-left" href="#">
<i class="icon ion-person"></i>
mein Konto
</a>
<a class="item item-icon-left" href="#">
<i class="icon ion-navicon-round"></i>
meine Bestellungen
</a>
<a class="item item-icon-left" href="#">
<i class="icon ion-heart"></i>
meine Empfänger
</a>
<a class="item item-icon-left" href="#">
<i class="icon ion-email"></i>
Email an uns
</a>
<a class="item item-icon-left" href="#">
<i class="icon ion-android-share-alt"></i>
Empfehlen Sie uns weiter
</a>
</div>
Here is a little codepen to demonstrate what you want:
http://codepen.io/anon/pen/ZGBegG

Image Duplication in FANCYBOX

The first Image is duplicating.
After clicking on target which is an image, Photo1 displays twice before Photo2 and Photo3.
script:
<script type="text/javascript">
$(document).ready(function(){
$(".fancybox5")
.attr('rel', 'gallery')
.fancybox({
openEffect: 'elastic',
prevEffect: 'fade',
nextEffect: 'fade'
});
});
</script>
html markup:
<div>
<a class="fancybox5" href="#inline5"> <div id="pics"><img src="images/pic.png" width="165" height="167" alt="Pics" border="0" /></div></a>
<div id="inline5" style="width:100%;display: none;">
<a class="fancybox5" href="media/photo3.jpg"><img src="media/photo3.jpg" width="400" height="500" /></a>
<div class="hidden">
<a class="fancybox5" href="media/photo1.jpg"><img src="media/photo1.jpg" width="400" height="500" /></a>
<a class="fancybox5" href="media/photo2.jpg"><img src="media/photo2.jpg" width="400" height="500" /></a>
</div>
</div>
</div>
You don't need to target the inline content neither you have to use thumbnails inside the hidden div. Target the first picture in your visible link only so tweak your html this way
<div>
<a class="fancybox5" href="media/photo1.jpg"><img src="media/photo1.jpg" width="400" height="500" /></a>
<div id="inline5" style="display: none;">
<a class="fancybox5" href="media/photo3.jpg"></a>
<a class="fancybox5" href="media/photo2.jpg"></a>
</div>
</div>
and this script should work
$(document).ready(function () {
$(".fancybox5")
.attr('rel', 'gallery')
.fancybox({
openEffect: 'elastic',
prevEffect: 'fade',
nextEffect: 'fade'
});
});