Bladeren bron

CAAnimation: add a softer wiggle mode needed for long items

(cherry picked from commit 56cabbe4c3f60f2f34296598c90ae1258c29ea16)
Felix Paul Kühne 9 jaren geleden
bovenliggende
commit
a505c6e23e

+ 1 - 1
Apple-TV/VLCOpenNetworkStreamTVViewController.m

@@ -174,7 +174,7 @@
 
     UITableViewCell *focusedCell = [self.previouslyPlayedStreamsTableView cellForRowAtIndexPath:self.currentlyFocusedIndexPath];
     if (editing) {
-        [focusedCell.layer addAnimation:[CAAnimation vlc_wiggleAnimation]
+        [focusedCell.layer addAnimation:[CAAnimation vlc_wiggleAnimationwithSoftMode:YES]
                                  forKey:VLCWiggleAnimationKey];
     } else {
         [focusedCell.layer removeAnimationForKey:VLCWiggleAnimationKey];

+ 1 - 1
Apple-TV/VLCRemotePlaybackViewController.m

@@ -238,7 +238,7 @@
 
     UICollectionViewCell *focusedCell = [self.cachedMediaCollectionView cellForItemAtIndexPath:self.currentlyFocusedIndexPath];
     if (editing) {
-        [focusedCell.layer addAnimation:[CAAnimation vlc_wiggleAnimation]
+        [focusedCell.layer addAnimation:[CAAnimation vlc_wiggleAnimationwithSoftMode:NO]
                                  forKey:VLCWiggleAnimationKey];
     } else {
         [focusedCell.layer removeAnimationForKey:VLCWiggleAnimationKey];

+ 1 - 1
SharedSources/CAAnimation+VLCWiggle.h

@@ -14,5 +14,5 @@
 static NSString *const VLCWiggleAnimationKey = @"VLCWiggleAnimation";
 
 @interface CAAnimation (VLCWiggle)
-+ (instancetype)vlc_wiggleAnimation;
++ (instancetype)vlc_wiggleAnimationwithSoftMode:(BOOL)softmode;
 @end

+ 16 - 7
SharedSources/CAAnimation+VLCWiggle.m

@@ -12,7 +12,7 @@
 #import "CAAnimation+VLCWiggle.h"
 
 @implementation CAAnimation (VLCWiggle)
-+ (instancetype)vlc_wiggleAnimation
++ (instancetype)vlc_wiggleAnimationwithSoftMode:(BOOL)softmode
 {
     CAKeyframeAnimation *position = [CAKeyframeAnimation animation];
     position.keyPath = @"position";
@@ -32,12 +32,21 @@
 
     CAKeyframeAnimation *rotation = [CAKeyframeAnimation animation];
     rotation.keyPath = @"transform.rotation";
-    rotation.values = @[
-                        @0,
-                        @0.03,
-                        @0,
-                        [NSNumber numberWithFloat:-0.02]
-                        ];
+    if (softmode) {
+        rotation.values = @[
+                            @0,
+                            @0.005,
+                            @0,
+                            [NSNumber numberWithFloat:-0.004]
+                            ];
+    } else {
+        rotation.values = @[
+                            @0,
+                            @0.03,
+                            @0,
+                            [NSNumber numberWithFloat:-0.02]
+                            ];
+    }
     rotation.timingFunctions = @[
                                  [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut],
                                  [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]