project/src/index.js
2025-03-22 13:14:28 +03:00

35 lines
981 B
JavaScript

const name = 'File'
import { name as name2 } from './index2.js'
console.log('From index.js log name', name2)
const btnLeft = document.querySelector('.top-nft .btn-left')
const btnRight = document.querySelector('.top-nft .btn-right')
const container = document.querySelector('.nft-card-container')
let containerOffset = 0;
const moveContainer = (offset) => {
const containerWidth = container.scrollWidth
const newOffset = containerOffset + offset
const minOffset = (containerWidth - document.body.clientWidth) * -1
const maxOffset = 0;
containerOffset = Math.min(Math.max(minOffset, newOffset), maxOffset);
container.style.transform = `translateX(${containerOffset}px)`
btnLeft.disabled = containerOffset >= maxOffset ? true : null;
btnRight.disabled = containerOffset <= minOffset;
}
moveContainer(0)
btnLeft.addEventListener('click', () => {
moveContainer(285)
})
btnRight.addEventListener('click', () => {
moveContainer(-285)
})