Hi All,
I could do with some help!
I'm using the draggable plugin to build a custom scrollbar for a horizontally scrolling element. It works great when dragging the scrollbar, but I also need to update the scrollbar if they scroll using a mouse or swipe with a finger.
I'm attempting to access a few variables stored within the draggable instance, but I'm always returned undefined.
Here's a simplified version of my code:
var scrollbar = Draggable
.create($scrollbar.grip, {
type: 'x',
bounds: $scrollbar.track,
cursor: 'ew-resize',
onDrag: scrollContent,
onThrowUpdate: scrollContent
});
This is where I'm getting lost. If I access scrollbar I can see some information stored, but not the three bits I need:
max x
min x
current x
(I can work all these values out myself, but as the work has already been done, and I just don't know how to access it, I'd rather not duplicate it and instead learn the right way.)
$content
.on('mousewheel', function(e){
$content[0].scrollLeft += e.deltaX;
console.log(scrollbar.maxX); // This is undefined
e.preventDefault();
});
Any ideas?
Thanks,
Will