nuke-components
Advanced tools
Comparing version 0.2.6 to 0.2.7
# Changelog | ||
## 0.2.7 / 2017-02-17 | ||
* [[78d753a](http://gitlab.alibaba-inc.com/nuke/components/commit/78d753a336eab855400e52f2021bf0373bb7c0a8)] - `feat` resetLoadmore | ||
* [[d67a50c](http://gitlab.alibaba-inc.com/nuke/components/commit/d67a50c35a9deca945c02ab7b0b97c5bbf49292a)] - `feat` add reset loadmore | ||
## 0.2.6 / 2017-02-17 | ||
@@ -5,0 +10,0 @@ |
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
value: true | ||
}); | ||
@@ -38,155 +38,157 @@ | ||
var Cell = function (_PureComponent) { | ||
_inherits(Cell, _PureComponent); | ||
_inherits(Cell, _PureComponent); | ||
function Cell() { | ||
_classCallCheck(this, Cell); | ||
function Cell() { | ||
_classCallCheck(this, Cell); | ||
return _possibleConstructorReturn(this, (Cell.__proto__ || Object.getPrototypeOf(Cell)).apply(this, arguments)); | ||
} | ||
_createClass(Cell, [{ | ||
key: 'render', | ||
value: function render() { | ||
if (_nukeEnv.isWeex && this.context.isInARecyclerView) { | ||
return (0, _rax.createElement)('cell', _extends({}, this.props, { append: 'tree' })); | ||
} else { | ||
return (0, _rax.createElement)(_view2.default, this.props); | ||
} | ||
return _possibleConstructorReturn(this, (Cell.__proto__ || Object.getPrototypeOf(Cell)).apply(this, arguments)); | ||
} | ||
}]); | ||
return Cell; | ||
_createClass(Cell, [{ | ||
key: 'render', | ||
value: function render() { | ||
if (_nukeEnv.isWeex && this.context.isInARecyclerView) { | ||
return (0, _rax.createElement)('cell', _extends({}, this.props, { append: 'tree' })); | ||
} else { | ||
return (0, _rax.createElement)(_view2.default, this.props); | ||
} | ||
} | ||
}]); | ||
return Cell; | ||
}(_rax.PureComponent); | ||
Cell.contextTypes = { | ||
isInARecyclerView: _rax.PropTypes.bool | ||
isInARecyclerView: _rax.PropTypes.bool | ||
}; | ||
var Header = function (_PureComponent2) { | ||
_inherits(Header, _PureComponent2); | ||
_inherits(Header, _PureComponent2); | ||
function Header() { | ||
_classCallCheck(this, Header); | ||
function Header() { | ||
_classCallCheck(this, Header); | ||
return _possibleConstructorReturn(this, (Header.__proto__ || Object.getPrototypeOf(Header)).apply(this, arguments)); | ||
} | ||
_createClass(Header, [{ | ||
key: 'render', | ||
value: function render() { | ||
if (_nukeEnv.isWeex && this.context.isInARecyclerView) { | ||
return (0, _rax.createElement)('header', _extends({}, this.props, { append: 'tree' })); | ||
} else { | ||
return (0, _rax.createElement)(_view2.default, this.props); | ||
} | ||
return _possibleConstructorReturn(this, (Header.__proto__ || Object.getPrototypeOf(Header)).apply(this, arguments)); | ||
} | ||
}]); | ||
return Header; | ||
_createClass(Header, [{ | ||
key: 'render', | ||
value: function render() { | ||
if (_nukeEnv.isWeex && this.context.isInARecyclerView) { | ||
return (0, _rax.createElement)('header', _extends({}, this.props, { append: 'tree' })); | ||
} else { | ||
return (0, _rax.createElement)(_view2.default, this.props); | ||
} | ||
} | ||
}]); | ||
return Header; | ||
}(_rax.PureComponent); | ||
Header.contextTypes = { | ||
isInARecyclerView: _rax.PropTypes.bool | ||
isInARecyclerView: _rax.PropTypes.bool | ||
}; | ||
var RecyclerView = function (_Component) { | ||
_inherits(RecyclerView, _Component); | ||
_inherits(RecyclerView, _Component); | ||
function RecyclerView() { | ||
var _ref; | ||
function RecyclerView() { | ||
var _ref; | ||
var _temp, _this3, _ret; | ||
var _temp, _this3, _ret; | ||
_classCallCheck(this, RecyclerView); | ||
_classCallCheck(this, RecyclerView); | ||
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { | ||
args[_key] = arguments[_key]; | ||
} | ||
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { | ||
args[_key] = arguments[_key]; | ||
} | ||
return _ret = (_temp = (_this3 = _possibleConstructorReturn(this, (_ref = RecyclerView.__proto__ || Object.getPrototypeOf(RecyclerView)).call.apply(_ref, [this].concat(args))), _this3), _this3.resetLoadmore = function () {}, _this3.scrollTo = function (options) { | ||
return _ret = (_temp = (_this3 = _possibleConstructorReturn(this, (_ref = RecyclerView.__proto__ || Object.getPrototypeOf(RecyclerView)).call.apply(_ref, [this].concat(args))), _this3), _this3.resetLoadmore = function () { | ||
_this3.refs['scrollview'].resetLoadmore && _this3.refs['scrollview'].resetLoadmore(); | ||
}, _this3.scrollTo = function (options) { | ||
var x = parseInt(options.x); | ||
var y = parseInt(options.y); | ||
var x = parseInt(options.x); | ||
var y = parseInt(options.y); | ||
if (_nukeEnv.isWeex) { | ||
var dom = require('@weex-module/dom'); | ||
var firstCell = (0, _rax.findDOMNode)(_this3.refs.cell0); | ||
dom.scrollToElement(firstCell.ref, { | ||
offset: x || y || 0 | ||
}); | ||
} else { | ||
_this3.refs.scrollview.scrollTo(options); | ||
} | ||
}, _temp), _possibleConstructorReturn(_this3, _ret); | ||
} | ||
_createClass(RecyclerView, [{ | ||
key: 'getChildContext', | ||
value: function getChildContext() { | ||
return { | ||
isInARecyclerView: true | ||
}; | ||
if (_nukeEnv.isWeex) { | ||
var dom = require('@weex-module/dom'); | ||
var firstCell = (0, _rax.findDOMNode)(_this3.refs.cell0); | ||
dom.scrollToElement(firstCell.ref, { | ||
offset: x || y || 0 | ||
}); | ||
} else { | ||
_this3.refs.scrollview.scrollTo(options); | ||
} | ||
}, _temp), _possibleConstructorReturn(_this3, _ret); | ||
} | ||
}, { | ||
key: 'render', | ||
value: function render() { | ||
var props = this.props; | ||
_createClass(RecyclerView, [{ | ||
key: 'getChildContext', | ||
value: function getChildContext() { | ||
return { | ||
isInARecyclerView: true | ||
}; | ||
} | ||
}, { | ||
key: 'render', | ||
value: function render() { | ||
if (_nukeEnv.isWeex) { | ||
var props = this.props; | ||
var children = props.children; | ||
if (!Array.isArray(children)) { | ||
children = [children]; | ||
} | ||
if (_nukeEnv.isWeex) { | ||
var cells = children.map(function (child, index) { | ||
if (child) { | ||
var ref = 'cell' + index; | ||
if (props._autoWrapCell && child.type != _refreshControl2.default) { | ||
if (child.key) return (0, _rax.createElement)( | ||
Cell, | ||
{ ref: ref, key: child.key }, | ||
child | ||
);else { | ||
var children = props.children; | ||
if (!Array.isArray(children)) { | ||
children = [children]; | ||
} | ||
var cells = children.map(function (child, index) { | ||
if (child) { | ||
var ref = 'cell' + index; | ||
if (props._autoWrapCell && child.type != _refreshControl2.default) { | ||
if (child.key) return (0, _rax.createElement)( | ||
Cell, | ||
{ ref: ref, key: child.key }, | ||
child | ||
);else { | ||
return (0, _rax.createElement)( | ||
Cell, | ||
{ ref: ref }, | ||
child | ||
); | ||
} | ||
} else { | ||
return (0, _rax.cloneElement)(child, { ref: ref }); | ||
} | ||
} else { | ||
return null; | ||
} | ||
}); | ||
return (0, _rax.createElement)( | ||
Cell, | ||
{ ref: ref }, | ||
child | ||
'list', | ||
{ | ||
id: props.id, | ||
ref: 'scrollview', | ||
style: props.style, | ||
onLoadmore: props.onEndReached, | ||
loadmoreoffset: props.onEndReachedThreshold, | ||
showScrollbar: props.showScrollbar | ||
}, | ||
cells | ||
); | ||
} | ||
} else { | ||
return (0, _rax.cloneElement)(child, { ref: ref }); | ||
return (0, _rax.createElement)(_scrollView2.default, _extends({}, props, { ref: 'scrollview' })); | ||
} | ||
} else { | ||
return null; | ||
} | ||
}); | ||
} | ||
}]); | ||
return (0, _rax.createElement)( | ||
'list', | ||
{ | ||
id: props.id, | ||
ref: props.id, | ||
style: props.style, | ||
onLoadmore: props.onEndReached, | ||
loadmoreoffset: props.onEndReachedThreshold, | ||
showScrollbar: props.showScrollbar | ||
}, | ||
cells | ||
); | ||
} else { | ||
return (0, _rax.createElement)(_scrollView2.default, _extends({}, props, { ref: 'scrollview' })); | ||
} | ||
} | ||
}]); | ||
return RecyclerView; | ||
return RecyclerView; | ||
}(_rax.Component); | ||
RecyclerView.defaultProps = { | ||
onEndReachedThreshold: DEFAULT_END_REACHED_THRESHOLD | ||
onEndReachedThreshold: DEFAULT_END_REACHED_THRESHOLD | ||
}; | ||
RecyclerView.childContextTypes = { | ||
isInARecyclerView: _rax.PropTypes.bool | ||
isInARecyclerView: _rax.PropTypes.bool | ||
}; | ||
@@ -193,0 +195,0 @@ |
{ | ||
"name": "nuke-components", | ||
"version": "0.2.6", | ||
"version": "0.2.7", | ||
"description": "nuke原件库", | ||
@@ -5,0 +5,0 @@ "main": "lib/index", |
@@ -12,27 +12,27 @@ /* @jsx createElement */ | ||
class Cell extends PureComponent { | ||
static contextTypes = { | ||
isInARecyclerView: PropTypes.bool | ||
}; | ||
static contextTypes = { | ||
isInARecyclerView: PropTypes.bool | ||
}; | ||
render() { | ||
if (isWeex && this.context.isInARecyclerView) { | ||
return <cell {...this.props} append="tree" />; | ||
} else { | ||
return <View {...this.props} />; | ||
render() { | ||
if (isWeex && this.context.isInARecyclerView) { | ||
return <cell {...this.props} append="tree" />; | ||
} else { | ||
return <View {...this.props} />; | ||
} | ||
} | ||
} | ||
} | ||
class Header extends PureComponent { | ||
static contextTypes = { | ||
isInARecyclerView: PropTypes.bool | ||
}; | ||
static contextTypes = { | ||
isInARecyclerView: PropTypes.bool | ||
}; | ||
render() { | ||
if (isWeex && this.context.isInARecyclerView) { | ||
return <header {...this.props} append="tree" />; | ||
} else { | ||
return <View {...this.props} />; | ||
render() { | ||
if (isWeex && this.context.isInARecyclerView) { | ||
return <header {...this.props} append="tree" />; | ||
} else { | ||
return <View {...this.props} />; | ||
} | ||
} | ||
} | ||
} | ||
@@ -42,84 +42,82 @@ | ||
static defaultProps = { | ||
onEndReachedThreshold: DEFAULT_END_REACHED_THRESHOLD, | ||
}; | ||
static defaultProps = { | ||
onEndReachedThreshold: DEFAULT_END_REACHED_THRESHOLD, | ||
}; | ||
static childContextTypes = { | ||
isInARecyclerView: PropTypes.bool | ||
}; | ||
getChildContext() { | ||
return { | ||
isInARecyclerView: true | ||
static childContextTypes = { | ||
isInARecyclerView: PropTypes.bool | ||
}; | ||
} | ||
resetLoadmore=()=>{ | ||
console.log(this); | ||
console.log(findDOMNode(this.refs.niubi)); | ||
// this.refs.[this.props.id].resetLoadmore(); | ||
} | ||
getChildContext() { | ||
return { | ||
isInARecyclerView: true | ||
}; | ||
} | ||
scrollTo = (options) => { | ||
resetLoadmore=()=>{ | ||
this.refs['scrollview'].resetLoadmore && this.refs['scrollview'].resetLoadmore(); | ||
} | ||
let x = parseInt(options.x); | ||
let y = parseInt(options.y); | ||
scrollTo = (options) => { | ||
if (isWeex) { | ||
let dom = require('@weex-module/dom'); | ||
let firstCell = findDOMNode(this.refs.cell0); | ||
dom.scrollToElement(firstCell.ref, { | ||
offset: x || y || 0 | ||
}); | ||
} else { | ||
this.refs.scrollview.scrollTo(options); | ||
let x = parseInt(options.x); | ||
let y = parseInt(options.y); | ||
if (isWeex) { | ||
let dom = require('@weex-module/dom'); | ||
let firstCell = findDOMNode(this.refs.cell0); | ||
dom.scrollToElement(firstCell.ref, { | ||
offset: x || y || 0 | ||
}); | ||
} else { | ||
this.refs.scrollview.scrollTo(options); | ||
} | ||
} | ||
} | ||
render() { | ||
render() { | ||
let props = this.props; | ||
let props = this.props; | ||
if (isWeex) { | ||
if (isWeex) { | ||
let children = props.children; | ||
if (!Array.isArray(children)) { | ||
children = [children]; | ||
} | ||
let children = props.children; | ||
if (!Array.isArray(children)) { | ||
children = [children]; | ||
} | ||
let cells = children.map((child, index) => { | ||
if (child) { | ||
const ref = 'cell' + index; | ||
if (props._autoWrapCell && child.type != RefreshControl) { | ||
if(child.key) | ||
return <Cell ref={ref} key={child.key}>{child}</Cell>; | ||
else { | ||
return <Cell ref={ref}>{child}</Cell>; | ||
} | ||
} else { | ||
return cloneElement(child, {ref}); | ||
} | ||
let cells = children.map((child, index) => { | ||
if (child) { | ||
const ref = 'cell' + index; | ||
if (props._autoWrapCell && child.type != RefreshControl) { | ||
if(child.key) | ||
return <Cell ref={ref} key={child.key}>{child}</Cell>; | ||
else { | ||
return <Cell ref={ref}>{child}</Cell>; | ||
} | ||
} else { | ||
return cloneElement(child, {ref}); | ||
} | ||
} else { | ||
return null; | ||
} | ||
}); | ||
return ( | ||
<list | ||
id={props.id} | ||
ref="scrollview" | ||
style={props.style} | ||
onLoadmore={props.onEndReached} | ||
loadmoreoffset={props.onEndReachedThreshold} | ||
showScrollbar={props.showScrollbar} | ||
> | ||
{cells} | ||
</list> | ||
); | ||
} else { | ||
return null; | ||
return ( | ||
<ScrollView {...props} ref="scrollview" /> | ||
); | ||
} | ||
}); | ||
return ( | ||
<list | ||
id={props.id} | ||
ref={props.id} | ||
style={props.style} | ||
onLoadmore={props.onEndReached} | ||
loadmoreoffset={props.onEndReachedThreshold} | ||
showScrollbar={props.showScrollbar} | ||
> | ||
{cells} | ||
</list> | ||
); | ||
} else { | ||
return ( | ||
<ScrollView {...props} ref="scrollview" /> | ||
); | ||
} | ||
} | ||
} | ||
@@ -126,0 +124,0 @@ |
106877