scrolling up set of pictures up and down on hover function - javascript

I have been working on a portfolio for a small firm that I have. I was planning to have the same function as this one from e-onetime http://eone-time.com/#team do you think this is possible with a gif image. The function that I would like to have is that on hover gif animated 1 time, or should I set multiple images like what they did on their portfolio and let it scroll up and down onclick.
This is a section from my TEAM section in which the static gif and animated gif is located:
<!-- Team Section -->
<section id="team" class="content-section text-center">
<div class="team-section">
<div class="container">
<div class="col-lg-8 col-lg-offset-2">
<h1>TEAM</h1>
<HR>
</div>
</div>
<!-- Team Grid --><section class="main">
<div id="items">
<div class="item">
<a id="1" class="work page-scroll">
<img class="media" src="img/tryimages/greggy.png"/>
<div class="content">
<img class="media" src="img/tryimages/greggy.gif"/>
<!--<h2 class="title">Click</h2>!-->
</div>
</a>
</div>
<div class="item">
<a id="2" class="work page-scroll">
<img class="media" src="img/tryimages/dennise.png"/>
<div class="content">
<img class="media" src="img/tryimages/dennise.gif"/>
</div>
</a>
</div>
<div class="item">
<a id="3" class="work page-scroll">
<img class="media" src="img/tryimages/jm.png"/>
<div class="content">
<img class="media" src="img/tryimages/jm.gif"/>
</div>
</a>
</div>
<div class="item">
<a id="4" class="work page-scroll">
<img class="media" src="img/tryimages/hannah.png"/>
<div class="content">
<img class="media" src="img/tryimages/hannah.gif"/>
</div>
</a>
</div>
</div>
</section><!-- End of Works Grid -->
This is the javascript function I have for my team profiler:
</script>
<!--Team JS Function!-->
<script>
$("#items a").click(function() {
var id = $(this).attr("id");
$("#pages div, #pages2 div").siblings().hide("slow");
$("#pages div#" + id + "").toggle("slow");
});
$("#items2 a").click(function() {
var id = $(this).attr("id");
$("#pages2 div, #pages div").siblings().hide("slow");
$("#pages2 div#" + id + "").toggle("slow");
});
</script>

just animate background-image using css keyframes for a .animated class, and then add this to your javascript:
$('#items a').mouseover(function(){
$(this).toggleClass('animated');
});

Related

Onclick of Image (used in element <a>) not working in jquery

