okay now working with adjust

undo
Saint 2023-06-02 19:20:04 -04:00
parent 3a456cb457
commit f479bdf3ee
4 changed files with 63 additions and 67 deletions

View File

@ -95,7 +95,7 @@ public class VisibilityTracker<ID: Hashable>: ObservableObject {
}
func sortViews() {
var sortedPairs = visibleViews.sorted(by: { Int($0.1) < Int($1.1) })
var sortedPairs = visibleViews.sorted(by: { abs(Int($0.1)) < abs(Int($1.1)) })
// let sortedPairs = visibleViews.sorted(by: { Int($0.1) < Int($1.1) })
// let sortedPairs = visibleViews.sorted(by: { $0 < $1 })
sortedViewIDs = sortedPairs.map { $0.0 }

View File

@ -4,59 +4,11 @@
type = "1"
version = "2.0">
<Breakpoints>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
uuid = "15F59F9C-3FC1-4D0F-B85D-E6FBE78FA1B7"
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "gloss/ContentView.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "577"
endingLineNumber = "577"
landmarkName = "unknown"
landmarkType = "0">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
uuid = "CDC436E9-4048-417F-B565-1230E11797C1"
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "gloss/ContentView.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "446"
endingLineNumber = "446"
landmarkName = "body"
landmarkType = "24">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
uuid = "EA8119C2-B8C5-4B88-AA9A-2C4C80482D9E"
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "gloss/ContentView.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "451"
endingLineNumber = "451"
landmarkName = "body"
landmarkType = "24">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
uuid = "19620363-AF5F-4353-862D-4E40746274F5"
shouldBeEnabled = "Yes"
shouldBeEnabled = "No"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "gloss/ContentView.swift"
@ -72,7 +24,7 @@
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
uuid = "A3202903-6BE5-4879-8970-4CE7B825E6DD"
shouldBeEnabled = "Yes"
shouldBeEnabled = "No"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "gloss/ContentView.swift"
@ -84,5 +36,37 @@
landmarkType = "7">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
uuid = "DCBFFF14-138E-43D2-BA78-A5265A13CD4F"
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "gloss/ContentView.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "457"
endingLineNumber = "457"
landmarkName = "body"
landmarkType = "24">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
uuid = "1FDEB1B0-A696-4F5A-86AB-30728070E82F"
shouldBeEnabled = "No"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "gloss/ContentView.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "425"
endingLineNumber = "425"
landmarkName = "body"
landmarkType = "24">
</BreakpointContent>
</BreakpointProxy>
</Breakpoints>
</Bucket>

View File

@ -421,8 +421,8 @@ struct ContentView: View {
Task {
DispatchQueue.main.async {
Print("first scroll to")
Print(scrollId)
Print("scroll Id target: \(scrollId)")
proxy.scrollTo(scrollId! , anchor: .top)
@ -432,10 +432,11 @@ struct ContentView: View {
// if (currentId != scrollId!) {
DispatchQueue.main.asyncAfter(deadline: .now() + 2) {
DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) {
Print(" scroll id target", currentId)
Print(" current id ", scrollId)
Print(" scroll id target", scrollId)
Print(" current id ", currentId)
Print(gTracker!.sortedViewIDs)
if (currentId! != scrollId!) {
Print("NO MATCH")
}
@ -446,10 +447,20 @@ struct ContentView: View {
var curOffset = gTracker!.visibleViews[scrollId!]
Print(" stats", gTracker!.visibleViews)
// // setScrollOffset = CGFloat(Int(currentOffset!) * -1 + Int(scrollOffset!))
if (curOffset != nil) {
setScrollOffset = CGFloat(Int(scrollOffset!) - Int(curOffset!))
Print("applying scroll offset \(setScrollOffset)")
// // setScrollOffset = CGFloat(Int(scrollOffset!))
// Print("setting scroll offset", setScrollOffset)
refresh2.toggle()
} else {
var adjust = (Int(scrollId!)! - Int(currentId!)!) * 200
Print("adjusting \(adjust)")
setScrollOffset = CGFloat(adjust)
refresh.toggle()
}
// // currentId = scrollId!
// DispatchQueue.main.async {
@ -553,14 +564,15 @@ struct ContentView: View {
return
}
currentId = tracker.sortedViewIDs[tracker.sortedViewIDs.count - 1]
// currentId = tracker.sortedViewIDs[tracker.sortedViewIDs.count - 1]
currentId = tracker.sortedViewIDs[0]
currentOffset = tracker.visibleViews[currentId!]!
if (Int(currentOffset!) < 0) {
if (tracker.sortedViewIDs.count > 1) {
currentId = tracker.sortedViewIDs[1]
currentOffset = tracker.visibleViews[currentId!]!
}
}
// if (Int(currentOffset!) != -1 && Int(currentOffset!) < 0) {
// if (tracker.sortedViewIDs.count > 1) {
// currentId = tracker.sortedViewIDs[1]
// currentOffset = tracker.visibleViews[currentId!]!
// }
// }
// if (currentId != nil) {
// // if (printCount % printRate == 0) {
// // print(printCount)