custom-threesixty.ts 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. // export interface IImage {
  2. // url: string | null;
  3. // href?: string;
  4. // clickAction?: Function;
  5. // caption?: string;
  6. // title?: string;
  7. // backgroundSize?: string;
  8. // backgroundPosition?: string;
  9. // backgroundRepeat?: string;
  10. // }
  11. // import { Http, Response, RequestOptions, Headers, Request, RequestMethod } from '@angular/http';
  12. import { CONFIG } from '../../app/config';
  13. declare var $:any;
  14. export class ImageClass{
  15. constructor( ){
  16. // this.http = http;
  17. }
  18. loaded(){
  19. $.getScript("assets/js/jquery.threesixty.js")
  20. var hotspotList=[];
  21. setTimeout(() => {
  22. var $threeSixty = $('.threesixty');
  23. var wid = 806/100;
  24. var hei = 520/100;
  25. var img_arr = [];
  26. var newx,newY,contentTitle,contentDescription,contentFile;
  27. for(var i=0;i<CONFIG.image360Sources.length;i++){
  28. img_arr.push(CONFIG.image360Sources[i].image_url)
  29. hotspotList[i] = []
  30. for(var j=0;j<CONFIG.image360Sources[i].hotspot.length;j++){
  31. // hotspotList[i].push(CONFIG.image360Sources[i].hotspot[j].point_arr)
  32. newx = wid*((CONFIG.image360Sources[i].hotspot[j].point_arr.x / 1024)*100);
  33. newY = hei*((CONFIG.image360Sources[i].hotspot[j].point_arr.y / 660)*100);
  34. var obj={
  35. x:newx,y:newY,contentTitle:CONFIG.image360Sources[i].hotspot[j].title,contentDescription:CONFIG.image360Sources[i].hotspot[j].description,contentFile:CONFIG.image360Sources[i].hotspot[j].thumb_image_url
  36. };
  37. hotspotList[i].push(obj)
  38. }
  39. }
  40. $threeSixty.threeSixty({
  41. dragDirection: 'horizontal',
  42. useKeys: true,
  43. draggable: false,
  44. imagearray: img_arr,
  45. hotspotArray:hotspotList,
  46. speed:100
  47. });
  48. $('.next').click(function () {
  49. $threeSixty.nextFrame();
  50. });
  51. $('.prev').click(function () {
  52. $threeSixty.prevFrame();
  53. });
  54. $threeSixty.on('down', function () {
  55. $('.ui, h1, h2, .label, .examples').stop().animate({ opacity: 0 }, 300);
  56. });
  57. $threeSixty.on('up', function () {
  58. $('.ui, h1, h2, .label, .examples').stop().animate({ opacity: 1 }, 500);
  59. });
  60. $('.threesixty').on('move', function(){
  61. })
  62. }, 500);
  63. }
  64. }