featherlight.js thumbnails into gallery - featherlight.js

I am going round in circles to create a thumbnail based media viewer (my example just uses images but videos can be in place on the original). The thumbnails to main image work just fine but I then wanted to add a "click main image to see large version". This works. However, ideally I would like then have the previous/next buttons to cycle through the large size images from the thumbnail. I do not wish to trigger the featherlight overlay when clicking on a thumbnail.
Here is my jsfiddle: https://jsfiddle.net/2oux4tcw/4/
For reference here is my JS, html and CSS
HTML
<div class="largeone" id="bigpic">
<p class="info">Click a thumbnail</p>
</div>
<div class="thumbscon">
<ul>
<li><img id="img1" class="thumb galleryitem" data-featherlight-gallery src="https://dummyimage.com/100x100/238943/fff.png&text=Green+Thumbnail" data-largeone="https://dummyimage.com/600x600/238943/fff.png&text=Green+Largeg" alt="Green" title="Green Image"></li>
<li><img id="img2" class="thumb galleryitem" data-featherlight-gallery src="https://dummyimage.com/100x100/992323/fff.png&text=Red+Thumbnail" data-largeone="https://dummyimage.com/600x600/992323/ffffff.png&text=Red" alt="Red" title="Red Image"></li>
<li><img id="img3" class="thumb galleryitem" data-featherlight-gallery src="https://dummyimage.com/100x100/232399/fff.png&text=Blue+Thumbnail" data-largeone="https://dummyimage.com/600x600/232399/ffffff.png&text=Blue" alt="Blue" title="Blue Image"></li>
</ul>
</div>
CSS
.largeone{background: #dedede; border: 1px solid #555; margin-bottom: 12px; height: 600px; width: 600px;}
.thumbscon ul{text-align: center; width: 600px;}
.thumbscon li{display: inline-block; margin-right: 6px; }
p.info{margin: 40% 35%; display: inline-block; width: 30%; text-align: center;}
JS
var showLargeImage = function(elementId){
var el = jQuery("#"+elementId);
var newMedia = "";
if(el){
var imgsrc = el.attr("data-largeone"); //large image source
var imgtitle = el.attr("title");
var imgalt = el.attr("alt");
newMedia = jQuery("<img>",{src: imgsrc,title:imgtitle,alt:imgalt,id:"bigimage",class:"galleryitem"})
newMedia.attr("data-featherlight",imgsrc);
newMedia.attr("data-featherlight-gallery",imgsrc);
}
if(newMedia.length >0){
jQuery("#bigpic").html(newMedia);
}
}
jQuery(document).ready(function(){
jQuery(document).on("click","img.thumb",function(e){
e.preventDefault();
showLargeImage(jQuery(this).attr("id"));
});
jQuery(".galleryitem").featherlightGallery();
});
Any pointers on how to trigger the gallery action from the main image only, but show the data-largeone images from the thumbnails?

Not sure I understand what you want exactly, but couldn't you simply create a hidden featherlight gallery, and redirect the click on the main image to the proper hidden thumbnail?

Related

Center Aligning a Facebook Timeline Plug in [duplicate]

Consider the following example: (live demo)
HTML:
<div>div</div>
<iframe></iframe>
CSS:
div, iframe {
width: 100px;
height: 50px;
margin: 0 auto;
background-color: #777;
}
Result:
Why the iframe is not centrally aligned like the div? How could I centrally align it?
Add display:block; to your iframe css.
div, iframe {
width: 100px;
height: 50px;
margin: 0 auto;
background-color: #777;
}
iframe {
display: block;
border-style:none;
}
<div>div</div>
<iframe src="data:,iframe"></iframe>
best way and more simple to center an iframe on your webpage is :
<p align="center"><iframe src="http://www.google.com/" width=500 height="500"></iframe></p>
where width and height will be the size of your iframe in your html page.
HTML:
<div id="all">
<div class="sub">div</div>
<iframe>ss</iframe>
</div>
CSS:
#all{
width:100%;
float:left;
text-align:center;
}
div.sub, iframe {
width: 100px;
height: 50px;
margin: 0 auto;
background-color: #777;
}
The simplest code to align the iframe element:
<div align="center"><iframe width="560" height="315" src="www.youtube.com" frameborder="1px"></iframe></div>
My simplest solution to this.
iframe {
margin:auto;
display:block;
}
If you are putting a video in the iframe and you want your layout to be fluid, you should look at this webpage: Fluid Width Video
Depending on the video source and if you want to have old videos become responsive your tactics will need to change.
If this is your first video, here is a simple solution:
<div class="videoWrapper">
<!-- Copy & Pasted from YouTube -->
<iframe width="560" height="349" src="http://www.youtube.com/embed/n_dZNLr2cME?rel=0&hd=1" frameborder="0" allowfullscreen></iframe>
</div>
And add this css:
.videoWrapper {
position: relative;
padding-bottom: 56.25%; /* 16:9 */
padding-top: 25px;
height: 0;
}
.videoWrapper iframe {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
Disclaimer: none of this is my code, but I've tested it and was happy with the results.
You can put iframe inside a <div>
<div>
<iframe></iframe>
</div>
It works because it is now inside a block element.
You can try
<h3 style="text-align:center;"><iframe src=""></iframe></h3>
I hope its useful for you
link
If you can't access the iFrame class then add below css to wrapper div.
<div style="display: flex; justify-content: center;">
<iframe></iframe>
</div>
In my case solution was on iframe class adding:
display: block;
margin-right: auto;
margin-left: auto;
According to http://www.w3schools.com/css/css_align.asp, setting the left and right margins to auto specifies that they should split the available margin equally. The result is a centered element:
margin-left: auto;margin-right: auto;
Here I have put snippet for all of you who are suffering to make iframe or image in center of the screen horizontally.
Give me THUMBS UP VOTE if you like.👍⯅.
style > img & iframe > this is your tag name so change that if you're want any other tag in center
<html >
<head>
<style type=text/css>
div{}
img{
margin: 0 auto;
display:block;
}
iframe{
margin: 0 auto;
display:block;
}
</style>
</head>
<body >
<iframe src="https://test-videos.co.uk/vids/bigbuckbunny/mp4/h264/360/Big_Buck_Bunny_360_10s_1MB.mp4" width="320" height="180" frameborder="0" allowfullscreen="allowfullscreen"></iframe>
<img src="http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/images/BigBuckBunny.jpg" width="320" height="180" />
</body>
</html>
<iframe src="https://www.facebook.com/plugins/page.php?href=https%3A%2F%2Fwww.facebook.com%2FRishabh-Cars-Jodhpur-110479104559774&tabs=timeline&width=500&height=1200&small_header=false&adapt_container_width=true&hide_cover=false&show_facepile=true&appId" width="500" height="1200" style="border:none;overflow:hidden;display:block;margin:0 auto;" scrolling="yes" frameborder=".6" allowfullscreen="true" allow="autoplay; clipboard-write; encrypted-media; picture-in-picture; web-share"></iframe>
use it and embed facebook in iframe in center of html page

JQuery Class selector not working on Zoom plugin

I've been trying to get jQuery to select a particular element in the JQuery zoom plugin but it doesnt seem to be working
This is the html markup for the zoom region
<div class="zoom" style="width: 60% !important; display: block; position: fixed; overflow: hidden;">
<img src="//cdn.shopify.com/s/files/1/0456/6809/t/3/assets/bx_loader.gif?27021" alt="" class="abs-center-translate loader">
<img src="//cdn.shopify.com/s/files/1/0456/6809/products/568A.jpeg?v=1413437903" class="zoomImg" style="position: absolute; top: -1385.54456824513px; left: -389.68108776267px; opacity: 1; width: 682.5px; height: 1024px; border: none; max-width: none; max-height: none;">
</div>
function showZoomImgSmaller(img) {
var zoomsmall = $('.zoom');
zoomsmall.empty();
zoomsmall.append('{{ "bx_loader.gif" | asset_url | img_tag: "", "abs-center-translate loader" }}');
$('.collectionZoomContainer').show();
zoomsmall.attr( "style","width:60%!important" );
var zoomsmallimg= $('.zoom > img');
console.log(zoomsmallimg.next().get());
$('.zoomImg').attr("style","max-width:500px!important");
zoomsmall.show();
zoomsmall.zoom({url: img, magnify: 0.5});
}
The console returns just a [] for the .zoomImg.get() and an undefined for a .zoomImg.html()
I want to change the css of this particular element and can only do it through jquery.
Any help will be greatly appreciated. Thanks
There is a lot going on here that I cannot see, but my guess is that when you call empty() on your div, you are removing all children of the div (including the .zoomImg class which you are trying to look up later). Instead of removing all elements, you might just want to remove the first image:
function showZoomImgSmaller(img) {
var zoomsmall = $('.zoom');
$('.zoom > .loader').remove(); //change is here
zoomsmall.append('{{ "bx_loader.gif" | asset_url | img_tag: "", "abs-center-translate loader" }}'); //angular? not sure what this does
$('.collectionZoomContainer').show(); //not sure what this
zoomsmall.attr( "style","width:60%!important" );
var zoomsmallimg= $('.zoom > img');
console.log(zoomsmallimg.next().get());
$('.zoomImg').attr("style","max-width:500px!important");
zoomsmall.show();
zoomsmall.zoom({url: img, magnify: 0.5});
}
Hey so I managed to get my style applied by appending css in the head of the page. This style was applied even though the element didnt exist till later.
This is the code I used.
$("<style type='text/css'> .zoomImg{ max-width:200px!important;} </style>").appendTo("head");
Cheers.

Can I toggle an image with Jquery, yet have live text upon click?

I'm not sure if my question makes sense, but,
I'm using jQuery to toggle an image from its off-state to its on-state upon click.
That was hard enough to get to work (I'm rather novice).
The problem is that the on-state is an image with a fair amount of body copy. It obviously does not look as good as it would if it were live type.
I was wondering, if it's even possible, that the on-state be a div with live text that is hidden until the image is clicked.
I have no idea how to go about solving this problem as my knowledge of jQuery is rather limited.
The page is currently being hosted here
Script:
<script type="text/javascript">
$(function(){
$("#click li").click(function (e) {
$("#click li.selected").not(this).removeClass("selected");
$(this).toggleClass("selected");
});
});
</script>
You could include both a div -- initially hidden, with size matching the image -- and the image in each li.
CSS:
.imagetext {
display: none;
height: 50px; /* or whatever */
width: 50px;
}
#click li img {
display: block;
height: 50px; /* or whatever */
width: 50px;
}
#click li.selected img {
display: none;
}
#click .imagetext {
display: block;
}
HTML along the lines of:
<div id="#click">
<ul>
<li>
<img src="..." />
<div class="imagetext">Four score and seven...</div>
</li>
<!-- ... -->
</ul>
</div>

