javascript - Inverting how an object is coupled to other object's events -
i have object, volumeslider, affected 2 other controls' events:
var volumeslider = $('#volumeslider'); $('#mutebutton').on('mouseenter', function() { volumeslider.fadein('fast'); } $('#controls').on('mouseleave', function() { volumeslider.fadeout('fast'); }
i invert such volumeslider 'listens' events on mutebutton , controls instead of being told respond them. possible? like:
//pseudo-code: volumeslider.on('#mutebutton.mouseenter'){ this.fadein('fast'); }.on('#controls.mouseleave'){ this.fadeout('fast'); }
is jquery's http://api.jquery.com/bind/ useful here?
here 1 suggestion:
volumeslider.on('dosomething', function(e) { $(this).fadein('fast'); }); $('#mutebutton').on('mouseenter', function(e) { volumeslider.trigger('dosomething'); }
Comments
Post a Comment