create-expo-cljs-app
Version:
Create a react native application with Expo and Shadow-CLJS!
106 lines (79 loc) • 4.26 kB
JavaScript
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
* @format
*/
;
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
import AnimatedValue from './AnimatedValue';
import AnimatedNode from './AnimatedNode';
import { generateNewAnimationId, shouldUseNativeDriver } from '../NativeAnimatedHelper';
var AnimatedTracking = /*#__PURE__*/function (_AnimatedNode) {
_inheritsLoose(AnimatedTracking, _AnimatedNode);
function AnimatedTracking(value, parent, animationClass, animationConfig, callback) {
var _this;
_this = _AnimatedNode.call(this) || this;
_this._value = value;
_this._parent = parent;
_this._animationClass = animationClass;
_this._animationConfig = animationConfig;
_this._useNativeDriver = shouldUseNativeDriver(animationConfig);
_this._callback = callback;
_this.__attach();
return _this;
}
var _proto = AnimatedTracking.prototype;
_proto.__makeNative = function __makeNative() {
this.__isNative = true;
this._parent.__makeNative();
_AnimatedNode.prototype.__makeNative.call(this);
this._value.__makeNative();
};
_proto.__getValue = function __getValue() {
return this._parent.__getValue();
};
_proto.__attach = function __attach() {
this._parent.__addChild(this);
if (this._useNativeDriver) {
// when the tracking starts we need to convert this node to a "native node"
// so that the parent node will be made "native" too. This is necessary as
// if we don't do this `update` method will get called. At that point it
// may be too late as it would mean the JS driver has already started
// updating node values
this.__makeNative();
}
};
_proto.__detach = function __detach() {
this._parent.__removeChild(this);
_AnimatedNode.prototype.__detach.call(this);
};
_proto.update = function update() {
this._value.animate(new this._animationClass(_objectSpread(_objectSpread({}, this._animationConfig), {}, {
toValue: this._animationConfig.toValue.__getValue()
})), this._callback);
};
_proto.__getNativeConfig = function __getNativeConfig() {
var animation = new this._animationClass(_objectSpread(_objectSpread({}, this._animationConfig), {}, {
// remove toValue from the config as it's a ref to Animated.Value
toValue: undefined
}));
var animationConfig = animation.__getNativeAnimationConfig();
return {
type: 'tracking',
animationId: generateNewAnimationId(),
animationConfig: animationConfig,
toValue: this._parent.__getNativeTag(),
value: this._value.__getNativeTag()
};
};
return AnimatedTracking;
}(AnimatedNode);
export default AnimatedTracking;