+ __idle = NO;
+
+ [self setWindowVisibility:ITWindowVanishingState];
+ [self performVanishFromProgress:1.0 effectTime:_effectTime];
+}
+
+- (void)performVanishFromProgress:(float)progress effectTime:(float)time
+{
+ [_window setEffectProgress:progress];
+ _effectSpeed = (1.0 / (EFFECT_FPS * time));
+ if ( progress == 1.0 ) {
+ [_window setAlphaValue:1.0];
+ }
+
+ [_window orderFront:self];
+ _effectTimer = [NSTimer scheduledTimerWithTimeInterval:(1.0 / EFFECT_FPS)
+ target:self
+ selector:@selector(vanishStep)
+ userInfo:nil
+ repeats:YES];
+}
+
+- (void)vanishStep
+{
+ float interSlide = 1.0;
+ [_window setEffectProgress:([_window effectProgress] - _effectSpeed)];
+ [_window setEffectProgress:( ([_window effectProgress] > 0.0) ? [_window effectProgress] : 0.0)];
+ interSlide = (( sin(([_window effectProgress] * pi) - (pi / 2)) + 1 ) / 2);
+ [self setSlide:( [_window frame].size.width - (interSlide * [_window frame].size.width) )];
+ [_window setAlphaValue:interSlide];
+
+ if ( [_window effectProgress] <= 0.0 ) {
+ [self vanishFinish];
+ }
+}
+
+- (void)vanishFinish
+{
+ [_effectTimer invalidate];
+ _effectTimer = nil;
+ [_window orderOut:self];
+ [_window setAlphaValue:1.0];
+ [self setSlide:0.0];
+ [self setWindowVisibility:ITWindowHiddenState];
+
+ __idle = YES;
+
+ if ( __shouldReleaseWhenIdle ) {
+ [self release];
+ }
+}
+
+- (void)cancelVanish
+{
+ [self setWindowVisibility:ITWindowAppearingState];
+
+ [_effectTimer invalidate];
+ _effectTimer = nil;
+
+ [self performAppearFromProgress:[_window effectProgress] effectTime:(_effectTime / 4.0)];
+}
+
+- (void)setSlide:(float)distance
+{
+ CGAffineTransform transform;
+ NSPoint translation;
+ NSRect winFrame = [_window frame];
+
+ if ( [_window horizontalPosition] == ITWindowPositionLeft ) {
+ translation.x = ( -(winFrame.origin.x) + distance ) ;
+ } else if ( [_window horizontalPosition] == ITWindowPositionRight ) {
+ translation.x = ( -(winFrame.origin.x) - distance ) ;
+ } else {
+ translation.x = ( -(winFrame.origin.x) ) ;
+ }
+
+ translation.y = winFrame.origin.y + winFrame.size.height - [[NSScreen mainScreen] frame].size.height;
+
+ transform = CGAffineTransformMakeTranslation( translation.x, translation.y );
+
+ CGSSetWindowTransform([NSApp contextID],
+ (CGSWindowID)[_window windowNumber],
+ transform);