react-native-drawer-layout
Advanced tools
Comparing version 0.3.6 to 0.4.0
@@ -1,2 +0,2 @@ | ||
var _extends = Object.assign || function (target) {for (var i = 1; i < arguments.length; i++) {var source = arguments[i];for (var key in source) {if (Object.prototype.hasOwnProperty.call(source, key)) {target[key] = source[key];}}}return target;};var _createClass = function () {function defineProperties(target, props) {for (var i = 0; i < props.length; i++) {var descriptor = props[i];descriptor.enumerable = descriptor.enumerable || false;descriptor.configurable = true;if ("value" in descriptor) descriptor.writable = true;Object.defineProperty(target, descriptor.key, descriptor);}}return function (Constructor, protoProps, staticProps) {if (protoProps) defineProperties(Constructor.prototype, protoProps);if (staticProps) defineProperties(Constructor, staticProps);return Constructor;};}();var _desc, _value, _class, _class2, _temp;Object.defineProperty(exports, "__esModule", { value: true });exports.default = undefined;var _reactNative = require('react-native');var _reactNative2 = _interopRequireDefault(_reactNative);var _autobindDecorator = require('autobind-decorator');var _autobindDecorator2 = _interopRequireDefault(_autobindDecorator);var _reactNativeDismissKeyboard = require('react-native-dismiss-keyboard');var _reactNativeDismissKeyboard2 = _interopRequireDefault(_reactNativeDismissKeyboard);function _interopRequireDefault(obj) {return obj && obj.__esModule ? obj : { default: obj };}function _classCallCheck(instance, Constructor) {if (!(instance instanceof Constructor)) {throw new TypeError("Cannot call a class as a function");}}function _possibleConstructorReturn(self, call) {if (!self) {throw new ReferenceError("this hasn't been initialised - super() hasn't been called");}return call && (typeof call === "object" || typeof call === "function") ? call : self;}function _inherits(subClass, superClass) {if (typeof superClass !== "function" && superClass !== null) {throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);}subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } });if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass;}function _applyDecoratedDescriptor(target, property, decorators, descriptor, context) {var desc = {};Object['ke' + 'ys'](descriptor).forEach(function (key) {desc[key] = descriptor[key];});desc.enumerable = !!desc.enumerable;desc.configurable = !!desc.configurable;if ('value' in desc || desc.initializer) {desc.writable = true;}desc = decorators.slice().reverse().reduce(function (desc, decorator) {return decorator(target, property, desc) || desc;}, desc);if (context && desc.initializer !== void 0) {desc.value = desc.initializer ? desc.initializer.call(context) : void 0;desc.initializer = undefined;}if (desc.initializer === void 0) {Object['define' + 'Property'](target, property, desc);desc = null;}return desc;} | ||
var _extends = Object.assign || function (target) {for (var i = 1; i < arguments.length; i++) {var source = arguments[i];for (var key in source) {if (Object.prototype.hasOwnProperty.call(source, key)) {target[key] = source[key];}}}return target;};var _createClass = function () {function defineProperties(target, props) {for (var i = 0; i < props.length; i++) {var descriptor = props[i];descriptor.enumerable = descriptor.enumerable || false;descriptor.configurable = true;if ("value" in descriptor) descriptor.writable = true;Object.defineProperty(target, descriptor.key, descriptor);}}return function (Constructor, protoProps, staticProps) {if (protoProps) defineProperties(Constructor.prototype, protoProps);if (staticProps) defineProperties(Constructor, staticProps);return Constructor;};}();var _desc, _value, _class, _class2, _temp;Object.defineProperty(exports, "__esModule", { value: true });exports.default = undefined;var _reactNative = require('react-native');var _reactNative2 = _interopRequireDefault(_reactNative);var _autobindDecorator = require('autobind-decorator');var _autobindDecorator2 = _interopRequireDefault(_autobindDecorator);var _reactNativeDismissKeyboard = require('react-native-dismiss-keyboard');var _reactNativeDismissKeyboard2 = _interopRequireDefault(_reactNativeDismissKeyboard);function _interopRequireDefault(obj) {return obj && obj.__esModule ? obj : { default: obj };}function _classCallCheck(instance, Constructor) {if (!(instance instanceof Constructor)) {throw new TypeError("Cannot call a class as a function");}}function _possibleConstructorReturn(self, call) {if (!self) {throw new ReferenceError("this hasn't been initialised - super() hasn't been called");}return call && (typeof call === "object" || typeof call === "function") ? call : self;}function _inherits(subClass, superClass) {if (typeof superClass !== "function" && superClass !== null) {throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);}subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } });if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass;}function _applyDecoratedDescriptor(target, property, decorators, descriptor, context) {var desc = {};Object['ke' + 'ys'](descriptor).forEach(function (key) {desc[key] = descriptor[key];});desc.enumerable = !!desc.enumerable;desc.configurable = !!desc.configurable;if ('value' in desc || desc.initializer) {desc.writable = true;}desc = decorators.slice().reverse().reduce(function (desc, decorator) {return decorator(target, property, desc) || desc;}, desc);if (context && desc.initializer !== void 0) {desc.value = desc.initializer ? desc.initializer.call(context) : void 0;desc.initializer = undefined;}if (desc.initializer === void 0) {Object['define' + 'Property'](target, property, desc);desc = null;}return desc;}var | ||
@@ -6,3 +6,13 @@ | ||
var DEVICE_WIDTH = parseFloat(_reactNative.Dimensions.get('window').width); | ||
Animated = _reactNative2.default.Animated;var | ||
Dimensions = _reactNative2.default.Dimensions;var | ||
InteractionManager = _reactNative2.default.InteractionManager;var | ||
PanResponder = _reactNative2.default.PanResponder;var | ||
PropTypes = _reactNative2.default.PropTypes;var | ||
StyleSheet = _reactNative2.default.StyleSheet;var | ||
TouchableWithoutFeedback = _reactNative2.default.TouchableWithoutFeedback;var | ||
View = _reactNative2.default.View; | ||
var DEVICE_WIDTH = parseFloat(Dimensions.get('window').width); | ||
var THRESHOLD = DEVICE_WIDTH / 2; | ||
@@ -42,4 +52,6 @@ var VX_MAX = 0.1; | ||
_this.interactionHandle = null; | ||
_this.state = { | ||
openValue: new _reactNative.Animated.Value(0), | ||
openValue: new Animated.Value(0), | ||
drawerShown: false };return _this;}_createClass(DrawerLayout, [{ key: 'componentWillMount', value: function componentWillMount() | ||
@@ -62,2 +74,10 @@ | ||
if (value === 0 || value === 1) { | ||
if (_this2.interactionHandle) { | ||
InteractionManager.clearInteractionHandle(_this2.interactionHandle);}} else | ||
{ | ||
_this2.interactionHandle = InteractionManager.createInteractionHandle();} | ||
_this2._lastOpenValue = value; | ||
@@ -69,3 +89,3 @@ if (_this2.props.onDrawerSlide) { | ||
this._panResponder = _reactNative.PanResponder.create({ | ||
this._panResponder = PanResponder.create({ | ||
onMoveShouldSetPanResponder: this._shouldSetPanResponder, | ||
@@ -112,4 +132,4 @@ onPanResponderGrant: this._panResponderGrant, | ||
return ( | ||
_reactNative2.default.createElement(_reactNative.View, _extends({ style: { flex: 1, backgroundColor: 'transparent' } }, this._panResponder.panHandlers), | ||
_reactNative2.default.createElement(_reactNative.Animated.View, { style: styles.main }, | ||
_reactNative2.default.createElement(View, _extends({ style: { flex: 1, backgroundColor: 'transparent' } }, this._panResponder.panHandlers), | ||
_reactNative2.default.createElement(Animated.View, { style: styles.main }, | ||
this.props.children), | ||
@@ -119,8 +139,8 @@ | ||
drawerShown && | ||
_reactNative2.default.createElement(_reactNative.TouchableWithoutFeedback, { onPress: this._onOverlayClick }, | ||
_reactNative2.default.createElement(_reactNative.Animated.View, { | ||
_reactNative2.default.createElement(TouchableWithoutFeedback, { onPress: this._onOverlayClick }, | ||
_reactNative2.default.createElement(Animated.View, { | ||
style: [styles.overlay, animatedOverlayStyles] })), | ||
_reactNative2.default.createElement(_reactNative.Animated.View, { style: [styles.drawer, dynamicDrawerStyles, animatedDrawerStyles] }, | ||
_reactNative2.default.createElement(Animated.View, { style: [styles.drawer, dynamicDrawerStyles, animatedDrawerStyles] }, | ||
this.props.renderNavigationView())));} }, { key: '_onOverlayClick', value: function _onOverlayClick( | ||
@@ -147,3 +167,3 @@ | ||
this._emitStateChanged(SETTLING); | ||
_reactNative.Animated.spring(this.state.openValue, _extends({ toValue: 1, bounciness: 0, restSpeedThreshold: 0.1 }, options)).start(function () { | ||
Animated.spring(this.state.openValue, _extends({ toValue: 1, bounciness: 0, restSpeedThreshold: 0.1 }, options)).start(function () { | ||
if (_this3.props.onDrawerOpen) { | ||
@@ -159,3 +179,3 @@ _this3.props.onDrawerOpen();} | ||
this._emitStateChanged(SETTLING); | ||
_reactNative.Animated.spring(this.state.openValue, _extends({ toValue: 0, bounciness: 0, restSpeedThreshold: 1 }, options)).start(function () { | ||
Animated.spring(this.state.openValue, _extends({ toValue: 0, bounciness: 0, restSpeedThreshold: 1 }, options)).start(function () { | ||
if (_this4.props.onDrawerClose) { | ||
@@ -282,3 +302,3 @@ _this4.props.onDrawerClose();} | ||
if (drawerPosition === 'right') { | ||
return (DEVICE_WIDTH - x) / drawerWidth;}} }]);return DrawerLayout;}(_reactNative2.default.Component), _class2.defaultProps = { drawerWidth: 0, drawerPosition: 'left' }, _class2.positions = { Left: 'left', Right: 'right' }, _class2.propTypes = { children: _reactNative2.default.PropTypes.node, drawerPosition: _reactNative.PropTypes.oneOf(['left', 'right']).isRequired, drawerWidth: _reactNative.PropTypes.number.isRequired, keyboardDismissMode: _reactNative.PropTypes.oneOf(['none', 'on-drag']), onDrawerClose: _reactNative.PropTypes.func, onDrawerOpen: _reactNative.PropTypes.func, onDrawerSlide: _reactNative.PropTypes.func, onDrawerStateChanged: _reactNative.PropTypes.func, renderNavigationView: _reactNative.PropTypes.func.isRequired }, _temp), (_applyDecoratedDescriptor(_class.prototype, '_onOverlayClick', [_autobindDecorator2.default], Object.getOwnPropertyDescriptor(_class.prototype, '_onOverlayClick'), _class.prototype), _applyDecoratedDescriptor(_class.prototype, 'openDrawer', [_autobindDecorator2.default], Object.getOwnPropertyDescriptor(_class.prototype, 'openDrawer'), _class.prototype), _applyDecoratedDescriptor(_class.prototype, 'closeDrawer', [_autobindDecorator2.default], Object.getOwnPropertyDescriptor(_class.prototype, 'closeDrawer'), _class.prototype), _applyDecoratedDescriptor(_class.prototype, '_handleDrawerOpen', [_autobindDecorator2.default], Object.getOwnPropertyDescriptor(_class.prototype, '_handleDrawerOpen'), _class.prototype), _applyDecoratedDescriptor(_class.prototype, '_handleDrawerClose', [_autobindDecorator2.default], Object.getOwnPropertyDescriptor(_class.prototype, '_handleDrawerClose'), _class.prototype), _applyDecoratedDescriptor(_class.prototype, '_shouldSetPanResponder', [_autobindDecorator2.default], Object.getOwnPropertyDescriptor(_class.prototype, '_shouldSetPanResponder'), _class.prototype), _applyDecoratedDescriptor(_class.prototype, '_panResponderGrant', [_autobindDecorator2.default], Object.getOwnPropertyDescriptor(_class.prototype, '_panResponderGrant'), _class.prototype), _applyDecoratedDescriptor(_class.prototype, '_panResponderMove', [_autobindDecorator2.default], Object.getOwnPropertyDescriptor(_class.prototype, '_panResponderMove'), _class.prototype), _applyDecoratedDescriptor(_class.prototype, '_panResponderRelease', [_autobindDecorator2.default], Object.getOwnPropertyDescriptor(_class.prototype, '_panResponderRelease'), _class.prototype)), _class);exports.default = DrawerLayout; | ||
return (DEVICE_WIDTH - x) / drawerWidth;}} }]);return DrawerLayout;}(_reactNative2.default.Component), _class2.defaultProps = { drawerWidth: 0, drawerPosition: 'left' }, _class2.positions = { Left: 'left', Right: 'right' }, _class2.propTypes = { children: _reactNative2.default.PropTypes.node, drawerPosition: PropTypes.oneOf(['left', 'right']).isRequired, drawerWidth: PropTypes.number.isRequired, keyboardDismissMode: PropTypes.oneOf(['none', 'on-drag']), onDrawerClose: PropTypes.func, onDrawerOpen: PropTypes.func, onDrawerSlide: PropTypes.func, onDrawerStateChanged: PropTypes.func, renderNavigationView: PropTypes.func.isRequired }, _temp), (_applyDecoratedDescriptor(_class.prototype, '_onOverlayClick', [_autobindDecorator2.default], Object.getOwnPropertyDescriptor(_class.prototype, '_onOverlayClick'), _class.prototype), _applyDecoratedDescriptor(_class.prototype, 'openDrawer', [_autobindDecorator2.default], Object.getOwnPropertyDescriptor(_class.prototype, 'openDrawer'), _class.prototype), _applyDecoratedDescriptor(_class.prototype, 'closeDrawer', [_autobindDecorator2.default], Object.getOwnPropertyDescriptor(_class.prototype, 'closeDrawer'), _class.prototype), _applyDecoratedDescriptor(_class.prototype, '_handleDrawerOpen', [_autobindDecorator2.default], Object.getOwnPropertyDescriptor(_class.prototype, '_handleDrawerOpen'), _class.prototype), _applyDecoratedDescriptor(_class.prototype, '_handleDrawerClose', [_autobindDecorator2.default], Object.getOwnPropertyDescriptor(_class.prototype, '_handleDrawerClose'), _class.prototype), _applyDecoratedDescriptor(_class.prototype, '_shouldSetPanResponder', [_autobindDecorator2.default], Object.getOwnPropertyDescriptor(_class.prototype, '_shouldSetPanResponder'), _class.prototype), _applyDecoratedDescriptor(_class.prototype, '_panResponderGrant', [_autobindDecorator2.default], Object.getOwnPropertyDescriptor(_class.prototype, '_panResponderGrant'), _class.prototype), _applyDecoratedDescriptor(_class.prototype, '_panResponderMove', [_autobindDecorator2.default], Object.getOwnPropertyDescriptor(_class.prototype, '_panResponderMove'), _class.prototype), _applyDecoratedDescriptor(_class.prototype, '_panResponderRelease', [_autobindDecorator2.default], Object.getOwnPropertyDescriptor(_class.prototype, '_panResponderRelease'), _class.prototype)), _class);exports.default = DrawerLayout; | ||
@@ -288,3 +308,3 @@ | ||
var styles = _reactNative.StyleSheet.create({ | ||
var styles = StyleSheet.create({ | ||
drawer: { | ||
@@ -291,0 +311,0 @@ position: 'absolute', |
{ | ||
"name": "react-native-drawer-layout", | ||
"version": "0.3.6", | ||
"version": "0.4.0", | ||
"description": "A platform-agnostic drawer layout. Pure JavaScript implementation on iOS and native implementation on Android. Why? Because the drawer layout is a useful component regardless of the platform! And if you can use it without changing any code, that's perfect.", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
19245
204