Possible 'bug' with story.isEmpty and animation

1 view
Skip to first unread message

Saq Imtiaz

unread,
Jul 21, 2006, 4:10:17 AM7/21/06
to TiddlyWikiDev
Hey guys,

I ran into a bit of a problem which may or may not be a bug.
If you have some code that closes a tiddler and then checks if the story is empty - with animations turned on - the story.isEmpty returns false. Possibly since the tiddler hasnt finished closing. With animations turned off everything works as it should.

Sample code:

story.closeTiddler("Sample");
if (story.isEmpty())
     doSomething();

Any ideas on how to get around this? I need to close a tiddler and then check to see if the story is empty, and if its empty then perform another action.
Any input would be highly appreciated.

Cheers,

Saq

Eric Shulman

unread,
Jul 21, 2006, 4:46:33 AM7/21/06
to TiddlyWikiDev
> I ran into a bit of a problem which may or may not be a bug.
> If you have some code that closes a tiddler and then checks if the story is
> empty - with animations turned on - the story.isEmpty returns false.
> Possibly since the tiddler hasnt finished closing. With animations turned
> off everything works as it should.

Animations use timeout interrupts to draw/redraw the DIVs several
times. Thus, animations are performed asynchronously. Fortunately,
there is a core Slider function that is called when the animation has
ended. You can hijack this function to perform "post-animation"
handling. I've done exactly this in NestedSliderPlugin (to fixup the
overflow param after animation, so that nested sliders don't get
incorrecty clipped).

Here's the code from http://www.TiddlyTools.com/#NestedSlidersPlugin:
-------------------
Slider.prototype.coreStop = Slider.prototype.stop;
Slider.prototype.stop = function() { this.coreStop();
this.element.style.overflow = "visible"; }

HTH,
-e
Eric Shulman
TiddlyTools / ELS Design Studios

Saq Imtiaz

unread,
Jul 21, 2006, 6:30:21 AM7/21/06
to Tiddly...@googlegroups.com
On 7/21/06, Eric Shulman <elsd...@gmail.com> wrote:

> I ran into a bit of a problem which may or may not be a bug.
> If you have some code that closes a tiddler and then checks if the story is
> empty - with animations turned on - the story.isEmpty returns false.
> Possibly since the tiddler hasnt finished closing. With animations turned
> off everything works as it should.

Animations use timeout interrupts to draw/redraw the DIVs several
times.  Thus, animations are performed asynchronously.  Fortunately,
there is a core Slider function that is called when the animation has
ended.  You can hijack this function to perform "post-animation"
handling.  I've done exactly this in NestedSliderPlugin (to fixup the
overflow param after animation, so that nested sliders don't get
incorrecty clipped).


That worked perfectly, thanks Eric!
Cheers,
Saq
Reply all
Reply to author
Forward
0 new messages