Gallery Responsive
Gallery Responsive by Andrew Pougher with Angular, JQuery, Bootstrap and some sparkles.
by Andrew Pougher
August 02, 2016
HTML
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/justifiedGallery/3.6.0/justifiedGallery.min.css">
<script src="//code.jquery.com/jquery-2.1.0.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/justifiedGallery/3.6.0/jquery.justifiedGallery.min.js"></script>
<div>
<div id="slideshow_wrap" ng-app="testApp" ng-controller="Ctrl">
<div justified id="justified">
<a ng-repeat="dir in dirs" ng-href="/#/dir/{{dir.id}}" repeat-done>
<img ng-src="{{dir.first_image}}" alt="{{dir.name}}"/>
</a>
</div>
</div>
</div>
<script>
/* http://bit.ly/ARP71 */
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-4809804-1', 'auto');
ga('send', 'pageview');
</script>
CSS
/* andrew pougher dev work 2015 at long f*** last I got angular to talk with a gallery library with some decency. Hope this helps others and saves you the time and effort it took me. I later incorporated this into MySql with a CMS for complete clientside control. Email me if you want to know how. */
JavaScript
var app = angular.module('testApp', []);
app.directive('justified', ['$timeout', function ($timeout) {
return {
restrict: 'AE',
link: function (scope, el, attrs) {
scope.$watch('$last', function (n, o) {
if (n) {
$timeout(function () { $(el[0]).justifiedGallery(); });
}
});
}
};
}]);
app.directive('repeatDone', [function () {
return {
restrict: 'A',
link: function (scope, element, iAttrs) {
var parentScope = element.parent().scope();
if (scope.$last){
parentScope.$last = true;
}
}
};
}]);
function Ctrl($scope) {
$scope.dirs = [{
id: 1,
name: "Andrew",
first_image: "http://placehold.it/900/3e3e45"
}, {
id: 2,
name: "Pougher",
first_image: "http://placehold.it/200/341435"
}, {
id: 3,
name: "Sweats",
first_image: "http://placehold.it/300/efefef"
}, {
id: 4,
name: "the",
first_image: "http://placehold.it/300/ege5ee"
}, {
id: 5,
name: "small stuff",
first_image: "http://placehold.it/300/444"
}];
}