Skip to content
This repository has been archived by the owner on May 10, 2024. It is now read-only.

Commit

Permalink
Revert "Fixed #631: Scrolling improvements. (#670)"
Browse files Browse the repository at this point in the history
  • Loading branch information
kylehickinson authored and Joel Reis committed Jan 23, 2019
1 parent d28ab4d commit 27f8fdb
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 18 deletions.
10 changes: 5 additions & 5 deletions Client/Frontend/Browser/BrowserViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -667,8 +667,8 @@ class BrowserViewController: UIViewController {
webViewContainerTopOffset = make.top.equalTo(readerModeBar?.snp.bottom ?? self.header.snp.bottom).constraint

let findInPageHeight = (findInPageBar == nil) ? 0 : UIConstants.ToolbarHeight
if let footerView = self.footer {
make.bottom.equalTo(footerView.snp.top).offset(-findInPageHeight)
if let toolbar = self.toolbar {
make.bottom.equalTo(toolbar.snp.top).offset(-findInPageHeight)
} else {
make.bottom.equalTo(self.view).offset(-findInPageHeight)
}
Expand All @@ -694,7 +694,7 @@ class BrowserViewController: UIViewController {

make.left.right.equalTo(self.view)
if self.homePanelIsInline {
make.bottom.equalTo(self.footer?.snp.top ?? self.view.snp.bottom)
make.bottom.equalTo(self.toolbar?.snp.top ?? self.view.snp.bottom)
} else {
make.bottom.equalTo(self.view.snp.bottom)
}
Expand All @@ -705,8 +705,8 @@ class BrowserViewController: UIViewController {
make.width.equalTo(self.view.snp.width)
if let keyboardHeight = keyboardState?.intersectionHeightForView(self.view), keyboardHeight > 0 {
make.bottom.equalTo(self.view).offset(-keyboardHeight)
} else if let footer = self.footer {
make.bottom.equalTo(footer.snp.top)
} else if let toolbar = self.toolbar {
make.bottom.equalTo(toolbar.snp.top)
} else {
make.bottom.equalTo(self.view)
}
Expand Down
2 changes: 0 additions & 2 deletions Client/Frontend/Browser/Tab.swift
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,6 @@ class Tab: NSObject {
configuration!.preferences = WKPreferences()
configuration!.preferences.javaScriptCanOpenWindowsAutomatically = false
configuration!.allowsInlineMediaPlayback = true
// Enables Zoom in website by ignoring their javascript based viewport Scale limits.
configuration!.ignoresViewportScaleLimits = true
let webView = TabWebView(frame: .zero, configuration: configuration!)
webView.delegate = self
configuration = nil
Expand Down
29 changes: 18 additions & 11 deletions Client/Frontend/Browser/TabScrollController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ class TabScrollingController: NSObject {
weak var tab: Tab? {
willSet {
self.scrollView?.delegate = nil
self.scrollView?.panGestureRecognizer.removeTarget(self, action: nil)
self.scrollView?.removeGestureRecognizer(panGesture)
}

didSet {
self.scrollView?.panGestureRecognizer.addTarget(self, action: #selector(handlePan))
self.scrollView?.addGestureRecognizer(panGesture)
scrollView?.delegate = self
}
}
Expand All @@ -52,7 +52,7 @@ class TabScrollingController: NSObject {

fileprivate var headerTopOffset: CGFloat = 0 {
didSet {
headerTopConstraint?.update(offset: headerTopOffset)
headerTopConstraint?.update(offset: headerTopOffset - tabsBarOffset)
header?.superview?.setNeedsLayout()
}
}
Expand All @@ -70,6 +70,13 @@ class TabScrollingController: NSObject {
}
}

fileprivate lazy var panGesture: UIPanGestureRecognizer = {
let panGesture = UIPanGestureRecognizer(target: self, action: #selector(handlePan))
panGesture.maximumNumberOfTouches = 1
panGesture.delegate = self
return panGesture
}()

fileprivate var scrollView: UIScrollView? { return tab?.webView?.scrollView }
fileprivate var contentOffset: CGPoint { return scrollView?.contentOffset ?? .zero }
fileprivate var contentSize: CGSize { return scrollView?.contentSize ?? .zero }
Expand Down Expand Up @@ -252,19 +259,19 @@ private extension TabScrollingController {
// produce a ~50px page jumping effect in response to tap navigations.
let isShownFromHidden = headerTopOffset == -topScrollHeight && headerOffset == 0

if isShownFromHidden {
scrollView.contentOffset = CGPoint(x: initialContentOffset.x, y: initialContentOffset.y + self.topScrollHeight)
}
self.headerTopOffset = headerOffset
self.footerBottomOffset = footerOffset
self.urlBar?.updateAlphaForSubviews(alpha)
self.tabsBar?.view.alpha = alpha
let animation: () -> Void = {
if isShownFromHidden {
scrollView.contentOffset = CGPoint(x: initialContentOffset.x, y: initialContentOffset.y + self.topScrollHeight)
}
self.headerTopOffset = headerOffset + self.tabsBarOffset
self.footerBottomOffset = footerOffset
self.urlBar?.updateAlphaForSubviews(alpha)
self.tabsBar?.view.alpha = alpha
self.header?.superview?.layoutIfNeeded()
}

if animated {
UIView.animate(withDuration: duration, delay: 0, options: [.beginFromCurrentState, .allowUserInteraction], animations: animation, completion: completion)
UIView.animate(withDuration: duration, delay: 0, options: .allowUserInteraction, animations: animation, completion: completion)
} else {
animation()
completion?(true)
Expand Down

0 comments on commit 27f8fdb

Please sign in to comment.