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

slideshow.js 2.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  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', '$mixpanel', function ($scope, $rootScope, $famous, $timeline, $location, $route, $timeout, Data, $mixpanel) {
  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. $mixpanel.track('Page View', { "Page": $scope.pageData.link });
  21. });
  22. }
  23. });
  24. // FadeIn
  25. $timeout(function(){
  26. $scope.showView = true;
  27. },100);
  28. // FadeOut
  29. $scope.fadeOut = function() {
  30. $scope.showView = false;
  31. $timeout(function(){
  32. $scope.showView = false;
  33. $location.path("/");
  34. },800);
  35. };
  36. $scope.index = 0;
  37. $scope.images = [];
  38. $scope.showSlider = function() {
  39. var show = false;
  40. if($scope.pageData.slides !== undefined) {
  41. if($scope.pageData.slides.length > 0) {
  42. show = true;
  43. for (var i = 0; i < $scope.pageData.slides.length; i++) {
  44. $scope.images.push($scope.pageData.slides[i].url);
  45. }
  46. } else {
  47. show = false;
  48. }
  49. if(!$scope.$$phase) {
  50. $scope.$apply(function(){
  51. $scope.slider = show;
  52. });
  53. } else {
  54. $scope.slider = show;
  55. }
  56. $timeout(function(){
  57. //$scope.resizeImages();
  58. },250);
  59. }
  60. };
  61. // callbacks for change in slides
  62. $scope.updateTsPrevious = function() {
  63. $scope.tsPrevious = +new Date();
  64. //$scope.resizeImages();
  65. };
  66. $scope.updateTsNext = function() {
  67. $scope.tsNext = +new Date();
  68. //$scope.resizeImages();
  69. };
  70. $scope.resizeImages = function() {
  71. var allImages = [];
  72. var clientHeight = document.getElementById('slider').clientHeight;
  73. $('img').each(function(idx, img) {
  74. allImages.push(img);
  75. });
  76. console.log('> Starting image resize process (resizing to ' + clientHeight + 'px)');
  77. for(var i = 0, max = allImages.length; i < max; i++){
  78. console.log('> resizing image');
  79. allImages[i].style.height = (clientHeight-25) + 'px';
  80. allImages[i].style.maxHeight = 'none';
  81. allImages[i].style.width = 'auto';
  82. }
  83. };
  84. $scope.showSlider();
  85. }]);