Personal portfolio website for Regina Carvalho. Built with Famous.js library.

slideshow.js 2.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. /**
  2. * @ngdoc function
  3. * @name domainManagerApp.controller:AboutCtrl
  4. * @description
  5. * # AboutCtrl
  6. * Controller of the domainManagerApp
  7. */
  8. angular.module('goApp.slideshow', ['ngFx', 'ngAnimate', 'goApp.data'])
  9. .controller('SlideshowController',['$scope', '$rootScope', '$famous', '$timeline', '$location', '$route', '$timeout', 'Data', function ($scope, $rootScope, $famous, $timeline, $location, $route, $timeout, Data) {
  10. 'use strict';
  11. console.log('> Loading Slideshow');
  12. // Get Page Data
  13. var link = $location.url();
  14. $scope.pageData = Data.getPageData(link);
  15. $rootScope.$on('data:loaded', function(data) {
  16. if(!$scope.$$phase) {
  17. $scope.$apply(function(){
  18. $scope.pageData = Data.getPageData(link);
  19. $scope.showSlider();
  20. });
  21. }
  22. });
  23. // FadeIn
  24. $timeout(function(){
  25. $scope.showView = true;
  26. },100);
  27. // FadeOut
  28. $scope.fadeOut = function() {
  29. $scope.showView = false;
  30. $timeout(function(){
  31. $scope.showView = false;
  32. $location.path("/");
  33. },800);
  34. };
  35. $scope.index = 0;
  36. $scope.images = [];
  37. $scope.showSlider = function() {
  38. var show = false;
  39. if($scope.pageData.slides !== undefined) {
  40. if($scope.pageData.slides.length > 0) {
  41. show = true;
  42. for (var i = 0; i < $scope.pageData.slides.length; i++) {
  43. $scope.images.push($scope.pageData.slides[i].url);
  44. }
  45. } else {
  46. show = false;
  47. }
  48. if(!$scope.$$phase) {
  49. $scope.$apply(function(){
  50. $scope.slider = show;
  51. });
  52. } else {
  53. $scope.slider = show;
  54. }
  55. $timeout(function(){
  56. //$scope.resizeImages();
  57. },250);
  58. }
  59. };
  60. // callbacks for change in slides
  61. $scope.updateTsPrevious = function() {
  62. $scope.tsPrevious = +new Date();
  63. //$scope.resizeImages();
  64. };
  65. $scope.updateTsNext = function() {
  66. $scope.tsNext = +new Date();
  67. //$scope.resizeImages();
  68. };
  69. $scope.resizeImages = function() {
  70. var allImages = [];
  71. var clientHeight = document.getElementById('slider').clientHeight;
  72. $('img').each(function(idx, img) {
  73. allImages.push(img);
  74. });
  75. console.log('> Starting image resize process (resizing to ' + clientHeight + 'px)');
  76. for(var i = 0, max = allImages.length; i < max; i++){
  77. console.log('> resizing image');
  78. allImages[i].style.height = (clientHeight-25) + 'px';
  79. allImages[i].style.maxHeight = 'none';
  80. allImages[i].style.width = 'auto';
  81. }
  82. };
  83. $scope.showSlider();
  84. }]);