sdk-tag-click.html 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8" />
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  6. <title>Document</title>
  7. <style>
  8. html,
  9. body {
  10. width: 100%;
  11. height: 100%;
  12. margin: 0;
  13. overflow: hidden;
  14. }
  15. .scene {
  16. width: 100%;
  17. height: 100%;
  18. }
  19. #toolbar {
  20. position: absolute;
  21. left: 50%;
  22. top: 0;
  23. z-index: 10000;
  24. }
  25. [xui_tags_view] .tag-body {
  26. position: absolute;
  27. right: 0;
  28. top: 50%;
  29. margin-right: 70px;
  30. width: 200px;
  31. height: 200px;
  32. transform: translateY(50%) scale(0);
  33. transform-origin: calc(100% + 40px) -50%;
  34. transition: all 0.3s cubic-bezier(0.35, 0.32, 0.65, 0.63);
  35. background: rgba(27, 27, 28, 0.8);
  36. border-radius: 4px;
  37. min-width: 400px;
  38. padding: 30px 20px;
  39. }
  40. [xui_tags_view] .tag-body::after {
  41. content: '';
  42. position: absolute;
  43. top: 50%;
  44. right: -39px;
  45. width: 0;
  46. height: 0;
  47. border-top: 15px solid transparent;
  48. border-bottom: 15px solid transparent;
  49. border-left: 40px solid rgba(27, 27, 28, 0.8);
  50. transform: translateY(-50%);
  51. }
  52. [xui_tags_view] .tag-body.show {
  53. transform: translateY(-50%) scale(1);
  54. }
  55. .title {
  56. font-size: 20px;
  57. font-weight: bold;
  58. line-height: 30px;
  59. color: #fff;
  60. position: relative;
  61. }
  62. .content {
  63. margin-top: 10px;
  64. font-size: 14px;
  65. color: #999;
  66. line-height: 20px;
  67. text-align: justify;
  68. word-break: break-all;
  69. }
  70. .content p {
  71. margin: 0;
  72. padding: 0;
  73. }
  74. </style>
  75. </head>
  76. <body>
  77. <div id="scene" class="scene"></div>
  78. <script src="../dist/sdk/kankan-sdk-deps.js"></script>
  79. <script src="../dist/sdk/kankan-sdk.js"></script>
  80. <script>
  81. var kankan = new KanKan({
  82. dom: '#scene',
  83. num: 't-GM44NgSkjr',
  84. tag:{
  85. showIn:'floorplan,dollhouse'
  86. }
  87. // num: 'eur-YbbHyQ5OF',
  88. // server:'https://eur.4dkankan.com/',
  89. // resource:'https://eurs3.4dkankan.com/'
  90. })
  91. kankan
  92. .use('TagView', {
  93. render(data) {
  94. return `<span class="tag-icon animate" style="background-image:url({{icon}})"></span><div class="tag-body"></div>`
  95. },
  96. })
  97. .then(view => {
  98. view.on('rendered', () => {
  99. // 动态构造面板内容
  100. function billboard(data) {
  101. return `
  102. <div class="title">${data.title}</div>
  103. <div class="content">${data.content}</div>
  104. `
  105. }
  106. function open(e) {
  107. if (e.$tag.classList.contains('fixed')) {
  108. return
  109. }
  110. view.tags.forEach(item => {
  111. view.$tags[item.sid].querySelector('.tag-body').innerHTML = ''
  112. view.$tags[item.sid].querySelector('.tag-body').classList.remove('show')
  113. })
  114. var $body = e.$tag.querySelector('.tag-body')
  115. $body.innerHTML = billboard(e.data)
  116. $body.classList.add('show')
  117. }
  118. function close(e) {
  119. if (e.$tag.classList.contains('fixed')) {
  120. return
  121. }
  122. let $body = e.$tag.querySelector('.tag-body')
  123. $body.classList.remove('show')
  124. }
  125. view.on('click', e => view.focus(e.data.sid, 'left').then(() => open(e)))
  126. view.on('mouseenter', e => open(e))
  127. view.on('mouseleave', e => close(e))
  128. // 切换点位时关闭热点面板
  129. kankan.Camera.on('flying.started', () => {
  130. if (!view.isAimating && view.$tag) {
  131. view.$tag.classList.remove('fixed')
  132. close({ $tag: view.$tag })
  133. }
  134. })
  135. })
  136. })
  137. kankan.render()
  138. </script>
  139. </body>
  140. </html>