Animation: Function Inside "Done" Still Executes
Hello community,
I am having an issue trying to stop a function from executing in the done property when using jquery animate method. Basically the first part of the animation is a color overlay when the user mouses over the element. Once that color overlay completes, then some text is suppose to appear
(which is a css text animation itself) . But if the user hovers over the element and quickly mouses out, then the text shouldn't appear but it still is. Here is my code.
- $(".grid1, .grid2, .grid3, .grid4, .grid5, .grid6").on("mouseover", function() {
- var pTag = $(this).find("p.grid-overlay");
- var currentGrid = $(this);
- var currentClass = $(this).attr("class");
- $(pTag).animate({
- backgroundColor: "#7c58bc",
- opacity: 0.5
- },
- {
- duration: 200,
- queue: false,
- specialEasing: {
- width:"linear",
- height:"easeInOutExpo"
- },
- done: function() {
- var currentGridTitle = gridText[currentClass].title;
- var topInc = 0;
- for (var key in currentGridTitle) {
- var titleElement = $("<p class=\'grid-block-text\'></p>");
- $(currentGrid).append(titleElement);
- $(titleElement).text(currentGridTitle[key]);
- var animationName = "animated fadeInDown";
- var animationEnd = "webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend";
- var pos = (120 + topInc) + "px";
- $(titleElement).css("top", pos);
- $(titleElement).addClass(animationName);
- $("#yourElement").one(animationEnd, function() {
- $(titleElement).removeClass(animationName);
- });
- topInc = 30;
- }
- }
- });
- });
I've tried using $(pTag).stop().animate({ }) as well as setting the queue property to false. But that doesn't seem to be working. I'm not sure what to do at this point. I appreciate any advice on this. Thanks.