Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change layer's position after animation stops.
Add setAnchorPoint, willStop, withDisableActions. Add layer dragging feature.
- Loading branch information
Showing
17 changed files
with
325 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,7 @@ | |
# | ||
# Pods/ | ||
|
||
build | ||
.DS_Store | ||
xcuserdata | ||
*.xccheckout |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// | ||
// CALayer+Drag.swift | ||
// ShapeAnimation | ||
// | ||
// Created by Zhang Yungui on 15/2/6. | ||
// Copyright (c) 2015 github.com/rhcad. All rights reserved. | ||
// | ||
|
||
import SwiftGraphics | ||
|
||
public extension CALayer { | ||
func constrainCenterToSuperview(center:CGPoint) { | ||
let kEdgeBuffer:CGFloat = 4 | ||
var constrain = superlayer.bounds.insetted(dx:kEdgeBuffer, dy:kEdgeBuffer) | ||
constrain.inset(dx: frame.width / 2, dy: frame.height / 2) | ||
let pt = constrain.isEmpty ? superlayer.bounds.mid : center.clamped(constrain) | ||
moveAnimation(to: pt, relative:false).apply() | ||
} | ||
|
||
func bringOnScreen() { | ||
if !superlayer.bounds.contains(frame) { | ||
constrainCenterToSuperview(position) | ||
} | ||
} | ||
} |
Oops, something went wrong.