Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No scroll-snap compatibility #64

Open
markusand opened this issue Feb 12, 2020 · 8 comments
Open

No scroll-snap compatibility #64

markusand opened this issue Feb 12, 2020 · 8 comments

Comments

@markusand
Copy link

It doesn't seem to work when using css scroll-snap-align

.carousel {
	position: relative;
	display: flex;
	height: 500px;
	width: 100%;
	scroll-snap-type: x mandatory;
	overflow-x: auto;

	/* Hide scrollbar */
	-ms-overflow-style: none;
	scrollbar-width: none;
	&::-webkit-scrollbar {
		display: none;
	}
}

.carousel .slide {
	flex: 0 0 100%;
	height: 100%;
	position: relative;
	box-sizing: border-box;
	scroll-snap-align: center;        <--- Here is the problem
	scroll-snap-stop: always;
}

Is there any way to make it work?

@donmbelembe
Copy link
Owner

donmbelembe commented Feb 12, 2020 via email

@markusand
Copy link
Author

It's using version 2.0.1

@Skwecode
Copy link

Did you find a solution? I'm facing the same problem.

@markusand
Copy link
Author

Didn't dig too deep into it. In my case I was using for a lightweight carousel, but it might not be the most appropriate usecase for this module. I moved to a specific carousel option.

@VasilVerdouw
Copy link

@donmbelembe Just wanted to let you know this is still a problem. I'm using the newest version but when using scroll snap dragscroll doesn't work.

@VasilVerdouw
Copy link

Also for anyone wondering, I am currently using the following code as an alternative:

const optionsRef = ref(null); // as Ref<HTMLDivElement | null>; // uncomment for typescript
const startY = ref(0);
const scrollTop = ref(0);
const isDown = ref(false);

optionsRef.value.addEventListener("mousedown", (e) => {
    if (!optionsRef.value) return;
    isDown.value = true;
    startY.value = e.pageY - optionsRef.value.offsetTop;
    scrollTop.value = optionsRef.value.scrollTop;
    document.body.style.cursor = "grabbing";
  });
  window.addEventListener("mouseup", () => {
    isDown.value = false;
    document.body.style.cursor = "default";
  });
  window.addEventListener("mousemove", (e) => {
    if (!optionsRef.value) return;
    if (!isDown.value) return;
    e.preventDefault();
    const y = e.pageY - optionsRef.value.offsetTop;
    const walk = y - startY.value;
    optionsRef.value.scrollTop = scrollTop.value - walk;
  });

@donmbelembe
Copy link
Owner

hello @VasilVerdouw Would you consider making a pull request?

@VasilVerdouw
Copy link

hello @VasilVerdouw Would you consider making a pull request?

Hey @donmbelembe, Sure, I'd love to, but the code I gave in my previous reply is a complete replacement of your library and honestly felt somewhat like a hack. I haven't yet looked at what your code does. Maybe I can combine some elements? Would like to hear your thoughts first.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants