darsain / sly

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

New features: 'dragInitiated' argument and 'releaseTweese' option. #218

Closed jonlinper closed 9 years ago

jonlinper commented 9 years ago

dragInitiated

This adds a new callback argument to the 'change' event, that allows to know if the change has been caused by a dragging (mouse or touch) or not.

I've a Sly scroll as a background of another. So when moving it, background gets updated. Animation is disabled when movement is a drag.

sly.on('change', function(eventName, dragInitiated) {
  background.slideTo((sly.pos.dest / sly.pos.end) * background.pos.end, dragInitiated);
});

releaseTweese

On the other hand, releaseTweese option allows to use a releaseSwing without tweese. Tweese looks bad for my non-item Sly.

darsain commented 9 years ago

change event should be completely agnostic to dragging. Passing that argument there just doesn't make sense. Stuff like this should be inferred from Sly state properties.

One such property is an unfortunately undocumented dragging object, which has for you very useful properties init, and released.

So, inside the change event, check sly.dragging.init to get the same result.

jonlinper commented 9 years ago

Darsain,

Thanks for your message. What about the releaseTweese option?

darsain commented 9 years ago

That's what releaseSwing option does.

jonlinper commented 9 years ago

It's not the same effect.