File tree Expand file tree Collapse file tree 2 files changed +38
-0
lines changed
Expand file tree Collapse file tree 2 files changed +38
-0
lines changed Original file line number Diff line number Diff line change @@ -736,6 +736,32 @@ class AnimatedMultiplication extends AnimatedWithChildren {
736736 }
737737}
738738
739+ class AnimatedDivision extends AnimatedWithChildren {
740+ constructor ( a , b ) {
741+ super ( ) ;
742+ this . _a = a ;
743+ this . _b = b ;
744+ }
745+
746+ __getValue ( ) {
747+ return this . _a . __getValue ( ) / this . _b . __getValue ( ) ;
748+ }
749+
750+ interpolate ( config ) {
751+ return new AnimatedInterpolation ( this , Interpolation . create ( config ) ) ;
752+ }
753+
754+ __attach ( ) {
755+ this . _a . __addChild ( this ) ;
756+ this . _b . __addChild ( this ) ;
757+ }
758+
759+ __detach ( ) {
760+ this . _a . __removeChild ( this ) ;
761+ this . _b . __removeChild ( this ) ;
762+ }
763+ }
764+
739765class AnimatedTransform extends AnimatedWithChildren {
740766 constructor ( transforms ) {
741767 super ( ) ;
@@ -949,6 +975,10 @@ function add(a, b) {
949975 return new AnimatedAddition ( a , b ) ;
950976}
951977
978+ function divide ( a , b ) {
979+ return new AnimatedDivision ( a , b ) ;
980+ }
981+
952982function multiply ( a , b ) {
953983 return new AnimatedMultiplication ( a , b ) ;
954984}
@@ -1187,6 +1217,7 @@ const AnimatedImplementation = {
11871217 spring,
11881218 add,
11891219 multiply,
1220+ divide,
11901221 sequence,
11911222 parallel,
11921223 stagger,
Original file line number Diff line number Diff line change @@ -24,3 +24,10 @@ describe('Animated.View', () => {
2424 expect ( typeof setNativeProps ) . to . equal ( 'function' ) ;
2525 } ) ;
2626} ) ;
27+
28+ describe ( 'Animated.divide' , ( ) => {
29+ it ( 'divides integers' , ( ) => {
30+ const divided = Animated . divide ( new Animated . Value ( 1 ) , new Animated . Value ( 2 ) ) ;
31+ expect ( divided . __getValue ( ) ) . to . equal ( 0.5 ) ;
32+ } ) ;
33+ } ) ;
You can’t perform that action at this time.
0 commit comments