-
Notifications
You must be signed in to change notification settings - Fork 462
Expand file tree
/
Copy pathScrollableGraphViewDrawingLayer.swift
More file actions
52 lines (37 loc) · 1.25 KB
/
ScrollableGraphViewDrawingLayer.swift
File metadata and controls
52 lines (37 loc) · 1.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import UIKit
internal class ScrollableGraphViewDrawingLayer : CAShapeLayer {
var offset: CGFloat = 0 {
didSet {
offsetDidChange()
}
}
var viewportWidth: CGFloat = 0
var viewportHeight: CGFloat = 0
var zeroYPosition: CGFloat = 0
weak var owner: Plot?
var active = true
init(viewportWidth: CGFloat, viewportHeight: CGFloat, offset: CGFloat = 0) {
super.init()
self.viewportWidth = viewportWidth
self.viewportHeight = viewportHeight
self.frame = CGRect(origin: CGPoint(x: offset, y: 0), size: CGSize(width: self.viewportWidth, height: self.viewportHeight))
setup()
}
override init(layer: Any) {
super.init()
}
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
private func setup() {
// Get rid of any animations.
self.actions = ["position" : NSNull(), "bounds" : NSNull()]
}
private func offsetDidChange() {
self.frame.origin.x = offset
self.bounds.origin.x = offset
}
func updatePath() {
fatalError("updatePath needs to be implemented by the subclass")
}
}