Skip to content

Commit

Permalink
save scroll position in case of insertion new candle
Browse files Browse the repository at this point in the history
  • Loading branch information
kosyloa committed May 30, 2024
1 parent 55c88ac commit 6a3736c
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions Samples/DXFeedCandleChartMac/CandleChartModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,20 @@ extension CandleChartModel: SnapshotDelegate {
} else {
// insert
self.candles.insert(newPrice, at: 0)
let temp = self.candles
self.xAxisLabels = CandleChartModel.calculateXaxisValues(with: self.type, values: temp)
let currentScroll = self.xScrollPosition

let xValues = Array(temp.enumerated().map({ index, stock in
if stock.stringtimeStamp == currentScroll {
self.xScrollPosition = temp[index - 1].stringtimeStamp
}
return stock.stringtimeStamp
}).reversed())
self.xValues = xValues
}


}
}
}
Expand Down

0 comments on commit 6a3736c

Please sign in to comment.