jparallax icon indicating copy to clipboard operation
jparallax copied to clipboard

active/inactive events

Open baden03 opened this issue 12 years ago • 2 comments

is there currently a way of knowing if the parallax is currently in motion or not? I would like to change an element based on if any layers are currently in motion like so:

jQuery(function() { jQuery('#parallax') .inactive(function() { var src = 'car_stop.png'; jQuery('#car').attr("src", src); }) .active(function() { var src = 'car_go.png'; jQuery('#car').attr("src", src); }); });

any help is greatly appreciated!

baden03 avatar Apr 07 '12 14:04 baden03

That's a good question. The short answer is no - at least no way that is explicitly exposed.

I can have a look making this info available. I have to say, I don't like your suggested API, though. That would involve adding two new methods to the jQuery object, .active() and .inactive(), which have no meaning other than when called on a parallax layer. I would be more inclined to make some events available to bind to, something like:

jQuery('.parallax_layer') .on('parallaxstart', function(e) { // Layer has started moving }) .on('parallaxend', function(e) { // Layer has stopped moving });

stephband avatar Apr 08 '12 22:04 stephband

The .on method with a parallaxstart and parallaxend event trigger is exactly what I am looking for. If this method could be available for the individual layers it would be even more powerful. This way we could access the parallax status of both the parallax container in general AND/OR a unique element.

Thanks for looking into this! -Baden

baden03 avatar Apr 10 '12 08:04 baden03