LOADING...

Preview

Pen ID
Unlock Campus Themeforest adv

 

Code
ig feed
CSS
@import url(https://fonts.googleapis.com/css?family=Open+Sans+Condensed:300,300italic,700);
body {
  margin: 0;
  padding: 0;
  font-family: 'Open Sans Condensed', sans-serif;
  background-color: #1D1F20;
  position: relative;
}

.igviewer {
  position: fixed;
  top: 0;
  bottom: 0;
  right: 0;
  left: 0;
  background-color: RGBA(29, 31, 32, 0.9);
}
.igviewer img {
  display: block;
  margin: 1rem auto;
  height: calc(100vh - 2rem);
  width: auto;
  box-shadow: 0px 10px 40px 10px rgba(0, 0, 0, 0.8);
}
.igviewer.hidden {
  display: none;
}

.instagram {
  display: -webkit-flex;
  display: flex;
  -webkit-flex-flow: row wrap;
  flex-flow: row wrap;
  overflow: hidden;
  width: 1024px;
  margin: 0 auto;
}
.instagram .image {
  background-repeat: none;
  background-position: center center;
  background-size: 100%;
  width: 248px;
  height: 248px;
  margin: 4px;
  overflow: hidden;
  transition: all 200ms ease;
  position: relative;
  cursor: pointer;
}
.instagram .image .caption {
  display: none;
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background-color: rgba(0, 0, 0, 0.7);
  color: #FFF;
  padding: 1em;
}
.instagram .image:hover {
  background-size: 110%;
}
.instagram .image:hover .caption {
  display: block;
}
JS
var ig = {};
// !!! USE YOUR OWN TOKEN
ig.token = '189242245.e4579bd.785b15a243fe4d87918dc5982b136bbd';

ig.init = function() {
  $('.instagram').each(function(i) {
    var args = {};
    args.container = $(this);
    args.userid = args.container.data('userid');
    args.limit = args.container.data('limit');
    args.feedurl = 'https://api.instagram.com/v1/users/'+args.userid+'/media/recent/?access_token='+ig.token+'&count='+args.limit+'&callback=?';
    args.html = '';
    // PASS ARGS TO QUERY
    ig.query(args);
  });
}

ig.query = function(args) {
  $.getJSON(args.feedurl, {}, function(data) {
		// PASS QUERY DATA TO BUILDER
		ig.build(data, args);
	});
}


ig.build = function(data, args) {
  
  $.each(data.data,function (i,item) {
    console.log(item);
    if (item.caption) var caption = item.caption.text;
    var thumb = item.images.low_resolution.url;
    var img = item.images.standard_resolution.url;
    //get 1280 size photo [hack until avail in api]
    var hires = img.replace('s640x640', '1080x1080');
    args.html += '';
    if (caption) args.html += ''+caption+'';
    args.html += '';
    // PASS TO OUTPUT
    ig.output(args);
  });
}

ig.output = function(args) {
  args.container.html(args.html);
}

ig.view = {
  viewer: $('.igviewer'),
  image: $('.igviewer img'),
  open: function(img) {
    ig.view.viewer.removeClass('hidden');
    ig.view.image.attr('src', img); 
  },
  close: function() {
    ig.view.viewer.addClass('hidden');
    ig.view.image.attr('src', ''); 
  }
}

ig.init();

//Listeners
$('.instagram').on('click', '.image', function(){
  var img = this.dataset.img;
  ig.view.open(img);
});
$('.igviewer').on('click', function(){
  ig.view.close();
});

Description

js/jquery/html5 instagram feed
Term
Mon, 11/27/2017 - 21:25

Related Codes

Pen ID
Pen ID
Pen ID
Square Adv