Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

$.textillate('stop') doesn't work #98

Open
Danelund opened this issue Aug 8, 2016 · 7 comments
Open

$.textillate('stop') doesn't work #98

Danelund opened this issue Aug 8, 2016 · 7 comments

Comments

@Danelund
Copy link

Danelund commented Aug 8, 2016

Calling $.textillate('stop') doesn't work. Nothing happens. Can't find a working sample.

@jschr
Copy link
Owner

jschr commented Aug 8, 2016

The stop method was added by @kodeaffe in #47. I've never used it myself. I'm guessing since stop just clears the out animation timeout, calling it during the out transition will still cause the next in animation to fire, causing the out to fire again. I believe that the quick fix would be set something like base.isStopped = true in the stop method and prevent the in animation from firing if the flag is set.

Would gladly accept a PR for this or will have to wait until I get a moment to test out the fix.

@ohpyupi
Copy link

ohpyupi commented Aug 9, 2016

I got a same issue with @Danelund . But thanks @jschr , your suggestion worked!

@ohpyupi
Copy link

ohpyupi commented Aug 9, 2016

I have another issue with 'stop' method. I am wondering if any of you can help me finding solutions.
I want to run only a loop of an animation effect. Text coming in and going out only once.
So what I am trying is to using callback function after out-animation.

$('.className').textillate({ loop: true, out: { callback: function () { $(''.className).textillate('stop'); }, }, });

I put the fix, but it still doesn't work for it.

@jschr
Copy link
Owner

jschr commented Aug 9, 2016

@ohpyupi would you be able to post your fix in case in helps others?

If I understand correctly, the root problem is that loop: false doesn't trigger the out effect. You could try loop: false with an empty item at the end of the loop: http://jsfiddle.net/jschr/t5cqnep7/

@ohpyupi
Copy link

ohpyupi commented Aug 9, 2016

I was having an issue with stop method and tried to make a button to trigger stop button. To test whether it's actually working or not... I thought your fix cleared the problem, but I think it didn't.

As you mentioned, during the animation, the stop method doesn't see base.timeoutRun. But when when the animation stops (a short interval between in-animation and out-animation).

Original coding

base.stop  = function () {
  if (base.timeoutRun) {
    clearInterval(base.timeoutRun);
    base.timeoutRun = null;
  }
}

So if I catch the moment when the animation stops and click the button that triggers stop method, then the animation can be stopped.

what the button looks like

$('.btnClassName').on('click', function () {
  $('aniObejct').textillate('stop');
});

@lukalev
Copy link

lukalev commented Dec 14, 2016

You can stop the loop after out animation by editing jquery.textillate.js and using a counter.
Initialize a counter (st in my case) globally. Then on first line of run method add if(st > 1) return; to exit loop after first iteration. And then increment counter.

(function run(index) { if(st > 1) return; st++; ...

@Tritek
Copy link

Tritek commented Nov 2, 2017

@lukalev
After your change the stop function works fine, but start don't work
$('.tlt').textillate('start');
Can you help me?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants