index.js 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602
  1. let result;
  2. $.ajax({
  3. method: "GET",
  4. url: "../json/realtime.json",
  5. dataType: "json",
  6. }).done(function (msg) {
  7. result = [...msg];
  8. renderSec00(result);
  9. renderSec02(result);
  10. renderSec05(result);
  11. renderSec06(result);
  12. renderSec07(result);
  13. renderSec08(result);
  14. renderSec09(result);
  15. renderSec10(result);
  16. renderVideo(result);
  17. renderTrending(result);
  18. });
  19. function renderSec00(data) {
  20. let temp = data[0]['data'];
  21. renderBannerStr('sec-00__slider', temp);
  22. $(".sec-00__slider").slick({
  23. dots: false,
  24. speed: 800,
  25. autoplay: true,
  26. autoplaySpeed: 5000,
  27. arrows: false,
  28. });
  29. }
  30. function renderSec02(data) {
  31. let temp = data[1]['data'];
  32. renderBannerStr('sec-02__slider', temp);
  33. $(".sec-02__slider").slick({
  34. dots: false,
  35. autoplay: true,
  36. arrows: true,
  37. fade: true,
  38. autoplaySpeed: 4000,
  39. });
  40. }
  41. function renderBannerStr(sec, data) {
  42. let str = '';
  43. for(let i = 0; i < data.length; i++){
  44. str+= `<div class="${sec}-${i+1} slide-item" onclick="window.open('${data[i]['link']}');" style="background-image: url('${data[i]['DimgUrl']}');" data-bg="${data[i]['DimgUrl']}"></div>`
  45. }
  46. $(`.${sec}`).html(str);
  47. }
  48. function renderSec05(data) {
  49. let randomIdx = Math.floor(Math.random()*3);
  50. const ran = $('.sec-05__tabdiv .nav-pills li').eq(randomIdx);
  51. const ranDiv = $('.sec-05tab-content>div').eq(randomIdx);
  52. $('.sec-05tab-content>div').hide();
  53. ranDiv.show();
  54. ran.addClass('active');
  55. ran.children().addClass('active');
  56. $('.sec-05 .morelink').attr('href', $('.sec-05__tabdiv .nav-item-link.active').data('link'));
  57. let temp = data[2]['data'];
  58. for(let i = 0; i < temp.length; i++){
  59. if(temp[i]["tab"] == '最夯設計'){
  60. let str = '';
  61. let sub = temp[i]["data"];
  62. for(let j = 0; j < sub.length; j++){
  63. str+= `<div class="tabpar__card" onclick="window.open('${sub[j]['link']}');">
  64. <div class="tabpar__card__imgfr mb-2" style="background-image: url('${sub[j]['imgUrl']}');" data-bg="${sub[j]['imgUrl']}"></div>
  65. <h5 class="mb-2 me-2">${sub[j]['title']}</h5>
  66. <p class="mt-2">${sub[j]['description']}</p>
  67. </div>`;
  68. }
  69. $('#pills-hot-tab .tabpar').html(str);
  70. }
  71. if(temp[i]["tab"] == '影音實錄'){
  72. let str = '';
  73. let sub = temp[i]["data"];
  74. for(let j = 0; j < sub.length; j++){
  75. str+= `<div class="tabpar__card" onclick="window.open('${sub[j]['link']}');">
  76. <div class="tabpar__card__imgfr mb-2" style="background-image: url('${sub[j]['imgUrl']}');" data-bg="${sub[j]['imgUrl']}"><img data-src="images/Play-Button.webp" alt="" class="tabpar__card__play lazyload"></div>
  77. <h5 class="mb-2 me-2">${sub[j]['title']}</h5>
  78. <p class="mt-2">${sub[j]['description']}</p>
  79. </div>`;
  80. }
  81. $('#pills-video-tab .tabpar').html(str);
  82. }
  83. if(temp[i]["tab"] == '專欄文章'){
  84. let str = '';
  85. let sub = temp[i]["data"];
  86. for(let j = 0; j < sub.length; j++){
  87. str+= `<div class="tabpar__card" onclick="window.open('${sub[j]['link']}');">
  88. <div class="tabpar__card__imgfr mb-2" style="background-image: url('${sub[j]['imgUrl']}');" data-bg="${sub[j]['imgUrl']}"></div>
  89. <h5 class="mb-2 me-2">${sub[j]['title']}</h5>
  90. <p class="mt-2">${sub[j]['description']}</p>
  91. </div>`;
  92. }
  93. $('#pills-blog-tab .tabpar').html(str);
  94. }
  95. }
  96. const cardText = document.querySelectorAll('.tabpar__card p');
  97. cardText.forEach((item, i) => {
  98. let len = item.textContent.length;
  99. if(len > 20) {
  100. let str = item.textContent.substring(0, 20) + '...';
  101. item.textContent = str;
  102. }
  103. })
  104. $('.sec-05__tabdiv .nav-pills button').on('click', function(event){
  105. event.preventDefault();
  106. $('.sec-05__tabdiv .nav-pills li').removeClass('active');
  107. $('.sec-05__tabdiv .nav-pills li button').removeClass('active');
  108. $(this).addClass('active');
  109. $(this).parent().addClass('active');
  110. $('.sec-05tab-content>div').hide();
  111. var target = $(this).attr('id');
  112. $(`#pills-tab #${target}`).show();
  113. $('.sec-05tab-content .tabpar').slick('setPosition');
  114. });
  115. $(`.sec-05tab-content .tabpar`).slick({
  116. arrows: true,
  117. slidesToShow: 3,
  118. infinite: false,
  119. dots: false,
  120. slidesToScroll: 1,
  121. prevArrow: '<button type="button" class="slick-prev"><i class="fas fa-chevron-left" style="font-size: 35px;color: black;"></i></button>',
  122. nextArrow: '<button type="button" class="slick-next"><i class="fas fa-chevron-right" style="font-size: 35px;color: black;"></i></button>'
  123. });
  124. $('.sec-05__tabdiv .nav-item-link').click(function() {
  125. $('.sec-05 .morelink').attr('href',$('.sec-05__tabdiv .nav-item-link.active').data('link'));
  126. });
  127. }
  128. function renderSec06(data) {
  129. let temp = data[3]['data'];
  130. let str = '';
  131. for(let i = 0; i < temp.length; i++){
  132. if(temp[i].video == 'true'){
  133. str+= `<div class="sec-06__card" onclick="window.open('${temp[i]['link']}');">
  134. <div class="sec-06__card__outer"><div class="sec-06__card__imgfr mb-2" style="background-image: url('${temp[i]['imgUrl']}');" data-bg="${temp[i]['imgUrl']}"><img class="sec-06__card__play lazyload" data-src="images/Play-Button.webp"></div></div>
  135. <h5 class="mb-2 mt-2">${temp[i]['title']}</h5>
  136. <p class="mt-2">${temp[i]['description']}</p>
  137. </div>`;
  138. } else {
  139. str+= `<div class="sec-06__card" onclick="window.open('${temp[i]['link']}');">
  140. <div class="sec-06__card__outer"><div class="sec-06__card__imgfr mb-2" style="background-image: url('${temp[i]['imgUrl']}');" data-bg="${temp[i]['imgUrl']}"></div></div>
  141. <h5 class="mb-2 mt-2">${temp[i]['title']}</h5>
  142. <p class="mt-2">${temp[i]['description']}</p>
  143. </div>`;
  144. }
  145. }
  146. $('.sec-06 .sec-06__slider').html(str);
  147. $('.sec-06__slider').slick({
  148. arrows: true,
  149. dots: false,
  150. speed: 800,
  151. prevArrow: '<button type="button" class="slick-prev"><i class="fas fa-chevron-left" style="font-size: 30px;color: white;"></i></button>',
  152. nextArrow: '<button type="button" class="slick-next"><i class="fas fa-chevron-right" style="font-size: 30px;color: white;"></i></button>'
  153. });
  154. const cardText = document.querySelectorAll('.sec-06__card p');
  155. cardText.forEach((item, i) => {
  156. let len = item.textContent.length;
  157. if(len > 20) {
  158. let str = item.textContent.substring(0, 40) + '...';
  159. item.textContent = str;
  160. }
  161. });
  162. }
  163. function renderSec07(data) {
  164. let temp = data[5]['data'];
  165. let str = '';
  166. for(let i = 0; i < temp.length; i++){
  167. str+= `<div class="sec-07__slider-${i+1} slide-item" onclick="window.open('${temp[i]['link']}');" style="background-image: url('${temp[i]['imgUrl']}');" data-bg="${temp[i]['imgUrl']}"></div>`
  168. }
  169. $(`.sec-07__slider`).html(str);
  170. $(".sec-07__slider").slick({
  171. dots: false,
  172. autoplay: true,
  173. arrows: false,
  174. slidesToShow: 4,
  175. slidesToScroll: 1,
  176. autoplaySpeed: 7000,
  177. initialSlide: 0,
  178. infinite: true,
  179. });
  180. }
  181. function renderSec08(data) {
  182. let temp = data[4]['data'];
  183. let str = '';
  184. for(let i = 0; i < temp.length; i++){
  185. if(temp[i].video == 'true'){
  186. str+= `<div class="sec-08__slider-${i+1} sec-08__card col-12 mx-2" onclick="window.open('${temp[i]['link']}');">
  187. <div class="sec-08__imgfr mb-2" style="background-image: url('${temp[i]['imgUrl']}');" data-bg="${temp[i]['imgUrl']}"><img class="sec-08__card__play lazyload" data-src="images/Play-Button.webp"></div>
  188. <h5 class="mb-2 me-2">${temp[i]['title']}</h5>
  189. <p class="mb-2 me-2">${temp[i]['description']}</p>
  190. </div>`;
  191. } else {
  192. str+= `<div class="sec-08__slider-${i+1} sec-08__card col-12 mx-2" onclick="window.open('${temp[i]['link']}');">
  193. <div class="sec-08__imgfr mb-2" style="background-image: url('${temp[i]['imgUrl']}');" data-bg="${temp[i]['imgUrl']}"></div>
  194. <h5 class="mb-2 me-2">${temp[i]['title']}</h5>
  195. <p class="mb-2 me-2">${temp[i]['description']}</p>
  196. </div>`;
  197. }
  198. }
  199. $('.sec-08__slider').html(str);
  200. $(".sec-08__slider").slick({
  201. arrows: true,
  202. slidesToShow: 1,
  203. infinite: false,
  204. dots: false,
  205. slidesToShow: 3,
  206. centerPadding: '12px',
  207. prevArrow: '<button type="button" class="slick-prev"><i class="fas fa-chevron-left" style="font-size: 35px;color: black;"></i></button>',
  208. nextArrow: '<button type="button" class="slick-next"><i class="fas fa-chevron-right" style="font-size: 35px;color: black;"></i></button>'
  209. });
  210. const cardText = document.querySelectorAll('.sec-08__card p');
  211. cardText.forEach((item, i) => {
  212. let len = item.textContent.length;
  213. if(len > 20) {
  214. let str = item.textContent.substring(0, 20) + '...';
  215. item.textContent = str;
  216. }
  217. })
  218. }
  219. function renderSec09(data) {
  220. let temp = data[6]['data'];
  221. let str = '';
  222. for(let i = 0; i < temp.length; i++){
  223. if(temp[i].video !== 'false') {
  224. str+= `<div class="sec-09__slider-1 sec-09__card col-12 mx-2" onclick="window.open('${temp[i]['link']}');">
  225. <div class="sec-09__imgfr mb-2" style="background-image: url('${temp[i]['imgUrl']}');" data-bg="${temp[i]['imgUrl']}"><img class="sec-09__card__play lazyload" data-src="images/Play-Button.webp"></div>
  226. <p class="sec-09__cardtxt">${temp[i]['title']}</p>
  227. </div>`
  228. } else {
  229. str+= `<div class="sec-09__slider-1 sec-09__card col-12 mx-2" onclick="window.open('${temp[i]['link']}');">
  230. <div class="sec-09__imgfr mb-2" style="background-image: url('${temp[i]['imgUrl']}');" data-bg="${temp[i]['imgUrl']}"></div>
  231. <p class="sec-09__cardtxt">${temp[i]['title']}</p>
  232. </div>`
  233. }
  234. }
  235. $('.sec-09__slider').html(str);
  236. $(".sec-09__slider").slick({
  237. autoplay: true,
  238. autoplaySpeed: 7000,
  239. arrows: true,
  240. slidesToShow: 4,
  241. infinite: true,
  242. dots: false,
  243. slidesToScroll: 1,
  244. prevArrow: '<button type="button" class="slick-prev"><i class="fas fa-chevron-left" style="font-size: 35px;color: black;"></i></button>',
  245. nextArrow: '<button type="button" class="slick-next"><i class="fas fa-chevron-right" style="font-size: 35px;color: black;"></i></button>'
  246. });
  247. }
  248. function renderSec10(data) {
  249. renderRecStr("sec-10", data[7]['data'].slice(0, 6));
  250. renderRecStr("sec-11", data[8]['data'].slice(0, 6));
  251. }
  252. function renderRecStr(sec, data) {
  253. let str = '';
  254. for(let i = 0; i < data.length; i++){
  255. //console.log(data[i]['description'].length);
  256. if(data[i]['description'].length > 0) {
  257. data[i]['description'].split(',');
  258. data[i]['description'] = data[i]['description'].split(',').slice(1).join("");
  259. }
  260. if(data[i].video !== 'false') {
  261. str+= `<div class="${sec}__card col-4 mb-3" onclick="window.open('${data[i]['link']}');">
  262. <div class="${sec}__card-img mb-2" style="background-image: url('${data[i]['imgUrl']}');" data-bg="${data[i]['imgUrl']}"><img class="${sec}__card__play lazyload" data-src="images/Play-Button.webp"></div>
  263. <h5 class="me-2">${data[i]['title']}</h5>
  264. <p class="${sec}__cardtxt me-2">${data[i]['description']}</p>
  265. </div>`
  266. } else {
  267. str+= `<div class="${sec}__card col-4 mb-3" onclick="window.open('${data[i]['link']}');">
  268. <div class="${sec}__card-img mb-2" style="background-image: url('${data[i]['imgUrl']}');" data-bg="${data[i]['imgUrl']}"></div>
  269. <h5 class="me-2">${data[i]['title']}</h5>
  270. <p class="${sec}__cardtxt me-2">${data[i]['description']}</p>
  271. </div>`
  272. }
  273. }
  274. $(`.${sec} .row`).html(str);
  275. const cardText = document.querySelectorAll(`.${sec}__card p`);
  276. cardText.forEach((item, i) => {
  277. let len = item.textContent.length;
  278. if(len > 20) {
  279. let str = item.textContent.substring(0, 20) + '...';
  280. item.textContent = str;
  281. }
  282. })
  283. }
  284. function renderVideo(data) {
  285. let temp = data[9];
  286. console.log(data[9]);
  287. $('.sec-06__videotxt').text(temp['title']);
  288. console.log('test');
  289. $('.sec-06__video__imgfr').css('background-image', `url(https://img.youtube.com/vi/${temp['yt']}/hqdefault.jpg)`);
  290. $('#videoModal').on('shown.bs.modal', function () {
  291. $('#videoModal iframe').attr('src', `https://www.youtube.com/embed/${temp['yt']}?controls=0&autoplay=1&amp;enablejsapi=1&amp;origin=https%3A%2F%2Fm.hhh.com.tw&amp;widgetid=1`);
  292. });
  293. $('#videoModal').on('hidden.bs.modal', function () {
  294. $('#videoModal iframe').removeAttr('src');
  295. });
  296. }
  297. function renderTrending(result){
  298. let temp = result[10]['data'];
  299. let str = '';
  300. for(let i = 0; i < temp.length; i++){
  301. str += `<a class="dropbox__hots__link" href="https://hhh.com.tw/search/lists/case/${temp[i]}-keyword/">${temp[i]}</a>`
  302. }
  303. $('.dropbox__hots').html(`<strong class="dropbox__hots__title">熱搜關鍵字:</strong>${str}`);
  304. }
  305. function tab2 () {
  306. if(('.dropbox__tabdiv').length){
  307. // Show the first tab by default
  308. $('.dropbox-tab-content>div').hide();
  309. $('.dropbox-tab-content>div:first').show();
  310. $('.dropbox__tabdiv .nav-pills li:first').addClass('active');
  311. $('.dropbox__tabdiv .nav-pills li:first button').addClass('active');
  312. // Change tab class and display content
  313. $('.dropbox__tabdiv .nav-pills button').on('click', function(event){
  314. event.preventDefault();
  315. $('.dropbox__tabdiv .nav-pills li').removeClass('active');
  316. $('.dropbox__tabdiv .nav-pills li button').removeClass('active');
  317. $(this).addClass('active');
  318. $(this).parent().addClass('active');
  319. $('.dropbox-tab-content>div').hide();
  320. var target = $(this).attr('id');
  321. $(`#pills-tab-2 #${target}`).show();
  322. });
  323. }
  324. }
  325. tab2();
  326. let sticky = 250;
  327. window.addEventListener('scroll', fixedOnScroll);
  328. const navbar = document.querySelector('.navbar-main');
  329. function fixedOnScroll() {
  330. if(window.pageYOffset >= sticky){
  331. navbar.classList.add('sticky');
  332. } else {
  333. navbar.classList.remove('sticky');
  334. }
  335. }
  336. $(window).scroll(function() {
  337. if ( $(this).scrollTop() > 800 ){
  338. $('.fixed-btn').fadeIn(222);
  339. } else {
  340. $('.fixed-btn').stop().fadeOut(222);
  341. }
  342. }).scroll();
  343. $('.btn-gotop').click(function () {
  344. $('html, body').animate({
  345. scrollTop: 0
  346. }, 500)
  347. });
  348. $('.navbar-search img').click(function(){
  349. $('.navbar-search .dropbox').toggleClass('open');
  350. if($('.navbar-search .dropbox').hasClass('open')) {
  351. $('.navbar-nav .nav-item').hover(function() {
  352. $('.navbar-nav .nav-item:hover>.dropbox').css("visibility", "hidden");
  353. })
  354. } else {
  355. $('.navbar-nav .nav-item').hover(function() {
  356. $('.navbar-nav .nav-item:hover>.dropbox').css("visibility", "visible");
  357. })
  358. }
  359. });
  360. $('.sec-00__close').click(function(){
  361. $(this).css('display', 'none');
  362. $('.sec-00').addClass('bannerClose');
  363. //$('.sec-02').css('padding-top', '53px');
  364. sticky = 0;
  365. });
  366. // search
  367. const imageSearch = document.querySelector('.image-search');
  368. const imagesSelect = document.querySelectorAll('#pills-img-tab select');
  369. imageSearch.addEventListener("click", function() {
  370. searchQueryStr(imagesSelect, 'photos');
  371. })
  372. const newsSearch = document.querySelector('.news-search');
  373. const newsSelect = document.querySelectorAll('#pills-news-tab select');
  374. newsSearch.addEventListener("click", function() {
  375. searchQueryStr(newsSelect, 'builder');
  376. });
  377. const caseSearch= document.querySelector('.case-search');
  378. const caseSelect = document.querySelectorAll('#pills-case-tab select');
  379. caseSearch.addEventListener("click", function() {
  380. let query = ''
  381. let str = 'https://hhh.com.tw/cases/lists/1-page/new-sort/';
  382. if($('#case-shui').val() == '風水') {
  383. caseSelect.forEach((item, i) => {
  384. if(i < 2) {
  385. if(item.value !== ''){
  386. query += `/${item.value}`;
  387. }
  388. }
  389. });
  390. str = `https://hhh.com.tw/cases/lists${query}/風水-keyword/1-page/`;
  391. window.open(str);
  392. return;
  393. }
  394. caseSelect.forEach((item, i) => {
  395. if(item.value !== ''){
  396. query += `/${item.value}`;
  397. }
  398. });
  399. str = `https://hhh.com.tw/cases/lists${query}/1-page/`;
  400. window.open(str);
  401. })
  402. const designerSearch = document.querySelector('.designer-search');
  403. const designerSelect = document.querySelectorAll('#pills-designer-tab select');
  404. designerSearch.addEventListener("click", function() {
  405. searchQueryStr(designerSelect, 'designers');
  406. })
  407. function searchQueryStr(block, link){
  408. let query = ''
  409. let str = `https://hhh.com.tw/${link}/lists/1-page/`;
  410. block.forEach((item, i) => {
  411. if(item.value !== ''){
  412. query += `/${item.value}`;
  413. }
  414. });
  415. str = `https://hhh.com.tw/${link}/lists${query}/1-page/`;
  416. window.location.href = str;
  417. }
  418. const searchBtn = document.querySelector('.dropbox__searchBar__submit');
  419. const searchBar = document.querySelector('.dropbox__searchBar__input');
  420. searchBtn.addEventListener('click', search);
  421. searchBar.addEventListener('keyup', pressSearch);
  422. function search() {
  423. if(searchBar.value == '') {
  424. window.location.href = 'https://m.hhh.com.tw/search/lists/case/';
  425. } else {
  426. window.location.href = `https://m.hhh.com.tw/search/lists/case/${searchBar.value}-keyword/`;
  427. console.log(`https://m.hhh.com.tw/search/lists/case/${searchBar.value}-keyword/`)
  428. }
  429. }
  430. function pressSearch(e) {
  431. if (e.keyCode === 13) {
  432. e.preventDefault();
  433. search();
  434. }
  435. }
  436. function todayTV() {
  437. var utc = new Date().toJSON().slice(0,10).replace(/-/g,'-');
  438. window.open(`https://hhh.com.tw/program/?tv=gstv&date=${utc}&type=tv`);
  439. }
  440. document.addEventListener('lazybeforeunveil', function(e){
  441. var bg = e.target.getAttribute('data-bg');
  442. if(bg){
  443. e.target.style.backgroundImage = 'url(' + bg + ')';
  444. }
  445. });
  446. // city result
  447. let cityResult;
  448. $.ajax({
  449. method: "GET",
  450. url: "../json/taiwan_districts.json",
  451. dataType: "json",
  452. }).done(function (msg) {
  453. cityResult = [...msg];
  454. let str = '';
  455. for(let i = 0; i < cityResult.length; i++){
  456. str += `<option value="${cityResult[i]['zip']}-city">${cityResult[i]['name']}</option>`;
  457. }
  458. $('#designer-city').html(`<option value="" selected="selected" disabled>所在縣市</option>${str}`);
  459. $('#designer-city').on('change', function() {
  460. let selected = $(this).val().split('-')[0];
  461. let countyStr = '';
  462. for(let i = 0; i < cityResult.length; i++){
  463. if(cityResult[i]['zip'] == selected) {
  464. for(let j = 0; j < cityResult[i]['districts'].length; j++){
  465. countyStr += `<option value="${cityResult[i]['districts'][j]['zip']}-county">${cityResult[i]['districts'][j]['name']}</option>`;
  466. }
  467. }
  468. }
  469. $('#designer-country').html(`<option value="" selected="selected" disabled>所在地區</option>${countyStr}`);
  470. });
  471. });
  472. //jQuery time
  473. var current_fs, next_fs, previous_fs; //fieldsets
  474. var left, opacity, scale; //fieldset properties which we will animate
  475. var animating; //flag to prevent quick multi-click glitches
  476. $(".next").click(function(){
  477. if(animating) return false;
  478. animating = true;
  479. current_fs = $(this).parent().parent();
  480. next_fs = $(this).parent().parent().next();
  481. //activate next step on progressbar using the index of next_fs
  482. $(".form-progressbar li").eq($("fieldset").index(next_fs)).addClass("active");
  483. //show the next fieldset
  484. next_fs.animate({opacity: 1}, {
  485. step: function(now, mx) {
  486. //as the opacity of current_fs reduces to 0 - stored in "now"
  487. //1. scale current_fs down to 80%
  488. scale = 0 + (1 + now) * .5 ;
  489. //2. bring next_fs from the right(50%)
  490. left = (now * 50)+"%";
  491. //3. increase opacity of next_fs to 1 as it moves in
  492. opacity = 0 + now;
  493. next_fs.css({
  494. 'transform': 'scale('+scale+')',
  495. });
  496. next_fs.css({'opacity': opacity});
  497. },
  498. duration: 400,
  499. complete: function(){
  500. next_fs.show();
  501. animating = false;
  502. },
  503. //this comes from the custom easing plugin
  504. easing: 'easeInOutBack'
  505. });
  506. //hide the current fieldset with style
  507. current_fs.animate({opacity: 0}, {
  508. step: function(now, mx) {
  509. //as the opacity of current_fs reduces to 0 - stored in "now"
  510. //1. scale current_fs down to 80%
  511. scale = 1 - (1 - now) * 0.2;
  512. //2. bring next_fs from the right(50%)
  513. left = (now * 50)+"%";
  514. //3. increase opacity of next_fs to 1 as it moves in
  515. opacity = 1 - now;
  516. current_fs.css({
  517. 'transform': 'scale('+scale+')',
  518. });
  519. next_fs.css({'opacity': opacity});
  520. },
  521. duration: 400,
  522. complete: function(){
  523. current_fs.hide();
  524. animating = false;
  525. },
  526. //this comes from the custom easing plugin
  527. easing: 'easeInOutBack'
  528. });
  529. });
  530. /* const sec = document.querySelectorAll('.sec');
  531. const title = document.querySelectorAll('.title');
  532. const cover = document.querySelectorAll('.cover');
  533. const test_content = document.querySelectorAll('.test_content');
  534. function checkSlide() {
  535. console.log('pass');
  536. sec.forEach((block, i) => {
  537. // half way through the image
  538. //const test = document.querySelector('.test');
  539. const slideInAt = window.scrollY + window.innerHeight;
  540. console.log(slideInAt);
  541. //console.log(test.offsetTop);
  542. // bottom of the image
  543. const isHalfShown = slideInAt > block.offsetTop;
  544. if (isHalfShown) {
  545. console.log('active');
  546. title[i].style.bottom = '0em';
  547. cover[i].classList.add('slidein');
  548. test_content[i].classList.add('fadein');
  549. }
  550. })
  551. };
  552. window.addEventListener('scroll', checkSlide); */