Skip to content

Commit

Permalink
Accounted for horizontal scrolling for attachment viewport intersection
Browse files Browse the repository at this point in the history
  • Loading branch information
rajdeep committed Apr 17, 2024
1 parent 6af0d8a commit 76d1656
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -476,10 +476,15 @@ extension CommandsExampleViewController: EditorViewDelegate {
extension CommandsExampleViewController: TableViewDelegate {
var viewport: CGRect? {
var viewport = editor.scrollView.bounds
let offset: CGFloat = 100
viewport.origin.y += offset
viewport.size.height -= (offset * 2)
Utility.drawRect(rect: CGRect(origin: CGPoint(x: 0, y: offset), size: viewport.size), color: .red, in: editor)
let offsetY: CGFloat = 100
let offsetX: CGFloat = 40

viewport.origin.x += offsetX
viewport.origin.y += offsetY
viewport.size.width -= (offsetX * 2)
viewport.size.height -= (offsetY * 2)

Utility.drawRect(rect: CGRect(origin: CGPoint(x: offsetX, y: offsetY), size: viewport.size), color: .red, in: editor)
return viewport
}

Expand Down
6 changes: 4 additions & 2 deletions Proton/Sources/Swift/Table/TableView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -365,8 +365,10 @@ public class TableView: UIView {
let containerViewport = delegate?.viewport ?? container.bounds
let adjustedViewport = containerViewport.offsetBy(dx: tableView.bounds.origin.x, dy: tableView.bounds.origin.y)

let adjustedAttachmentContentViewFrame = CGRect(origin: rootOrigin, size: attachmentContentView.frame.size)
guard adjustedViewport.intersects(adjustedAttachmentContentViewFrame) else {
let origin = tableView.bounds.offsetBy(dx: rootOrigin.x, dy: rootOrigin.y).origin
let adjustedAttachmentViewport = CGRect(origin: origin, size: attachmentContentView.frame.size)

guard adjustedViewport.intersects(adjustedAttachmentViewport) else {
cellsInViewport = []
return
}
Expand Down

0 comments on commit 76d1656

Please sign in to comment.