diff --git a/resources/js/basic.js b/resources/js/basic.js new file mode 100644 index 0000000..72b8b5b --- /dev/null +++ b/resources/js/basic.js @@ -0,0 +1,178 @@ +import Swiper from 'swiper/swiper-bundle'; +import { ScratchCard, SCRATCH_TYPE } from 'scratchcard-js' +require('./bootstrap'); +require('@fancyapps/fancybox'); + +$(document).ready(function () { + + + // BOUTON HAUT DE PAGE + $(window).on('scroll', function () { + if ($(window).scrollTop()) { + $('.pageup').addClass('see') + } + else { + $('.pageup').removeClass('see') + } + }) + + $('.toggle-menu').click(function () { + $(this).toggleClass('active'); + $('nav').toggleClass('active'); + $('body').toggleClass('mobile-nav-active'); + }) + $('ul li a').click(function () { + const body = document.querySelector('body'); + if (body.classList.contains('mobile-nav-active')) { + $('.toggle-menu').toggleClass('active'); + $('nav').toggleClass('active'); + $('body').toggleClass('mobile-nav-active'); + } + }) + // $('.close-menu').click(function(){ + // $('nav').removeClass('active') + // $('li').siblings().removeClass('active') + // }) + + var mySwiper = new Swiper('.swiper-container', { + // Optional parameters + direction: 'horizontal', + loop: true, + autoplay: { + delay: 3000, + }, + pagination: { + el: '.gift-bloc .swiper-pagination', + type: 'bullets', + clickable: true, + }, + }) + + // var scratch = new Scratch({ + // canvasId: 'js-scratch-canvas', + // imageBackground: '../images/logo-footer.png', + // pictureOver: '../images/grattage.png', + // cursor: { + // png: 'piece.png', + // cur: 'piece.cur', + // x: '20', + // y: '17' + // }, + // radius: 20, + // nPoints: 100, + // percent: 50, + // callback: function () { + // alert('I am Callback.'); + // }, + // pointSize: { x: 3, y: 3} + // }); + + const scContainer = document.getElementById('js--sc--container') + if (scContainer != null) { + const scInfos = document.querySelector('.sc__infos'); + const sc = new ScratchCard('#js--sc--container', { + scratchType: SCRATCH_TYPE.LINE, + containerWidth: scContainer.offsetWidth, + containerHeight: scContainer.offsetHeight, + imageForwardSrc: '/front/assets/images/grattage.png', + imageBackgroundSrc: '', + htmlBackground: '', + clearZoneRadius: 50, + nPoints: 30, + pointSize: 8, + callback: function () { + // alert('Now the window will reload !') + // window.location.reload() + $(".congratulate .main--bloc").css('display', 'block'); + $(".sc__wrapper").hide(); + } + }) + + // Init + sc.init().then(() => { + // sc.canvas.addEventListener('scratch.move', () => { + // let percent = sc.getPercent().toFixed(0); + // scInfos.innerHTML = percent + '%'; + // console.log(percent) + // }) + }).catch((error) => { + // image not loaded + alert(error.message); + }); + } + + // const scContainer = document.getElementById('js--sc--container') + // const sc = new ScratchCard('#js--sc--container', { + // scratchType: SCRATCH_TYPE.SPRAY, + // containerWidth: scContainer.offsetWidth, + // containerHeight: scContainer.offsetHeight, + // imageForwardSrc: './assets/images/grattage.png', + // imageBackgroundSrc: './assets/images/logo-footer.png', + // htmlBackground: '