No condition: handler not called
slorber opened this issue · comments
This works
this.steady = new Steady({
conditions: { "max-bottom" : 1000},
scrollElement: this.getDOMNode(),
throttle: 500,
handler: function(values,done) {
console.debug("scroll",values);
done();
}.bind(this)
});
This does not:
this.steady = new Steady({
conditions: {},
scrollElement: this.getDOMNode(),
throttle: 500,
handler: function(values,done) {
console.debug("scroll",values);
done();
}.bind(this)
});
I think the handler should be fired
Because there's no conditions to satisfy
Look at line #163
if ( !self._wantedTrackers.length || self.processing ) return;
if there's no trackers (a.k.a conditions) Steady.js won't do anything because otherwise it'll be triggered with every scroll event that isn't throttled by Steady.js, which is a bad practice that led me to create Steady.js in the first place.
Actually I would have expected the handler to be called with every scroll event, but the handler being throttled.
I'm sorry, but i see that as an anti-pattern.
why?
Because it's most likely that this handler will be executing different logic based on the location of the user in the page.
Which means breaking down the code to each scenario is a lot better than tangling it together.
Actually I don't use Steady on the body node but smaller divs so generally the behaviors is well encapsulated