Skip to content

Commit 54150c3

Browse files
committed
add function
1 parent fc67296 commit 54150c3

1 file changed

Lines changed: 18 additions & 6 deletions

File tree

ScrollEdgeControl/Core/ScrollEdgeControl.swift

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -562,15 +562,27 @@ public final class ScrollEdgeControl: UIControl {
562562

563563
private func layoutSelfInScrollView() {
564564

565+
func setFrame(_ frame: CGRect) {
566+
guard self.frame != frame else {
567+
return
568+
}
569+
self.frame = frame
570+
}
571+
572+
func setZPosition(_ position: CGFloat) {
573+
guard layer.zPosition != position else { return }
574+
layer.zPosition = position
575+
}
576+
565577
guard let scrollView = targetScrollView else {
566578
return
567579
}
568580

569581
switch configuration.zLayoutMode {
570582
case .front:
571-
layer.zPosition = 1
583+
setZPosition(1)
572584
case .back:
573-
layer.zPosition = -1
585+
setZPosition(-1)
574586
}
575587

576588
let length: CGFloat
@@ -603,7 +615,7 @@ public final class ScrollEdgeControl: UIControl {
603615
size: sizeForVertical
604616
)
605617

606-
self.frame = frame
618+
setFrame(frame)
607619

608620
case .bottom:
609621

@@ -616,7 +628,7 @@ public final class ScrollEdgeControl: UIControl {
616628
size: sizeForVertical
617629
)
618630

619-
self.frame = frame
631+
setFrame(frame)
620632

621633
case .left:
622634

@@ -628,7 +640,7 @@ public final class ScrollEdgeControl: UIControl {
628640
size: sizeForHorizontal
629641
)
630642

631-
self.frame = frame
643+
setFrame(frame)
632644

633645
case .right:
634646

@@ -641,7 +653,7 @@ public final class ScrollEdgeControl: UIControl {
641653
size: sizeForHorizontal
642654
)
643655

644-
self.frame = frame
656+
setFrame(frame)
645657

646658
}
647659

0 commit comments

Comments
 (0)