Removing CSS Margin on iPad / iPhone

On an e-commerce website that I set-up Link on a page that has 4 alternative product views (they are the 4 small images underneath the add to basket) On an iPhone or iPad the 4th image isn't having its right margin removed so it goes onto the next line.
Basically each images has a 10px right margin, and then the last image that has a class of 'end' has a right margin of '0px !important'.
This works fine in web browsers but on the iPad / iPhone the 0px right margin is not being applied.
I have a feeling this is going to be an easy one but I just can't see it, thanks in advance for any help.
EDIT I have added the code below and have also set-up a stripped down version of the page I am having the problems on: link, it is the 4 small images at the bottom of the right hand side.
Below is the HTML for the images:
<div class="image-additional">
<img alt="" title="" src="larchblue-cr-55x55.jpg" class="thumb ">
<img alt="" title="" src="larchgreen-cr-55x55.jpg" class="thumb ">
<img alt="" title="" src="larchpink-cr-55x55.jpg" class="thumb ">
<img alt="" title="" src="larchyellow-cr-55x55.jpg" class="thumb end">
</div>
And here is the CSS:
.image-additional {
width: 268px;
margin-top: 13px;
clear: both;
position: absolute;
bottom: 0;
overflow: hidden;
}
.image-additional img {
border: 1px solid #E7E7E7;
margin-right: 10px;
}
.image-additional img.end, .image-additional img:last-child {
margin-right: 0px !important;
}
Try using :last-child pseudo element for your mobile targets.
.img:last-child {
margin-right: 0px;
}
Note: It works everywhere except for IE8 and below.

Coverflow in HTML5 for iPhone/iPod Touch

I have to do a web page destined for iPhone and iPod-touch that needs to incorporate the Coverflow style of apple in a page to display a list of videos.
I've heard something about gizmos that could help, but I can't find anything relevant or that could work properly with the iPhone/iPod-Touch navigation.
Anyone knows something that could help me getting started?
Thanks
-Stephanie
Try ContentFlow:
http://www.jacksasylum.eu/ContentFlow/
Here is an example that is working on my iPhone :
http://www.majes.fr/
This is the best one which i found till now ;) Coverflow
This is a cross-browser implementation of Cover Flow: http://luwes.co/labs/js-cover-flow/
The primary mode works in HTML5 (JavaScript/CSS) and it has a fallback for older browsers in flash. It supports mobile, you can flip through the covers with a simple swipe gesture.
Tested on: Safari, Chrome, Firefox, Opera, IE8+, iPad, iPhone
This might help you: http://paulbakaus.com/2008/05/31/coverflow-anyone/
Though it doesn't seem that there is any official way to do it because CSS transforms only all a 2d matrix, so you can't get a trapezium shape.
you can find tons of coverflow samples in google
but all the samples that i found are too complex(a lot of files or hard to implement) and they don't give what i was looking
so i decide to create a coverflow
1.- less files
2.- easy to implement
3.- Works with Webkit (Safari, Safari Mobile and Chrome)
the code that i'm going to show is just to give you a clue
of what can you do with your project
this is a very simple sample that only shows you the essential
it's not a final work
this coverflow works with a input range (slider)
and thats it
When you get the idea of how coverflow works
you will be able to add more features clicks, touches, flip cover....
Finally here is the code:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8"/>
<title>CoverFlow</title>
<style>
html { height: 100%; }
body { background-image: -webkit-radial-gradient(gray 0%, black 100%); }
#coverflow {
width: 800px;
height: 400px;
overflow: hidden;
margin: 100px auto;
-webkit-perspective: 500;
background-color: rgba(0, 0, 0, 0.4);
-webkit-transform-style: preserve-3d;
}
#container {
height: 100%;
width: 100%;
margin-left: 350px;
background-color: transparent;
-webkit-transition: all 400ms ease-in-out;
}
.holder {
float: left;
position: absolute;
margin-top: 100px;
margin-left: 20px;
-webkit-transition: all 300ms ease-in-out;
-webkit-box-reflect: below 4px
-webkit-gradient(
linear,
left top,
left bottom,
color-stop(0, rgba(255, 255, 255, 0)),
color-stop(.5, rgba(255, 255, 255, .3)),
color-stop(1, rgba(255, 255, 255, .3))
);
}
.slider {
position: absolute;
width: 200px;
height: 30px;
margin: 0 0 0 430px;
-webkit-appearance: none !important;
border-radius: 6px;
border: 1px solid white;
background: #999;
opacity: .5;
}
.slider::-webkit-slider-thumb {
-webkit-appearance: none !important;
width: 50px;
height: 18px;
border-radius: 8px;
border: 2px solid #fff;
background: -webkit-gradient(linear, left top, left bottom, color-stop(0, #999), color-stop(.5, #000) );
}
#log { color: white; font-size: 30pt; }
</style>
</head>
<body onload="flow()">
<div id="coverflow">
<div id="container">
<div class="holder" id="1"><img src="../img/1.jpg" width="200"></div>
<div class="holder" id="2"><img src="../img/2.jpg" width="200"></div>
<div class="holder" id="3"><img src="../img/3.jpg" width="200"></div>
<div class="holder" id="4"><img src="../img/4.jpg" width="200"></div>
<div class="holder" id="5"><img src="../img/5.jpg" width="200"></div>
<div class="holder" id="6"><img src="../img/6.jpg" width="200"></div>
<div class="holder" id="7"><img src="../img/7.jpg" width="200"></div>
<div class="holder" id="8"><img src="../img/8.jpg" width="200"></div>
<div class="holder" id="9"><img src="../img/9.jpg" width="200"></div>
<div class="holder" id="10"><img src="../img/1.jpg" width="200"></div>
<div class="holder" id="11"><img src="../img/2.jpg" width="200"></div>
</div>
</div>
<input id="slider" class="slider" type="range" min="1" max="11" value="6" onchange="flow();">
<a id="log">value</a>
<script>
function flow() {
var space = 2;
var coverCount = 11;
var current = slider.value;
var cover = document.getElementById(current + "");
var position = [0, 230, 180, 130, 80, 30, -20, -70, -120, -170, -220, -270];
for (var i = current; i < (coverCount +1); i++)
{
document.getElementById(i + "").style.webkitTransform = "translate3d("+((i+space)*50)+"px,0,-10px) rotateY(-65deg)";
document.getElementById(i + "").style.zIndex = -i + "";
}
for (var i = 1; i < current; i++)
{
document.getElementById(i + "").style.webkitTransform = "translate3d("+((i-space)*50)+"px,0,-10px) rotateY(65deg)";
document.getElementById(i + "").style.zIndex = i + "";
}
cover.style.webkitTransform = "translate3d("+(slider.value*50)+"px,0,100px) rotateY(0deg)";
cover.style.zIndex = current + "";
document.getElementById("container").style.marginLeft = position[current] + "px";
document.getElementById("log").innerHTML = slider.value + "";
}
</script>
</body>
</html>
i know you can find a lot of better coverflows this is just to share
Just remember to replace the path of the images and/or names
Hope it helps
Good Luck
I mainly stick with native App development, so I don't know if there is an existing cover flow implementation, but using Dashcode Parts you can add some more complex UI elements.
You could try xFlow! http://xflow.pwhitrow.com
i just made this
http://coulisse.luvdasun.com/
not sure if it works on iphone / ipod, i still have to test that
gr.
You can try this, I have developed specifically for iOS devices. Has touch gestures enabled.
http://jbkflex.wordpress.com/2012/08/21/css3-coverflow-animation-for-ios-adding-touch-gestures/