AFRAME.registerComponent('buttons-handler', {
    init() {
        this.fox = document.querySelector('#fox')
        this.afterExpiriensButtons = document.querySelector('#after-expiriens-buttons')
        this.repeatButton = document.querySelector('#repeat-button')
        this.shareButton = document.querySelector('#share-button')

        this.fox.addEventListener('animation-finished', () => {
            this.afterExpiriensButtons.classList.remove('hidden')
        })

        this.repeatButton.addEventListener('click', () => {
            this.afterExpiriensButtons.classList.add('hidden')
            document.querySelector('#fox-wrapper').setAttribute('tap-to-place', '')
        })

        this.shareButton.addEventListener('click', () => {
            navigator.share({
                url: 'https://fox.mordovia-russia.ru/',
            })
        })
    },
})