Skip to content

Instantly share code, notes, and snippets.

@kenwheeler
Created August 1, 2017 19:43
Show Gist options
  • Save kenwheeler/09974aebc08f0b530c1e77452f908810 to your computer and use it in GitHub Desktop.
Save kenwheeler/09974aebc08f0b530c1e77452f908810 to your computer and use it in GitHub Desktop.
let scheduleItemPress args self => {
let (x, y, width, height, item, index) = args;
/* Handle target dimensions */
let fx = float_of_int x;
let fy = float_of_int y;
let fw = float_of_int width;
let fh = float_of_int height;
let targetDimensions = {x: fx, y: fy, width: fw, height: fh};
self.ReasonReact.update handleTargetDimensions targetDimensions;
/* Set modal coords based upon clicked item */
Animated.Value.setValue self.state.modalLeft fx;
Animated.Value.setValue self.state.modalTop fy;
Animated.Value.setValue self.state.modalWidth fw;
Animated.Value.setValue self.state.modalHeight fh;
/* Display and give modal data */
self.ReasonReact.update handleItem (Some item);
self.ReasonReact.update handleIndex index;
self.ReasonReact.update handleModal true;
let ww = (DimensionsRe.get `window)##width - 20;
let wh = (DimensionsRe.get `window)##height - 90;
/* Define animations */
let animationBatch =
Animated.parallel
[|
Animated.Timing.animate
value::self.state.listOpacity toValue::(`raw 0.) easing::easeIn duration::300. (),
Animated.Timing.animate
value::self.state.modalTop
toValue::(`raw (PlatformRe.os === PlatformRe.IOS ? 30. : 10.))
easing::easeIn
duration::300.
(),
Animated.Timing.animate
value::self.state.modalWidth
toValue::(`raw (float_of_int ww))
easing::easeIn
duration::300.
(),
Animated.Timing.animate
value::self.state.modalHeight
toValue::(`raw (float_of_int wh))
easing::easeIn
duration::300.
()
|]
[%bs.raw "{stopTogether: true}"];
/* Start animations */
Animated.CompositeAnimation.start
animationBatch
callback::(
fun _ => {
let _id =
Js.Global.setTimeout
(fun _finished => self.ReasonReact.update handleModalReady true) 100;
()
}
);
ReasonReact.NoUpdate
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment