[rating-view] [ios] Fixed rating view update delay.

This commit is contained in:
Ilya Grechuhin 2017-12-06 18:08:52 +03:00
parent 545df162e5
commit 9c5facf6bd

View file

@ -308,6 +308,9 @@ import UIKit
}
private var viewSize = CGSize()
var scheduledUpdate: DispatchWorkItem?
func updateImpl() {
let layers = createLayers()
layer.sublayers = layers
@ -317,16 +320,10 @@ import UIKit
frame.size = intrinsicContentSize
}
@objc func doUpdate() {
DispatchQueue.main.async {
self.updateImpl()
}
}
func update() {
let sel = #selector(doUpdate)
NSObject.cancelPreviousPerformRequests(withTarget: self, selector: sel, object: nil)
perform(sel, with: nil, afterDelay: 1 / 120)
scheduledUpdate?.cancel()
scheduledUpdate = DispatchWorkItem { self.updateImpl() }
DispatchQueue.main.async(execute: scheduledUpdate!)
}
override var intrinsicContentSize: CGSize {