Skip to content

Commit

Permalink
⭐️ Impl: Add RNIAnimatorSize
Browse files Browse the repository at this point in the history
  • Loading branch information
dominicstop committed Apr 18, 2023
1 parent f1af0aa commit 91da1b2
Showing 1 changed file with 54 additions and 0 deletions.
54 changes: 54 additions & 0 deletions ios/src_library/Helpers+Utilities/RNIAnimatorSize.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
//
// RNIAnimatorSize.swift
// react-native-ios-modal
//
// Created by Dominic Go on 4/19/23.
//

import Foundation

fileprivate extension CGSize {
init(array: [CGFloat]) {
self = CGSize(width: array[0], height: array[1]);
};

var array: [CGFloat] {
return [
self.width,
self.height
];
};
};

public class RNIAnimatorSize: RNIAnimator {

public init?(
durationSeconds: CFTimeInterval,
sizeStart: CGSize,
sizeEnd: CGSize,
onSizeDidChange: ((_ newSize: CGSize) -> Void)? = nil,
onAnimationCompletion: (() -> Void)? = nil
) {
super.init(
durationSeconds: durationSeconds,
animatedValuesStart: sizeStart.array,
animatedValuesEnd: sizeEnd.array
) {
onSizeDidChange?(
CGSize(array: $0)
);
} onAnimationCompletion: {
onAnimationCompletion?();
};
};

public func update(
sizeEnd: CGSize,
duration: CGFloat? = nil
){
super.update(
animatedValuesEnd: sizeEnd.array,
duration: duration
);
};
};

0 comments on commit 91da1b2

Please sign in to comment.