You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

rc-drawer

Package Overview
Dependencies
Maintainers
1
Versions
136
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rc-drawer - npm Package Compare versions

Comparing version

to
0.4.2

197

lib/Drawer.js

@@ -11,4 +11,2 @@ 'use strict';

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 _react = require('react');

@@ -28,2 +26,4 @@

function _defaults(obj, defaults) { var keys = Object.getOwnPropertyNames(defaults); for (var i = 0; i < keys.length; i++) { var key = keys[i]; var value = Object.getOwnPropertyDescriptor(defaults, key); if (value && value.configurable && obj[key] === undefined) { Object.defineProperty(obj, key, value); } } return obj; }
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; }

@@ -35,3 +35,3 @@

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 _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) : _defaults(subClass, superClass); }

@@ -58,3 +58,3 @@ function getOffset(ele) {

var _this = _possibleConstructorReturn(this, Object.getPrototypeOf(Drawer).call(this, props));
var _this = _possibleConstructorReturn(this, _React$Component.call(this, props));

@@ -301,120 +301,117 @@ _this.onOverlayClicked = function () {

_createClass(Drawer, [{
key: 'componentDidMount',
value: function componentDidMount() {
Drawer.prototype.componentDidMount = function componentDidMount() {
this.saveSidebarSize();
};
Drawer.prototype.componentDidUpdate = function componentDidUpdate() {
// filter out the updates when we're touching
if (!this.isTouching()) {
this.saveSidebarSize();
}
}, {
key: 'componentDidUpdate',
value: function componentDidUpdate() {
// filter out the updates when we're touching
if (!this.isTouching()) {
this.saveSidebarSize();
}
}
};
// This logic helps us prevents the user from sliding the sidebar horizontally
// while scrolling the sidebar vertically. When a scroll event comes in, we're
// cancelling the ongoing gesture if it did not move horizontally much.
// This logic helps us prevents the user from sliding the sidebar horizontally
// while scrolling the sidebar vertically. When a scroll event comes in, we're
// cancelling the ongoing gesture if it did not move horizontally much.
// True if the on going gesture X distance is less than the cancel distance
// True if the on going gesture X distance is less than the cancel distance
// calculate the sidebarWidth based on current touch info
// calculate the sidebarWidth based on current touch info
// calculate the sidebarHeight based on current touch info
// calculate the sidebarHeight based on current touch info
}, {
key: 'render',
value: function render() {
var _rootCls;
var _props = this.props;
var className = _props.className;
var prefixCls = _props.prefixCls;
var position = _props.position;
var transitions = _props.transitions;
var touch = _props.touch;
var enableDragHandle = _props.enableDragHandle;
var sidebar = _props.sidebar;
var children = _props.children;
var docked = _props.docked;
var open = _props.open;
Drawer.prototype.render = function render() {
var _rootCls;
var _props = this.props;
var className = _props.className;
var prefixCls = _props.prefixCls;
var position = _props.position;
var transitions = _props.transitions;
var touch = _props.touch;
var enableDragHandle = _props.enableDragHandle;
var sidebar = _props.sidebar;
var children = _props.children;
var docked = _props.docked;
var open = _props.open;
var sidebarStyle = _extends({}, this.props.sidebarStyle);
var contentStyle = _extends({}, this.props.contentStyle);
var overlayStyle = _extends({}, this.props.overlayStyle);
var rootCls = (_rootCls = {}, _defineProperty(_rootCls, className, !!className), _defineProperty(_rootCls, prefixCls, true), _defineProperty(_rootCls, prefixCls + '-' + position, true), _rootCls);
var sidebarStyle = _extends({}, this.props.sidebarStyle);
var contentStyle = _extends({}, this.props.contentStyle);
var overlayStyle = _extends({}, this.props.overlayStyle);
var rootProps = {};
var isTouching = this.isTouching();
var rootCls = (_rootCls = {}, _defineProperty(_rootCls, className, !!className), _defineProperty(_rootCls, prefixCls, true), _defineProperty(_rootCls, prefixCls + '-' + position, true), _rootCls);
if (isTouching) {
this.renderStyle({ sidebarStyle: sidebarStyle, isTouching: true, overlayStyle: overlayStyle });
} else if (docked) {
if (this.state.sidebarWidth !== 0) {
rootCls[prefixCls + '-docked'] = true;
this.renderStyle({ sidebarStyle: sidebarStyle, contentStyle: contentStyle });
}
} else if (open) {
rootCls[prefixCls + '-open'] = true;
this.renderStyle({ sidebarStyle: sidebarStyle });
overlayStyle.opacity = 1;
overlayStyle.visibility = 'visible';
}
var rootProps = {};
var isTouching = this.isTouching();
if (isTouching || !transitions) {
sidebarStyle.transition = 'none';
sidebarStyle.WebkitTransition = 'none';
contentStyle.transition = 'none';
overlayStyle.transition = 'none';
if (isTouching) {
this.renderStyle({ sidebarStyle: sidebarStyle, isTouching: true, overlayStyle: overlayStyle });
} else if (docked) {
if (this.state.sidebarWidth !== 0) {
rootCls[prefixCls + '-docked'] = true;
this.renderStyle({ sidebarStyle: sidebarStyle, contentStyle: contentStyle });
}
} else if (open) {
rootCls[prefixCls + '-open'] = true;
this.renderStyle({ sidebarStyle: sidebarStyle });
overlayStyle.opacity = 1;
overlayStyle.visibility = 'visible';
}
var dragHandle = null;
if (isTouching || !transitions) {
sidebarStyle.transition = 'none';
sidebarStyle.WebkitTransition = 'none';
contentStyle.transition = 'none';
overlayStyle.transition = 'none';
}
if (this.state.touchSupported && touch) {
if (open) {
rootProps.onTouchStart = this.onTouchStart;
rootProps.onTouchMove = this.onTouchMove;
rootProps.onTouchEnd = this.onTouchEnd;
rootProps.onTouchCancel = this.onTouchEnd;
rootProps.onScroll = this.onScroll;
} else if (enableDragHandle) {
dragHandle = _react2["default"].createElement('div', { className: prefixCls + '-draghandle', style: this.props.dragHandleStyle,
onTouchStart: this.onTouchStart, onTouchMove: this.onTouchMove,
onTouchEnd: this.onTouchEnd, onTouchCancel: this.onTouchEnd,
ref: 'dragHandle'
});
}
var dragHandle = null;
if (this.state.touchSupported && touch) {
if (open) {
rootProps.onTouchStart = this.onTouchStart;
rootProps.onTouchMove = this.onTouchMove;
rootProps.onTouchEnd = this.onTouchEnd;
rootProps.onTouchCancel = this.onTouchEnd;
rootProps.onScroll = this.onScroll;
} else if (enableDragHandle) {
dragHandle = _react2["default"].createElement('div', { className: prefixCls + '-draghandle', style: this.props.dragHandleStyle,
onTouchStart: this.onTouchStart, onTouchMove: this.onTouchMove,
onTouchEnd: this.onTouchEnd, onTouchCancel: this.onTouchEnd,
ref: 'dragHandle'
});
}
}
return _react2["default"].createElement(
return _react2["default"].createElement(
'div',
_extends({ className: (0, _classnames2["default"])(rootCls) }, rootProps),
_react2["default"].createElement(
'div',
_extends({ className: (0, _classnames2["default"])(rootCls) }, rootProps),
_react2["default"].createElement(
'div',
{ className: prefixCls + '-sidebar', style: sidebarStyle,
ref: 'sidebar'
},
sidebar
),
_react2["default"].createElement('div', { className: prefixCls + '-overlay', style: overlayStyle,
onClick: this.onOverlayClicked,
onTouchTap: this.onOverlayClicked,
ref: 'overlay'
}),
_react2["default"].createElement(
'div',
{ className: prefixCls + '-content', style: contentStyle,
ref: 'content'
},
dragHandle,
children
)
);
}
}]);
{ className: prefixCls + '-sidebar', style: sidebarStyle,
ref: 'sidebar'
},
sidebar
),
_react2["default"].createElement('div', { className: prefixCls + '-overlay',
style: overlayStyle,
role: 'presentation',
tabIndex: '0',
onClick: this.onOverlayClicked,
ref: 'overlay'
}),
_react2["default"].createElement(
'div',
{ className: prefixCls + '-content', style: contentStyle,
ref: 'content'
},
dragHandle,
children
)
);
};

@@ -421,0 +418,0 @@ return Drawer;

{
"name": "rc-drawer",
"version": "0.4.1",
"version": "0.4.2",
"description": "drawer ui component for react",

@@ -43,5 +43,5 @@ "keywords": [

"rc-tools": "5.x",
"react": "0.14.x",
"react-addons-test-utils": "0.14.x",
"react-dom": "0.14.x"
"react": "15.x",
"react-addons-test-utils": "15.x",
"react-dom": "15.x"
},

@@ -48,0 +48,0 @@ "pre-commit": [