[jQuery] Re: bind eventhandler after animation finished

2009-01-24 Thread maggus.st...@googlemail.com

hi stephan,

ahh ok, thx for pointing to the callbacks...

soo if i can't solve the problem this way how to handle it?

thank you, markus

On 24 Jan., 14:32, Stephan Veigl  wrote:
> First of all, slideUp(speed, callback) and slideDown(speed, callback)
> have callback functions which are called once the animation is
> finished. (seehttp://docs.jquery.com/Effects/slideDown#speedcallback
> -> examples)
>
> But I'm not sure if this really solves your problem. If you bind the
> mouseleave event in the callback you might never get this event when
> the user moves the mouse out of your div before the animation has
> finished.
> So the main question is: what would you like to happen if the mouse is
> moved out while the image is sliding in?
>
> by(e)
> Stephan
>
> 2009/1/24 maggus.st...@googlemail.com :
>
>
>
> > hi everyone,
>
> > what i want to accomplish in general:
> > i have a text field which has a filename as the value.
> > when hovering the field, a div should slide in from the bottom of the
> > field and show a preview of this image.
> > currently i'm using the following jquery-code:
>
> >  function rexShowMediaPreview() {
> >    var value;
> >    if($(this).hasClass("rex-widget-media"))
> >      value = $("input[type=text]", this).val();
> >    else
> >      value = $("select", this).val();
>
> >    var div = $(".rex-media-preview", this);
> >    var url = '../index.php?rex_resize=246a__'+ value;
> >    if(value && value.length != 0 &&
> >      (
> >        value.substr(-3) == "png" ||
> >        value.substr(-3) == "gif" ||
> >        value.substr(-3) == "bmp" ||
> >        value.substr(-3) == "jpg" ||
> >        value.substr(-4) == "jpeg")
> >      )
> >    {
> >      div.html('');
> >      div.slideDown("slow");
> >    }
> >    else
> >    {
> >      div.slideUp("slow");
> >    }
> >  };
>
> >  $(".rex-widget-media.rex-widget-preview, .rex-widget-medialist.rex-
> > widget-preview")
> >    .bind("mouseenter", rexShowMediaPreview)
> >    .bind("mouseleave", function() {
> >            var div = $(".rex-media-preview", this);
> >            div.slideUp("slow");
> >  });
>
> > the markup looks like the following:
>
> >    
> >      
> >        
> >           > value="myimg.jpg" id="REX_MEDIA_2" readonly="readonly" />
> >        
> >        
> >      
> >    
>
> > this doesn't work well...
> > (when leaving the div while sliding in, the div immediatly slides
> > out...)
>
> > is someony able to give me a hint...? i suppose it would be much
> > better if the mouseleave eventhandler would be bound when the slide in
> > animation finished (while unbinding the mouseenter handler) and the
> > same while sliding out vice versa...
>
> > any ideas?


[jQuery] Re: bind eventhandler after animation finished

2009-01-24 Thread Stephan Veigl

First of all, slideUp(speed, callback) and slideDown(speed, callback)
have callback functions which are called once the animation is
finished. (see http://docs.jquery.com/Effects/slideDown#speedcallback
-> examples)

But I'm not sure if this really solves your problem. If you bind the
mouseleave event in the callback you might never get this event when
the user moves the mouse out of your div before the animation has
finished.
So the main question is: what would you like to happen if the mouse is
moved out while the image is sliding in?

by(e)
Stephan


2009/1/24 maggus.st...@googlemail.com :
>
> hi everyone,
>
> what i want to accomplish in general:
> i have a text field which has a filename as the value.
> when hovering the field, a div should slide in from the bottom of the
> field and show a preview of this image.
> currently i'm using the following jquery-code:
>
>  function rexShowMediaPreview() {
>var value;
>if($(this).hasClass("rex-widget-media"))
>  value = $("input[type=text]", this).val();
>else
>  value = $("select", this).val();
>
>var div = $(".rex-media-preview", this);
>var url = '../index.php?rex_resize=246a__'+ value;
>if(value && value.length != 0 &&
>  (
>value.substr(-3) == "png" ||
>value.substr(-3) == "gif" ||
>value.substr(-3) == "bmp" ||
>value.substr(-3) == "jpg" ||
>value.substr(-4) == "jpeg")
>  )
>{
>  div.html('');
>  div.slideDown("slow");
>}
>else
>{
>  div.slideUp("slow");
>}
>  };
>
>  $(".rex-widget-media.rex-widget-preview, .rex-widget-medialist.rex-
> widget-preview")
>.bind("mouseenter", rexShowMediaPreview)
>.bind("mouseleave", function() {
>var div = $(".rex-media-preview", this);
>div.slideUp("slow");
>  });
>
>
> the markup looks like the following:
>
>
>  
>
>   value="myimg.jpg" id="REX_MEDIA_2" readonly="readonly" />
>
>
>  
>
>
>
> this doesn't work well...
> (when leaving the div while sliding in, the div immediatly slides
> out...)
>
> is someony able to give me a hint...? i suppose it would be much
> better if the mouseleave eventhandler would be bound when the slide in
> animation finished (while unbinding the mouseenter handler) and the
> same while sliding out vice versa...
>
> any ideas?