darsain / sly

JavaScript library for one-directional scrolling with item based navigation support.
http://darsa.in/sly
2.87k stars 497 forks source link

scrollable content #242

Open valerka-xarkov opened 8 years ago

valerka-xarkov commented 8 years ago

Hi,

I have an issue. When I have scrollable content inside sly (I mean inside one of block in sly) - there is a problem when I trying to scroll it using mouse.

I propose next solution: in contructor initialize one more variable var isContentScroller = false;

in init section add one more event listener

$frame[0].addEventListener('scroll', function (event) {
    if (!$frame.is(event.target)) {
        isContentScrolled = true;
    }
}, true);

so, every scroll event will be catched. If it is not $frame - it mean user scrolling inner scroll.

and in drag handler instead of

slideTo(dragging.slidee ? round(dragging.initPos - dragging.delta) : handleToSlidee(dragging.initPos + dragging.delta));

write like this

if (!isContentScrolled) {
    slideTo(dragging.slidee ? round(dragging.initPos - dragging.delta) : handleToSlidee(dragging.initPos + dragging.delta));
} else {
    isContentScrolled = !dragging.released;
}

Thanks for great widget )

sergey-dev commented 8 years ago

Duplicate of https://github.com/darsain/sly/issues/243 ?

sergey-dev commented 8 years ago

@valerka-xarkov , please fix the code formatting, if you want people to understand you. Thanks!

valerka-xarkov commented 8 years ago

Not duplication. Formated