react-native-drawer-layout
Advanced tools
Comparing version 0.3.1 to 0.3.3
@@ -1,114 +0,73 @@ | ||
Object.defineProperty(exports, '__esModule', { | ||
value: true | ||
}); | ||
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 _createDecoratedClass = (function () { function defineProperties(target, descriptors, initializers) { for (var i = 0; i < descriptors.length; i++) { var descriptor = descriptors[i]; var decorators = descriptor.decorators; var key = descriptor.key; delete descriptor.key; delete descriptor.decorators; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor || descriptor.initializer) descriptor.writable = true; if (decorators) { for (var f = 0; f < decorators.length; f++) { var decorator = decorators[f]; if (typeof decorator === 'function') { descriptor = decorator(target, key, descriptor) || descriptor; } else { throw new TypeError('The decorator for method ' + descriptor.key + ' is of the invalid type ' + typeof decorator); } } if (descriptor.initializer !== undefined) { initializers[key] = descriptor; continue; } } Object.defineProperty(target, key, descriptor); } } return function (Constructor, protoProps, staticProps, protoInitializers, staticInitializers) { if (protoProps) defineProperties(Constructor.prototype, protoProps, protoInitializers); if (staticProps) defineProperties(Constructor, staticProps, staticInitializers); return Constructor; }; })(); | ||
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 _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } }; | ||
var DEVICE_WIDTH = parseFloat(_reactNative.Dimensions.get('window').width); | ||
var THRESHOLD = DEVICE_WIDTH / 2; | ||
var VX_MAX = 0.1; | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } | ||
var IDLE = 'Idle'; | ||
var DRAGGING = 'Dragging'; | ||
var SETTLING = 'Settling';var | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } | ||
DrawerLayout = (_class = (_temp = _class2 = function (_React$Component) {_inherits(DrawerLayout, _React$Component); | ||
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; } | ||
var _reactNative = require('react-native'); | ||
var _reactNative2 = _interopRequireDefault(_reactNative); | ||
var _autobindDecorator = require('autobind-decorator'); | ||
var _autobindDecorator2 = _interopRequireDefault(_autobindDecorator); | ||
var _dismissKeyboard = require('dismissKeyboard'); | ||
var _dismissKeyboard2 = _interopRequireDefault(_dismissKeyboard); | ||
var DEVICE_WIDTH = parseFloat(_reactNative.Dimensions.get('window').width); | ||
var THRESHOLD = DEVICE_WIDTH / 2; | ||
var VX_MAX = 0.1; | ||
var IDLE = 'Idle'; | ||
var DRAGGING = 'Dragging'; | ||
var SETTLING = 'Settling'; | ||
var DrawerLayout = (function (_React$Component) { | ||
_inherits(DrawerLayout, _React$Component); | ||
_createClass(DrawerLayout, null, [{ | ||
key: 'defaultProps', | ||
value: { | ||
drawerWidth: 0, | ||
drawerPosition: 'left' | ||
}, | ||
enumerable: true | ||
}, { | ||
key: 'propTypes', | ||
value: { | ||
drawerWidth: _reactNative.PropTypes.number.isRequired, | ||
drawerPosition: _reactNative.PropTypes.oneOf(['left', 'right']).isRequired, | ||
renderNavigationView: _reactNative.PropTypes.func.isRequired, | ||
onDrawerSlide: _reactNative.PropTypes.func, | ||
onDrawerStateChanged: _reactNative.PropTypes.func, | ||
onDrawerOpen: _reactNative.PropTypes.func, | ||
onDrawerClose: _reactNative.PropTypes.func, | ||
keyboardDismissMode: _reactNative.PropTypes.oneOf(['none', 'on-drag']) | ||
}, | ||
enumerable: true | ||
}]); | ||
function DrawerLayout(props, context) { | ||
_classCallCheck(this, DrawerLayout); | ||
_get(Object.getPrototypeOf(DrawerLayout.prototype), 'constructor', this).call(this, props, context); | ||
this.state = { | ||
openValue: new _reactNative.Animated.Value(0) | ||
}; | ||
} | ||
_createDecoratedClass(DrawerLayout, [{ | ||
key: 'componentWillMount', | ||
value: function componentWillMount() { | ||
var _this = this; | ||
var openValue = this.state.openValue; | ||
openValue.addListener(function (_ref) { | ||
var value = _ref.value; | ||
if (_this.props.keyboardDismissMode === 'on-drag') { | ||
(0, _dismissKeyboard2.default)(); | ||
} | ||
_this._lastOpenValue = value; | ||
_this.props.onDrawerSlide && _this.props.onDrawerSlide({ nativeEvent: { offset: value } }); | ||
}); | ||
this._panResponder = _reactNative.PanResponder.create({ | ||
onMoveShouldSetPanResponder: this._shouldSetPanResponder, | ||
onPanResponderGrant: this._panResponderGrant, | ||
onPanResponderMove: this._panResponderMove, | ||
onPanResponderTerminationRequest: function (evt, gestureState) { | ||
return true; | ||
}, | ||
onPanResponderRelease: this._panResponderRelease, | ||
onPanResponderTerminate: function (evt, gestureState) {} | ||
}); | ||
} | ||
}, { | ||
key: 'render', | ||
value: function render() { | ||
var openValue = this.state.openValue; | ||
var _props = this.props; | ||
var drawerPosition = _props.drawerPosition; | ||
var drawerWidth = _props.drawerWidth; | ||
function DrawerLayout(props, context) {_classCallCheck(this, DrawerLayout);var _this = _possibleConstructorReturn(this, Object.getPrototypeOf(DrawerLayout).call(this, | ||
props, context)); | ||
_this.state = { | ||
openValue: new _reactNative.Animated.Value(0) };return _this;}_createClass(DrawerLayout, [{ key: 'componentWillMount', value: function componentWillMount() | ||
{var _this2 = this;var | ||
openValue = this.state.openValue; | ||
openValue.addListener(function (_ref) {var value = _ref.value; | ||
if (_this2.props.keyboardDismissMode === 'on-drag') { | ||
(0, _reactNativeDismissKeyboard2.default)();} | ||
_this2._lastOpenValue = value; | ||
if (_this2.props.onDrawerSlide) { | ||
_this2.props.onDrawerSlide({ nativeEvent: { offset: value } });}}); | ||
this._panResponder = _reactNative.PanResponder.create({ | ||
onMoveShouldSetPanResponder: this._shouldSetPanResponder, | ||
onPanResponderGrant: this._panResponderGrant, | ||
onPanResponderMove: this._panResponderMove, | ||
onPanResponderTerminationRequest: function () {return true;}, | ||
onPanResponderRelease: this._panResponderRelease, | ||
onPanResponderTerminate: function () {} });} }, { key: 'render', value: function render() | ||
{var | ||
openValue = this.state.openValue;var _props = | ||
this.props;var drawerPosition = _props.drawerPosition;var drawerWidth = _props.drawerWidth; | ||
var dynamicDrawerStyles = {}; | ||
@@ -122,106 +81,91 @@ dynamicDrawerStyles[drawerPosition] = 0; | ||
if (drawerPosition === 'left') { | ||
outputRange = [-drawerWidth, 0]; | ||
} else { | ||
outputRange = [drawerWidth, 0]; | ||
} | ||
outputRange = [-drawerWidth, 0];} else | ||
{ | ||
outputRange = [drawerWidth, 0];} | ||
var drawerTranslateX = openValue.interpolate({ | ||
inputRange: [0, 1], | ||
outputRange: outputRange, | ||
extrapolate: 'clamp' | ||
}); | ||
var drawerTranslateX = openValue.interpolate({ | ||
inputRange: [0, 1], | ||
outputRange: outputRange, | ||
extrapolate: 'clamp' }); | ||
var animatedDrawerStyles = { transform: [{ translateX: drawerTranslateX }] }; | ||
/* Overlay styles */ | ||
var opacityOutputRange = undefined; | ||
var overlayOpacity = openValue.interpolate({ | ||
inputRange: [0, 1], | ||
outputRange: [0, 0.7], | ||
extrapolate: 'clamp' }); | ||
var overlayOpacity = openValue.interpolate({ | ||
inputRange: [0, 1], | ||
outputRange: [0, 0.7], | ||
extrapolate: 'clamp' | ||
}); | ||
var animatedOverlayStyles = { opacity: overlayOpacity }; | ||
return _reactNative2.default.createElement( | ||
_reactNative.View, | ||
_extends({ style: { flex: 1, backgroundColor: 'transparent' } }, this._panResponder.panHandlers), | ||
_reactNative2.default.createElement( | ||
_reactNative.Animated.View, | ||
{ style: styles.main }, | ||
this.props.children | ||
), | ||
_reactNative2.default.createElement( | ||
_reactNative.TouchableWithoutFeedback, | ||
{ onPress: this._onOverlayClick }, | ||
_reactNative2.default.createElement(_reactNative.Animated.View, { | ||
style: [styles.overlay, animatedOverlayStyles], | ||
pointerEvents: 'none' }) | ||
), | ||
_reactNative2.default.createElement( | ||
_reactNative.Animated.View, | ||
{ style: [styles.drawer, dynamicDrawerStyles, animatedDrawerStyles] }, | ||
this.props.renderNavigationView() | ||
) | ||
); | ||
} | ||
}, { | ||
key: '_onOverlayClick', | ||
decorators: [_autobindDecorator2.default], | ||
value: function _onOverlayClick() { | ||
this.closeDrawer(); | ||
} | ||
}, { | ||
key: '_emitStateChanged', | ||
value: function _emitStateChanged(newState) { | ||
this.props.onDrawerStateChanged && this.props.onDrawerStateChanged(newState); | ||
} | ||
}, { | ||
key: 'openDrawer', | ||
decorators: [_autobindDecorator2.default], | ||
value: function openDrawer() { | ||
var _this2 = this; | ||
return ( | ||
_reactNative2.default.createElement(_reactNative.View, _extends({ style: { flex: 1, backgroundColor: 'transparent' } }, this._panResponder.panHandlers), | ||
_reactNative2.default.createElement(_reactNative.Animated.View, { style: styles.main }, | ||
this.props.children), | ||
var options = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0]; | ||
_reactNative2.default.createElement(_reactNative.TouchableWithoutFeedback, { onPress: this._onOverlayClick }, | ||
_reactNative2.default.createElement(_reactNative.Animated.View, { | ||
style: [styles.overlay, animatedOverlayStyles] })), | ||
_reactNative2.default.createElement(_reactNative.Animated.View, { style: [styles.drawer, dynamicDrawerStyles, animatedDrawerStyles] }, | ||
this.props.renderNavigationView())));} }, { key: '_onOverlayClick', value: function _onOverlayClick( | ||
e) { | ||
e.stopPropagation(); | ||
this.closeDrawer();} }, { key: '_emitStateChanged', value: function _emitStateChanged( | ||
newState) { | ||
if (this.props.onDrawerStateChanged) { | ||
this.props.onDrawerStateChanged(newState);}} }, { key: 'openDrawer', value: function openDrawer() | ||
{var _this3 = this;var options = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0]; | ||
this._emitStateChanged(SETTLING); | ||
_reactNative.Animated.spring(this.state.openValue, _extends({ toValue: 1, bounciness: 0, restSpeedThreshold: 0.1 }, options)).start(function () { | ||
_this2.props.onDrawerOpen && _this2.props.onDrawerOpen(); | ||
_this2._emitStateChanged(IDLE); | ||
}); | ||
} | ||
}, { | ||
key: 'closeDrawer', | ||
decorators: [_autobindDecorator2.default], | ||
value: function closeDrawer() { | ||
var _this3 = this; | ||
if (_this3.props.onDrawerOpen) { | ||
_this3.props.onDrawerOpen();} | ||
var options = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0]; | ||
_this3._emitStateChanged(IDLE);});} }, { key: 'closeDrawer', value: function closeDrawer() | ||
{var _this4 = this;var options = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0]; | ||
this._emitStateChanged(SETTLING); | ||
_reactNative.Animated.spring(this.state.openValue, _extends({ toValue: 0, bounciness: 0, restSpeedThreshold: 1 }, options)).start(function () { | ||
_this3.props.onDrawerClose && _this3.props.onDrawerClose(); | ||
_this3._emitStateChanged(IDLE); | ||
}); | ||
} | ||
}, { | ||
key: '_handleDrawerOpen', | ||
decorators: [_autobindDecorator2.default], | ||
value: function _handleDrawerOpen() { | ||
this.props.onDrawerOpen && this.props.onDrawerOpen(); | ||
} | ||
}, { | ||
key: '_handleDrawerClose', | ||
decorators: [_autobindDecorator2.default], | ||
value: function _handleDrawerClose() { | ||
this.props.onDrawerClose && this.props.onDrawerClose(); | ||
} | ||
}, { | ||
key: '_shouldSetPanResponder', | ||
decorators: [_autobindDecorator2.default], | ||
value: function _shouldSetPanResponder(e, _ref2) { | ||
var moveX = _ref2.moveX; | ||
var dx = _ref2.dx; | ||
var dy = _ref2.dy; | ||
var drawerPosition = this.props.drawerPosition; | ||
if (_this4.props.onDrawerClose) { | ||
_this4.props.onDrawerClose();} | ||
_this4._emitStateChanged(IDLE);});} }, { key: '_handleDrawerOpen', value: function _handleDrawerOpen() | ||
{ | ||
if (this.props.onDrawerOpen) { | ||
this.props.onDrawerOpen();}} }, { key: '_handleDrawerClose', value: function _handleDrawerClose() | ||
{ | ||
if (this.props.onDrawerClose) { | ||
this.props.onDrawerClose();}} }, { key: '_shouldSetPanResponder', value: function _shouldSetPanResponder( | ||
e, _ref2) {var moveX = _ref2.moveX;var dx = _ref2.dx;var dy = _ref2.dy;var | ||
drawerPosition = this.props.drawerPosition; | ||
if (drawerPosition === 'left') { | ||
@@ -234,13 +178,13 @@ var overlayArea = DEVICE_WIDTH - (DEVICE_WIDTH - this.props.drawerWidth); | ||
this._closingAnchorValue = this._getOpenValueForX(moveX); | ||
return true; | ||
} | ||
} else { | ||
return true;}} else | ||
{ | ||
if (moveX <= 35 && dx > 0) { | ||
this._isClosing = false; | ||
return true; | ||
} else { | ||
return false; | ||
} | ||
} | ||
} else { | ||
return true;} | ||
return false;}} else | ||
{ | ||
var overlayArea = DEVICE_WIDTH - this.props.drawerWidth; | ||
@@ -252,49 +196,40 @@ | ||
this._closingAnchorValue = this._getOpenValueForX(moveX); | ||
return true; | ||
} | ||
} else { | ||
return true;}} else | ||
{ | ||
if (moveX >= DEVICE_WIDTH - 35 && dx < 0) { | ||
this._isClosing = false; | ||
return true; | ||
} else { | ||
return false; | ||
} | ||
} | ||
} | ||
} | ||
}, { | ||
key: '_panResponderGrant', | ||
decorators: [_autobindDecorator2.default], | ||
value: function _panResponderGrant() { | ||
this._emitStateChanged(DRAGGING); | ||
} | ||
}, { | ||
key: '_panResponderMove', | ||
decorators: [_autobindDecorator2.default], | ||
value: function _panResponderMove(e, _ref3) { | ||
var moveX = _ref3.moveX; | ||
return true;} | ||
return false;}}} }, { key: '_panResponderGrant', value: function _panResponderGrant() | ||
{ | ||
this._emitStateChanged(DRAGGING);} }, { key: '_panResponderMove', value: function _panResponderMove( | ||
e, _ref3) {var moveX = _ref3.moveX; | ||
var openValue = this._getOpenValueForX(moveX); | ||
if (this._isClosing) { | ||
openValue = 1 - (this._closingAnchorValue - openValue); | ||
} | ||
openValue = 1 - (this._closingAnchorValue - openValue);} | ||
if (openValue > 1) { | ||
openValue = 1; | ||
} else if (openValue < 0) { | ||
openValue = 0; | ||
} | ||
openValue = 1;} else | ||
if (openValue < 0) { | ||
openValue = 0;} | ||
this.state.openValue.setValue(openValue); | ||
} | ||
}, { | ||
key: '_panResponderRelease', | ||
decorators: [_autobindDecorator2.default], | ||
value: function _panResponderRelease(e, _ref4) { | ||
var moveX = _ref4.moveX; | ||
var vx = _ref4.vx; | ||
var drawerPosition = this.props.drawerPosition; | ||
var openValue = this.state.openValue; | ||
this.state.openValue.setValue(openValue);} }, { key: '_panResponderRelease', value: function _panResponderRelease( | ||
e, _ref4) {var moveX = _ref4.moveX;var vx = _ref4.vx;var | ||
drawerPosition = this.props.drawerPosition; | ||
var previouslyOpen = this._isClosing; | ||
@@ -305,60 +240,51 @@ var isWithinVelocityThreshold = vx < VX_MAX && vx > -VX_MAX; | ||
if (vx > 0 && moveX > THRESHOLD || vx >= VX_MAX || isWithinVelocityThreshold && previouslyOpen && moveX > THRESHOLD) { | ||
this.openDrawer({ velocity: vx }); | ||
} else if (vx < 0 && moveX < THRESHOLD || vx < -VX_MAX || isWithinVelocityThreshold && !previouslyOpen) { | ||
this.closeDrawer({ velocity: vx }); | ||
} else if (previouslyOpen) { | ||
this.openDrawer(); | ||
} else { | ||
this.closeDrawer(); | ||
} | ||
} else { | ||
this.openDrawer({ velocity: vx });} else | ||
if (vx < 0 && moveX < THRESHOLD || vx < -VX_MAX || isWithinVelocityThreshold && !previouslyOpen) { | ||
this.closeDrawer({ velocity: vx });} else | ||
if (previouslyOpen) { | ||
this.openDrawer();} else | ||
{ | ||
this.closeDrawer();}} | ||
if (drawerPosition === 'right') { | ||
if (vx < 0 && moveX < THRESHOLD || vx <= -VX_MAX || isWithinVelocityThreshold && previouslyOpen && moveX < THRESHOLD) { | ||
this.openDrawer({ velocity: -1 * vx }); | ||
} else if (vx > 0 && moveX > THRESHOLD || vx > VX_MAX || isWithinVelocityThreshold && !previouslyOpen) { | ||
this.closeDrawer({ velocity: -1 * vx }); | ||
} else if (previouslyOpen) { | ||
this.openDrawer(); | ||
} else { | ||
this.closeDrawer(); | ||
} | ||
} | ||
} | ||
}, { | ||
key: '_getOpenValueForX', | ||
value: function _getOpenValueForX(x) { | ||
var _props2 = this.props; | ||
var drawerPosition = _props2.drawerPosition; | ||
var drawerWidth = _props2.drawerWidth; | ||
this.openDrawer({ velocity: -1 * vx });} else | ||
if (vx > 0 && moveX > THRESHOLD || vx > VX_MAX || isWithinVelocityThreshold && !previouslyOpen) { | ||
this.closeDrawer({ velocity: -1 * vx });} else | ||
if (previouslyOpen) { | ||
this.openDrawer();} else | ||
{ | ||
this.closeDrawer();}}} }, { key: '_getOpenValueForX', value: function _getOpenValueForX( | ||
x) {var _props2 = | ||
this.props;var drawerPosition = _props2.drawerPosition;var drawerWidth = _props2.drawerWidth; | ||
if (drawerPosition === 'left') { | ||
return x / drawerWidth; | ||
} else if (drawerPosition === 'right') { | ||
return (DEVICE_WIDTH - x) / drawerWidth; | ||
} | ||
} | ||
}]); | ||
return x / drawerWidth;} else | ||
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 DrawerLayout; | ||
})(_reactNative2.default.Component); | ||
exports.default = DrawerLayout; | ||
var styles = _reactNative.StyleSheet.create({ | ||
drawer: { | ||
position: 'absolute', | ||
top: 0, | ||
bottom: 0 | ||
}, | ||
main: { | ||
flex: 1 | ||
}, | ||
overlay: { | ||
backgroundColor: '#000', | ||
position: 'absolute', | ||
top: 0, | ||
left: 0, | ||
bottom: 0, | ||
right: 0 | ||
} | ||
}); | ||
module.exports = exports.default; | ||
var styles = _reactNative.StyleSheet.create({ | ||
drawer: { | ||
position: 'absolute', | ||
top: 0, | ||
bottom: 0 }, | ||
main: { | ||
flex: 1 }, | ||
overlay: { | ||
backgroundColor: '#000', | ||
position: 'absolute', | ||
top: 0, | ||
left: 0, | ||
bottom: 0, | ||
right: 0 } }); |
@@ -1,8 +0,7 @@ | ||
var React = require('react-native'); | ||
var Platform = React.Platform; | ||
var React = require('react-native');var | ||
Platform = React.Platform; | ||
if (Platform.OS === 'android') { | ||
module.exports = require('./DrawerLayout.android'); | ||
} else if (Platform.OS === 'ios') { | ||
module.exports = require('./DrawerLayout.ios'); | ||
} | ||
module.exports = require('./DrawerLayout.android');} else | ||
if (Platform.OS === 'ios') { | ||
module.exports = require('./DrawerLayout.ios');} |
{ | ||
"name": "react-native-drawer-layout", | ||
"version": "0.3.1", | ||
"version": "0.3.3", | ||
"description": "", | ||
"main": "dist/index.js", | ||
"scripts": { | ||
"prepublish": "npm run build", | ||
"babel": "babel src --out-dir dist", | ||
"build": "npm run-script clear && npm run-script babel", | ||
"clear": "rm -rf dist/ && mkdir dist/", | ||
"babel": "babel *.js --out-dir dist" | ||
"prepublish": "npm run build", | ||
"test": "xo" | ||
}, | ||
@@ -15,23 +16,2 @@ "files": [ | ||
], | ||
"babel": { | ||
"whitelist": [ | ||
"es6.modules", | ||
"es6.arrowFunctions", | ||
"es6.blockScoping", | ||
"es6.classes", | ||
"es6.destructuring", | ||
"es6.parameters", | ||
"es6.properties.computed", | ||
"es6.properties.shorthand", | ||
"es6.spread", | ||
"es6.templateLiterals", | ||
"es6.constants", | ||
"es7.trailingFunctionCommas", | ||
"es7.objectRestSpread", | ||
"react", | ||
"es7.classProperties", | ||
"es7.asyncFunctions", | ||
"es7.decorators" | ||
] | ||
}, | ||
"repository": { | ||
@@ -46,3 +26,4 @@ "type": "git", | ||
"email": "marc@iodine.com" | ||
}, { | ||
}, | ||
{ | ||
"name": "Daniel Schmidt", | ||
@@ -53,2 +34,51 @@ "email": "daniel.maximilian@gmx.net", | ||
], | ||
"xo": { | ||
"ignores": [ | ||
"DrawerLayoutExample/**", | ||
"dist/*" | ||
], | ||
"esnext": true, | ||
"space": 2, | ||
"plugins": [ | ||
"react" | ||
], | ||
"rules": { | ||
"babel/object-curly-spacing": [ | ||
2, | ||
"always" | ||
], | ||
"comma-dangle": [ | ||
2, | ||
"always-multiline" | ||
], | ||
"react/jsx-curly-spacing": 2, | ||
"strict": [ | ||
2, | ||
"never" | ||
], | ||
"no-use-before-define": 0, | ||
"one-var": [ | ||
2, | ||
{ | ||
"uninitialized": "always", | ||
"initialized": "never" | ||
} | ||
], | ||
"react/no-set-state": 1, | ||
"react/prop-types": 2, | ||
"react/jsx-sort-prop-types": 2, | ||
"react/jsx-closing-bracket-location": [ | ||
2, | ||
{ | ||
"selfClosing": "after-props", | ||
"nonEmpty": "after-props" | ||
} | ||
], | ||
"react/jsx-indent-props": [ | ||
2, | ||
2 | ||
], | ||
"react/self-closing-comp": 2 | ||
} | ||
}, | ||
"keywords": [ | ||
@@ -65,7 +95,18 @@ "react", | ||
"dependencies": { | ||
"autobind-decorator": "^1.3.2" | ||
"autobind-decorator": "^1.3.2", | ||
"react-native-dismiss-keyboard": "0.0.2" | ||
}, | ||
"devDependencies": { | ||
"babel": "^5.8.34" | ||
"babel-cli": "^6.0.0", | ||
"babel-eslint": "^5.0.0-beta6", | ||
"babel-plugin-transform-decorators-legacy": "^1.3.4", | ||
"eslint": "^1.10.3", | ||
"eslint-config-xo": "^0.9.1", | ||
"eslint-plugin-babel": "^3.0.0", | ||
"eslint-plugin-no-empty-blocks": "0.0.2", | ||
"eslint-plugin-no-use-extend-native": "^0.3.3", | ||
"eslint-plugin-react": "^3.13.1", | ||
"react-native": "^0.17.0", | ||
"xo": "^0.12.1" | ||
} | ||
} |
@@ -1,2 +0,2 @@ | ||
## react-native-drawer-layout | ||
## react-native-drawer-layout [![Circle CI](https://circleci.com/gh/iodine/react-native-drawer-layout.svg?style=svg)](https://circleci.com/gh/iodine/react-native-drawer-layout) | ||
@@ -15,3 +15,6 @@ 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. | ||
## Support | ||
We currently support `react-native >= 0.11`, if you experience any restrictions, please let us know. | ||
## Release Notes | ||
@@ -23,1 +26,5 @@ | ||
- The StatusBar is no longer dimmed by sliding the drawer layout automatically. To avoid this change you may use [StatusBarIOS.setHidden](https://facebook.github.io/react-native/docs/statusbarios.html#sethidden) in the [onDrawerSlide](https://facebook.github.io/react-native/docs/drawerlayoutandroid.html#ondrawerslide) callback. | ||
## Contribution | ||
Please make sure to run the tests before proposing a PR by running `npm test`. |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
18219
29
2
11
186
2
+ Addedreact-native-dismiss-keyboard@0.0.2(transitive)