Module: Turbo::VisitableView::Screenshots
- Included in:
- Turbo::VisitableView
- Defined in:
- lib/turbo/visitable_view/screenshots.rb
Instance Attribute Summary collapse
-
#screenshotView ⇒ Object
readonly
Returns the value of attribute screenshotView.
Instance Method Summary collapse
- #clearScreenshot ⇒ Object
- #hideScreenshot ⇒ Object
- #isShowingScreenshot ⇒ Object
- #screenshotContainerView ⇒ Object
- #showScreenshot ⇒ Object
- #updateScreenshot ⇒ Object
Instance Attribute Details
#screenshotView ⇒ Object (readonly)
Returns the value of attribute screenshotView.
13 14 15 |
# File 'lib/turbo/visitable_view/screenshots.rb', line 13 def screenshotView @screenshotView end |
Instance Method Details
#clearScreenshot ⇒ Object
51 52 53 |
# File 'lib/turbo/visitable_view/screenshots.rb', line 51 def clearScreenshot screenshotView.removeFromSuperview if screenshotView end |
#hideScreenshot ⇒ Object
46 47 48 49 |
# File 'lib/turbo/visitable_view/screenshots.rb', line 46 def hideScreenshot screenshotContainerView.removeFromSuperview showOrHideWebView end |
#isShowingScreenshot ⇒ Object
15 16 17 |
# File 'lib/turbo/visitable_view/screenshots.rb', line 15 def isShowingScreenshot screenshotContainerView.superview != nil end |
#screenshotContainerView ⇒ Object
4 5 6 7 8 9 10 11 |
# File 'lib/turbo/visitable_view/screenshots.rb', line 4 def screenshotContainerView @screenshotContainerView ||= begin view = UIView.alloc.initWithFrame(CGRectZero) view.translatesAutoresizingMaskIntoConstraints = false view.backgroundColor = backgroundColor view end end |
#showScreenshot ⇒ Object
38 39 40 41 42 43 44 |
# File 'lib/turbo/visitable_view/screenshots.rb', line 38 def showScreenshot if !isShowingScreenshot && !isRefreshing addSubview(screenshotContainerView) addFillConstraintsForSubview(screenshotContainerView) showOrHideWebView end end |
#updateScreenshot ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/turbo/visitable_view/screenshots.rb', line 19 def updateScreenshot return unless webView return if isShowingScreenshot screenshot = webView.snapshotViewAfterScreenUpdates(false) return unless screenshot screenshotView.removeFromSuperview if screenshotView screenshot.translatesAutoresizingMaskIntoConstraints = false screenshotContainerView.addSubview(screenshot) NSLayoutConstraint.activateConstraints([ screenshot.centerXAnchor.constraintEqualToAnchor(screenshotContainerView.centerXAnchor), screenshot.topAnchor.constraintEqualToAnchor(screenshotContainerView.topAnchor), screenshot.widthAnchor.constraintEqualToConstant(screenshot.bounds.size.width), screenshot.heightAnchor.constraintEqualToConstant(screenshot.bounds.size.height) ]) @screenshotView = screenshot end |