Hello everyone.
I'm trying to get the adapt-contrib-graphic to behave little differently for a project I'm working. A large image needs to retain its actual width & height so it overflows the container and scrolls (rather than resizing to fit the container).
I've managed that bit, so I have scrollbars left & bottom of the container but really being able to grab and drag the image would be the smartest solution. Any ideas?
I poached (and tweaked) the following code from codepen and added it to the GraphicView.js, which summarily broke everything!!
const slider = this.model.getElementById ('.graphic__image-container');
let isDown = false;
let startX;
let scrollLeft;
slider.addEventListener('mousedown', (e) => {
isDown = true;
slider.classList.add('active');
startX = e.pageX - slider.offsetLeft;
scrollLeft = slider.scrollLeft;
});
slider.addEventListener('mouseleave', () => {
isDown = false;
slider.classList.remove('active');
});
slider.addEventListener('mouseup', () => {
isDown = false;
slider.classList.remove('active');
});
slider.addEventListener('mousemove', (e) => {
if(!isDown) return;
e.preventDefault();
const x = e.pageX - slider.offsetLeft;
const walk = (x - startX) * 3; //scroll-fast
slider.scrollLeft = scrollLeft - walk;
console.log(walk);
});