I've written my first npm library called flix slider (https://www.npmjs.com/package/flix-slider) which is kinda based on the Netflix style slider. The designer wanted the slider to behave in a certain way and I couldn't find anything that did what I needed so built one from scratch.
Everything works well except when it comes to dragging and touch drag. I need to somehow disable/ignore if the user drags up or down. Currently, if they drag up or down it triggers a left or right drag. I've been looking at this all day I can't for the life of me figure out how to stop it lol
Im able to get work out if the user is scrolling up or down but im not sure how to use that information to stop the left and right functions from triggering.
$(document).on('mousemove', function (e) {
dragMove(e)
})
var dragMove = function (e) {
if (oldPageY > e.pageY) {
limit = true
}
if (dragging) {
// console.log(oldPageY, e.pageY)
if (oldPageX < e.pageX) {
xDirection = 'next drag'
if (limit) {
$(fsTrack).addClass('fs-being-dragged') // disable items from being clicked
nextItem(dragItemsToMove)
limit = false
}
oldPageX = e.pageX - pageXOffset
} else {
xDirection = 'prev drag'
if (limit) {
$(fsTrack).addClass('fs-being-dragged') // disable items from being clicked
prevItem(dragItemsToMove)
limit = false
}
oldPageX = e.pageX + pageXOffset
}
return false
}
}
Ultimately what im trying to achieve is only allowing the user to mousemove left or right. i.e. have the user mousedowned -> are they moving left or right -> call functions