-@interface HMExternalBrowserWindowController () <HMBookmarkListViewControllerDelegate>
+@interface HMExternalBrowserWindowController () <HMBookmarkListViewControllerDelegate, NSAnimationDelegate>
@property (nonatomic, weak) IBOutlet NSSegmentedControl *goSegment;
@property (nonatomic, weak) IBOutlet NSView *bookmarkListView;
@property (readwrite) NSRect contentVisibleRect;
@property (weak) HMBookmarkItem *waitingBookmarkItem;
+
+
+@property BOOL bookarkShowing;
@end
@implementation HMExternalBrowserWindowController
self.canResize = YES;
self.canScroll = YES;
self.canMovePage = YES;
+ self.bookarkShowing = NO;
}
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context
}
- (BOOL)showsBookmarkList
{
- return self.webView.frame.origin.x != 0;
+ return self.webView.frame.origin.x > 0;
}
- (IBAction)showBookmark:(id)sender
{
+ if(self.bookarkShowing) return;
+ self.bookarkShowing = YES;
+
if(!self.bookmarkListViwController) {
self.bookmarkListViwController = [HMBookmarkListViewController new];
self.bookmarkListView = self.bookmarkListViwController.view;
relativeTo:self.webView];
}
- CGFloat delta = 200;
- if([self showsBookmarkList]) {
- delta = -200;
- }
-
NSRect webViewFrame = self.webView.frame;
-
NSRect frame = self.bookmarkListView.frame;
frame.size.height = webViewFrame.size.height;
self.bookmarkListView.frame = frame;
- frame.origin.x += delta;
-
NSRect newFrame = webViewFrame;
- newFrame.origin.x += delta;
- newFrame.size.width -= delta;
+
+ if([self showsBookmarkList]) {
+ frame.origin.x = -200;
+ newFrame.origin.x = 0;
+ newFrame.size.width = self.window.frame.size.width;
+ } else {
+ frame.origin.x = 0;
+ newFrame.origin.x = 200;
+ newFrame.size.width = self.window.frame.size.width - 200;
+ }
NSDictionary *webViewAnime = @{
NSViewAnimationEndFrameKey : [NSValue valueWithRect:frame],
};
NSAnimation *anime = [[NSViewAnimation alloc] initWithViewAnimations:@[webViewAnime, bookMarkAnime]];
+ anime.delegate = self;
[anime startAnimation];
}
+- (void)animationDidEnd:(NSAnimation *)animation
+{
+ self.bookarkShowing = NO;
+}
- (BOOL)validateMenuItem:(NSMenuItem *)menuItem
{