material-motion-archive / starmap

Issue tracker for the starmap
https://material-motion.github.io/material-motion/
4 stars 0 forks source link

Begin exploring a JavaScript cross-platform language on iOS and Android #84

Open jverkoey opened 7 years ago

jverkoey commented 7 years ago

Goal: create one JavaScript director that can be used to add plans to a native runtime on iOS and Android. This same director could be used on the web as well.

jverkoey commented 7 years ago

Director example

import Transitions
import TransitionTween

class FadeInTransitionDirector {
  constructor(transition) {
    this.transition = transition
  }

 setUp() {
    let fadeIn = TransitionTween("opacity",
                                 transition,
                                 Segment.entire(),
                                 [0, 1])
    fadeIn.timingFunction = TimingFunctions.easeInEaseOut()
    this.transition.runtime.addPlan(fadeIn, this.transition.fore.element)
  }
}

runtime would be a bridge to the Apple/Android/Web Runtime instance. Any plans added to the runtime would generate native Performers. The end result would be an interaction/transition that is equally as performant as a director expressed in Objective-C/Swift/Java.

appsforartists commented 7 years ago

Is this explicitly targeting React Native and/or NativeScript?

There's a whole bunch of stuff those platforms provide that would be non-trivial separately (e.g. a way to marshal data between JS and ObjC). It also adds a further layer of common abstraction that must be maintained across platforms (e.g. to know that position needs to be converted to translate before the web can understand it).

jverkoey commented 7 years ago

This is a layer that should be able to target any platform.

jverkoey commented 7 years ago

Most of the work will be in building out JavaScript APIs that reflect the relevant data types and values we expect to use to express interactions. This is very likely work we'll be undertaking for material-motion-js already.

jverkoey commented 7 years ago

On Apple the fastest path to a prototype would be to use JavaScript core: http://nshipster.com/javascriptcore/

jverkoey commented 7 years ago

Use of JSContext in React Native: https://github.com/facebook/react-native/search?utf8=%E2%9C%93&q=JSContext&type=Code

jverkoey commented 7 years ago

It also adds a further layer of common abstraction that must be maintained across platforms

I see this as the layer we're building for the web anyway. The hardest part is the transferring of information into the native runtimes, which is also a problem we should be solving with regards to passing information to/from design tools.