I have this footer of a fixed nav-bar in Div.
<div id="footer">
<div class="col-xs-12 navbar-inverse navbar-fixed-bottom">
<div class="row" id="bottomNav">
<div class="col-xs-4 text-center">
<a id="id1" href="#">
<img id="image1" src='img/feature1.png' alt='missing'>
<div class="caption">Act-1</div>
</a>
</div>
<div class="col-xs-4 text-center">
<a id="id2" href="#">
<img id="image2" src='img/feature2.png' alt='missing'>
<div class="caption">Act-2</div>
</a>
</div>
<div class="col-xs-4 text-center">
<a id="id3" href="#">
<img id="image3" src='img/feature3.png' alt='missing'>
<div class="caption">Act-3</div>
</a>
</div>
</div>
</div>
</div>
On click of image1, I want to do some stuff. I am using alert to test it. The jquery function is in a separate js file which is added in the html. This is the only function js file has in it. I tried to use #id1 and #image1 both in the ebelow function, but it just would not get called.
$("#image1").click(function() {
alert("you are in Act-1 window");
});
what's wrong in such a simple code, i just can't get it.
Your code works fine. It seems to be working for me. The alert gets called if that is what you are looking for
$("#image1").click(function() {
alert("you are in Act-1 window");
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="footer">
<div class="col-xs-12 navbar-inverse navbar-fixed-bottom">
<div class="row" id="bottomNav">
<div class="col-xs-4 text-center">
<a id="id1" href="#">
<img id="image1" src='img/feature1.png' alt='missing'>
<div class="caption">Act-1</div>
</a>
</div>
<div class="col-xs-4 text-center">
<a id="id2" href="#">
<img id="image2" src='img/feature2.png' alt='missing'>
<div class="caption">Act-2</div>
</a>
</div>
<div class="col-xs-4 text-center">
<a id="id3" href="#">
<img id="image3" src='img/feature3.png' alt='missing'>
<div class="caption">Act-3</div>
</a>
</div>
</div>
</div>
</div>
Why you put the image inside a href="#" if you are not going to use it? here you have the error
You can also avoid jQuery by vanila js.
var img = document.querySelector('#YourID');
img.addEventListener('click', handler function);
It's better to use separated function for handling ( in this case you can remove the handler).

Masonry blocks shift while loaded

Hey guys having a problem with masonry plugin.
I'm trying to load the simple layout using percentPosition: true; and the problem is when everything loads, layout loads without the gutter and adds it later which causes all images to shift and it looks quiet annoying.
cant seem to figure out the solution to load it the way that nothing would shift. Bellow is the code:
and here is the link: dev3.oaknyc.com
<div class="section group">
<div class="col-sizer"></div>
<div class="gutter-sizer"></div>
<div class="col col-span2">
<img src={{media url="img/10-21/1.jpg"}}>
<a href={{store url="blog/introducing-hope-shoes-more/"}}>
<div class="txt-overlay">
<div class="txt-title">
<span>Introducing:</span>
<h3>HOPE for women + men</h3>
</div>
</div>
</a>
</div>
<div class="col">
<img src={{media url="img/10-21/2.jpg"}}>
<a href={{store url="women/new-items.html"}}>
<div class="txt-overlay">
<div class="txt-title">
<span>Just In:</span>
<h3>HENRIK VIBSKOV</h3>
</div>
</div>
</a>
</div>
<div class="col">
<img src={{media url="img/10-21/3.jpg"}}>
<a href={{store url="women/designers/oak.html"}}>
<div class="txt-overlay">
<div class="txt-title">
<span>Shop:</span>
<h3>OAK Collection Women</h3>
</div>
</div>
</a>
</div>
<div class="col">
<img src={{media url="img/10-21/4.jpg"}}>
<a href={{store url="men/designers/oak-collection.html"}}>
<div class="txt-overlay">
<div class="txt-title">
<span>Shop:</span>
<h3> OAK Collection Men</h3>
</div>
</div>
</a>
</div>
<div class="col col-span2">
<img src={{media url="wysiwyg/blanco/img/10-21/5.jpg"}}>
<a href={{store url="women/designers/laura-siegel.html"}}>
<div class="txt-overlay">
<div class="txt-title">
<span>Shop:</span>
<h3>Laura Siegel</h3>
</div>
</div>
</a>
</div>
<div class="col">
<img src={{media url="img/10-21/6.jpg"}}>
<a href={{store url="women/accessories.html"}}>
<div class="txt-overlay">
<div class="txt-title">
<span>Shop:</span>
<h3>Women's Accessories</h3>
</div>
</div>
</a>
</div>
<script src="https://npmcdn.com/imagesloaded#4.1/imagesloaded.pkgd.min.js"></script>
<script type="text/javascript">
//<![CDATA[
jQuery(document).ready(function(){
jQuery('.section').imagesLoaded(function(){
jQuery('.section').masonry({
// options
columnWidth: '.col-sizer',
itemSelector: '.col',
gutter: '.gutter-sizer',
percentPosition: true
});
});
});
//]]>
</script>

How to get automatically different images using modal in Semantic UI?

I'm trying to use modals with cards in Semantic UI. The concept is to click on the button on the card and display a modal with an image and description. I have 48 cards and I need different images with an every click on the card --> When I click on the card nr 1 - it shows the image number1, when I click on the card number2- it shows the image number 2, when I click on the card number 48- it shows the image nr 48 etc.
How can I get automatically each image from the card?
I'm a quite beginner with this stuff and I'm wondering if there is possible to use .append() with .each() in that case? Like this:
<script>
$(function(){
$('.ui.modal > .image').append($('.dimage')); //it adds only one image, but maybe there's a way to adds other ones using this script with minor modifications
});
</script>
This is excerpt from my code:
<!--head-->
<script>
$(function(){
$('.center > .ui.inverted.button').click(function(){
$('.ui.modal').modal('show');
});
});
</script>
<!-- my body-->
<div class="ui basic container">
<div class="ui four doubling special cards">
<div class="card">
<div class="blurring dimmable image">
<div class="ui dimmer">
<div class="content">
<div class="center">
<div class="ui inverted button">Show</div>
</div>
</div>
</div><!--ui dimmer-->
<img src="images/snacks/snack9.jpg">
</div>
<div class="content">
<a class="header">Snacks</a>
<div class="meta">
<span class="date">veggie/fruity</span>
</div>
</div>
</div><!--card-->
<div class="card">
<div class="blurring dimmable image">
<div class="ui dimmer">
<div class="content">
<div class="center">
<div class="ui inverted button">Show</div>
</div>
</div>
</div><!--ui dimmer-->
<img src="images/snacks/snack10.jpg">
</div>
<div class="content">
<a class="header">Snacks</a>
<div class="meta">
<span class="date">veggie/fruity</span>
</div>
</div>
</div><!--card-->
<div class="card">
<div class="blurring dimmable image">
<div class="ui dimmer">
<div class="content">
<div class="center">
<div class="ui inverted button">Show</div>
</div>
</div>
</div><!--ui dimmer-->
<img src="images/snacks/snack11.jpg">
</div>
<div class="content">
<a class="header">Snacks</a>
<div class="meta">
<span class="date">veggie/fruity</span>
</div>
</div>
</div><!--card-->
<div class="card">
<div class="blurring dimmable image">
<div class="ui dimmer">
<div class="content">
<div class="center">
<div class="ui inverted button">Show</div>
</div>
</div>
</div><!--ui dimmer-->
<img class="dimage" src="images/snacks/snack12.jpg">
</div>
<div class="content">
<a class="header">Snacks</a>
<div class="meta">
<span class="date">veggie/fruity</span>
</div>
</div>
</div><!--card-->
</div><!--ui four doubling special cards-->
<div class="ui modal">
<i class="close icon"></i>
<div class="header">
Modal Title
</div>
<div class="image content">
<div class="image">
An image can appear on the left
</div>
<div class="description">
A description can appear on the right
</div>
</div>
</div>
</div><!--ui basic container-->
Try the code below: https://jsfiddle.net/y7nd7qxw/. I had to adjust your card HTML a bit because the button wasn't showing up, but with the CSS you probably have it should be fine how you had it. Basically what I'm doing is storing the modal information on the data- attributes of your button. Then I'm getting those values in the click event and assigning them to the elements in the modal.
<!--head-->
<script>
$(function() {
var modal = $('#my-modal'), // hold reference to modal
modalImg = $('#modal-img'), // hold reference to image in modal
modalDesc = $('#modal-desc'); // hold reference to description in modal
//give your button an easier class reference
$('.show-modal').on('click', function() {
var button = $(this);
modalImg.attr('src', button.data('img'));
modalDesc.text(button.data('desc'));
modal.modal('show');
});
});
</script>
<!-- my body-->
<div class="ui basic container">
<div class="ui four doubling special cards">
<div class="card">
<div class="blurring dimmable image">
<div class="ui inverted button show-modal" data-desc="here is some description" data-img="http://placehold.it/200">Show</div>
<!--ui dimmer-->
<img src="images/snacks/snack9.jpg">
</div>
<div class="content">
<a class="header">Snacks</a>
<div class="meta">
<span class="date">veggie/fruity</span>
</div>
</div>
</div>
<!--card-->
<div class="card">
<div class="blurring dimmable image">
<div class="ui inverted button show-modal" data-desc="some other description description" data-img="http://placehold.it/400">Show</div>
<!--ui dimmer-->
<img src="images/snacks/snack9.jpg">
</div>
<div class="content">
<a class="header">Snacks</a>
<div class="meta">
<span class="date">veggie/fruity</span>
</div>
</div>
</div>
<!--card-->
</div>
<!--ui four doubling special cards-->
<div class="ui modal" id="my-modal">
<i class="close icon"></i>
<div class="header">
Modal Title
</div>
<div class="image content">
<div class="image">
<img src="" alt="" id="modal-img">
</div>
<div class="description">
<p id="modal-desc"></p>
</div>
</div>
</div>
</div>
<!--ui basic container-->

Issue Blueimp gallery Twitter Bootstrap

I'm using Blueimp gallery to present some images on my website. There are 8 images divided in two rows. The 5th thumbnail (first image on the second row) seems broken, although I can see it in the carousel presentation.
![thumbnails]:https://drive.google.com/file/d/0ByO6EWQ4CgAUaGwzbXhnWDlBWFU/view?usp=sharing
Here's the code
<!-- The Gallery as lightbox dialog, should be a child element of the document body -->
<div id="blueimp-gallery" class="blueimp-gallery blueimp-gallery-controls">
<div class="slides"></div>
<h3 class="title"></h3>
<a class="prev">‹</a>
<a class="next">›</a>
<a class="close">×</a>
<a class="play-pause"></a>
<ol class="indicator"></ol>
</div>
<div id="links">
<div class="row">
<div class="col-xs-2 col-xs-offset-3">
<a href="img/117.jpg" class="thumbnail">
<img src="img/thumbnails/117.jpg">
</a>
</div>
<div class="col-xs-2">
<a href="img/119.jpg" class="thumbnail">
<img src="img/thumbnails/119.jpg">
</a>
</div>
<div class="col-xs-2">
<a href="img/120.jpg" class="thumbnail">
<img src="img/thumbnails/120.jpg">
</a>
</div>
<div class="col-xs-2">
<a href="img/121.jpg" class="thumbnail">
<img src="img/thumbnails/121.jpg">
</a>
</div>
</div>
<div class="row">
<div class="col-xs-2 col-xs-offset-3">
<a href="img/125.jpg" class="thumbnail">
<img src="img/tumbnails/125.jpg">
</a>
</div>
<div class="col-xs-2">
<a href="img/128.jpg" class="thumbnail">
<img src="img/thumbnails/128.jpg">
</a>
</div>
<div class="col-xs-2">
<a href="img/129.jpg" class="thumbnail">
<img src="img/thumbnails/129.jpg">
</a>
</div>
<div class="col-xs-2">
<a href="img/130.jpg" class="thumbnail">
<img src="img/thumbnails/130.jpg">
</a>
</div>
</div>
</div>
<script>
document.getElementById('links').onclick = function (event) {
event = event || window.event;
var target = event.target || event.srcElement,
link = target.src ? target.parentNode : target,
options = {index: link, event: event},
links = this.getElementsByTagName('a');
blueimp.Gallery(links, options);
};
</script>
Does anyone have an idea of what can be happening here. Thanks in advance!
You have a typo: change
<img src="img/tumbnails/125.jpg">
to (add the 'h')
<img src="img/thumbnails/125.jpg">
:)

Individual transitions on Semantic UI cards fail

I'm trying to apply transitions as explained in here, but some cards fail to do a second transition/animation. Is it CSS, Semantic UI or me? You can try adding more cards to the test.
Edit:
As #niba requested, I made a jsfiddle to show what is
happening. Look that I named cards from "Card 0" to "Card 7". Run
several times and you may see some are missing.
Here is the code:
$(document)
.ready(function() {
$('.card')
.transition('fade')
.transition('fade', function() {
console.log('finished');
});
<div class="ui cards">
<div class="green card">
<div class="image">
<img src="img/1.jpg">
</div>
<div class="content">
<a class="header">Header</a>
<div class="meta">
<div class="ui small star rating"></div>
</div>
<div class="description">Description</div>
</div>
</div>
<div class="green card">
<div class="image">
<img src="img/2.jpg">
</div>
<div class="content">
<a class="header">Header</a>
<div class="meta">
<div class="ui small star rating"></div>
</div>
<div class="description">Description</div>
</div>
</div>
<div class="green card">
<div class="image">
<img src="img/3.jpg">
</div>
<div class="content">
<a class="header">Header</a>
<div class="meta">
<div class="ui small star rating"></div>
</div>
<div class="description">Description</div>
</div>
</div>
</div>

Categories