Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 16 additions & 4 deletions Sources/SwiftUITooltip/TooltipModifier.swift
Original file line number Diff line number Diff line change
Expand Up @@ -218,18 +218,24 @@ struct TooltipModifier<TooltipContent: View>: ViewModifier {
}
.offset(x: self.offsetHorizontal(g), y: self.offsetVertical(g))
.animation(self.animation)
.zIndex(config.zIndex)
.onAppear {
self.dispatchAnimation()
}
}
.zIndex(config.zIndex)
}

// MARK: - ViewModifier properties

func body(content: Content) -> some View {
content
.overlay(enabled ? tooltipBody.transition(config.transition) : nil)
ZStack {
content
if enabled {
tooltipBody
.transition(config.transition)
.zIndex(config.zIndex)
}
}
}
}

Expand All @@ -240,30 +246,36 @@ struct Tooltip_Previews: PreviewProvider {

var config1 = DefaultTooltipConfig(side: side)
config1.backgroundColor = .black
config1.zIndex = 999999

let config2 = DefaultTooltipConfig(side: side)
var config2 = DefaultTooltipConfig(side: side)
config2.zIndex = 999999

var config3 = DefaultTooltipConfig(side: side)
config3.backgroundColor = .green
config3.borderColor = .red
config3.zIndex = 999999

var config4 = DefaultTooltipConfig(side: side)
config4.arrowWidth = 24
config4.arrowHeight = 8
config4.backgroundColor = .black
config4.arrowType = .curveIn
config4.zIndex = 999999

var config5 = DefaultTooltipConfig(side: side)
config5.arrowWidth = 24
config5.arrowHeight = 8
config5.arrowType = .curveIn
config5.zIndex = 999999

var config6 = DefaultTooltipConfig(side: side)
config6.arrowWidth = 24
config6.arrowHeight = 8
config6.backgroundColor = .green
config6.borderColor = .red
config6.arrowType = .curveIn
config6.zIndex = 999999

return VStack {
HStack {
Expand Down
2 changes: 1 addition & 1 deletion Sources/SwiftUITooltip/config/ArrowOnlyTooltipConfig.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public struct ArrowOnlyTooltipConfig: TooltipConfig {

public var side: TooltipSide = .bottom
public var margin: CGFloat = 8
public var zIndex: Double = 10000
public var zIndex: Double = 999999

public var width: CGFloat?
public var height: CGFloat?
Expand Down
2 changes: 1 addition & 1 deletion Sources/SwiftUITooltip/config/DefaultTooltipConfig.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public struct DefaultTooltipConfig: TooltipConfig {

public var side: TooltipSide = .bottom
public var margin: CGFloat = 8
public var zIndex: Double = 10000
public var zIndex: Double = 999999

public var width: CGFloat?
public var height: CGFloat?
Expand Down