nuke-scroll-view
Advanced tools
Comparing version 2.0.0 to 2.0.1
@@ -1,39 +0,42 @@ | ||
# Changelog | ||
# Changelog | ||
## 2.0.1 / 2018-03-27 | ||
## 2.0.0 / 2018-03-22 | ||
* [[a69ad27](http://gitlab.alibaba-inc.com/nuke/scroll-view/commit/a69ad27474935ae068c8e8fb44b4f94398e7ea06)] - `fix` fix children split error | ||
* [[5460c54](http://gitlab.alibaba-inc.com/nuke/scroll-view/commit/5460c547e726421177082a063233b9a414886e94)] - `feat` update dependencies | ||
* [[c27e41d](http://gitlab.alibaba-inc.com/nuke/scroll-view/commit/c27e41de285ac49bf061f3683f936927e70f17f0)] - `docs` add demo | ||
## 2.0.0 / 2018-03-22 | ||
## 1.0.4 / 2017-12-21 | ||
* [[5460c54](http://gitlab.alibaba-inc.com/nuke/scroll-view/commit/5460c547e726421177082a063233b9a414886e94)] - `feat` update dependencies | ||
* [[c27e41d](http://gitlab.alibaba-inc.com/nuke/scroll-view/commit/c27e41de285ac49bf061f3683f936927e70f17f0)] - `docs` add demo | ||
* [[11028ef](http://gitlab.alibaba-inc.com/nuke/scroll-view/commit/11028ef8fca7705ec47e0c4d3787e06e8ad8833e)] - `fix` dependency lost | ||
* [[250952c](http://gitlab.alibaba-inc.com/nuke/scroll-view/commit/250952ca66cf84582ed0384f6bc5a5e7580929f6)] - `fix` compat style height lose | ||
## 1.0.4 / 2017-12-21 | ||
## 1.0.3 / 2017-11-28 | ||
* [[11028ef](http://gitlab.alibaba-inc.com/nuke/scroll-view/commit/11028ef8fca7705ec47e0c4d3787e06e8ad8833e)] - `fix` dependency lost | ||
* [[250952c](http://gitlab.alibaba-inc.com/nuke/scroll-view/commit/250952ca66cf84582ed0384f6bc5a5e7580929f6)] - `fix` compat style height lose | ||
* [[1aeecb9](http://gitlab.alibaba-inc.com/nuke/scroll-view/commit/1aeecb93f2770596ffd52a980b8c48212cc76b11)] - `fix` onScoll event los & add resetLoadmore | ||
## 1.0.3 / 2017-11-28 | ||
## 1.0.1 / 2017-11-23 | ||
* [[1aeecb9](http://gitlab.alibaba-inc.com/nuke/scroll-view/commit/1aeecb93f2770596ffd52a980b8c48212cc76b11)] - `fix` onScoll event los & add resetLoadmore | ||
* [[54e1a9e](http://gitlab.alibaba-inc.com/nuke/scroll-view/commit/54e1a9e1deac0f76120fc830d557a6e59797b7a3)] - `fix` if there's no refreshControl | ||
* [[868dda9](http://gitlab.alibaba-inc.com/nuke/scroll-view/commit/868dda91d8e8140025a956402784b9adc815f81d)] - `feat` replace hammerjs | ||
* [[8806919](http://gitlab.alibaba-inc.com/nuke/scroll-view/commit/8806919e61bb2bcf26470632cf3310360526f123)] - `fix` use type.displayName to replace type compare | ||
* [[b662bee](http://gitlab.alibaba-inc.com/nuke/scroll-view/commit/b662beecf6272a8e3f6b4c017f361097dc7cb752)] - `fix` basic logic done | ||
## 1.0.1 / 2017-11-23 | ||
## 1.0.0 / 2017-11-04 | ||
* [[54e1a9e](http://gitlab.alibaba-inc.com/nuke/scroll-view/commit/54e1a9e1deac0f76120fc830d557a6e59797b7a3)] - `fix` if there's no refreshControl | ||
* [[868dda9](http://gitlab.alibaba-inc.com/nuke/scroll-view/commit/868dda91d8e8140025a956402784b9adc815f81d)] - `feat` replace hammerjs | ||
* [[8806919](http://gitlab.alibaba-inc.com/nuke/scroll-view/commit/8806919e61bb2bcf26470632cf3310360526f123)] - `fix` use type.displayName to replace type compare | ||
* [[b662bee](http://gitlab.alibaba-inc.com/nuke/scroll-view/commit/b662beecf6272a8e3f6b4c017f361097dc7cb752)] - `fix` basic logic done | ||
* [[1eadac1](http://gitlab.alibaba-inc.com/nuke/scroll-view/commit/1eadac196df8cd5bdf290fa34a63ac58d561296d)] - `feat` view dependency update | ||
## 1.0.0 / 2017-11-04 | ||
## 0.0.3 / 2017-06-16 | ||
* [[1eadac1](http://gitlab.alibaba-inc.com/nuke/scroll-view/commit/1eadac196df8cd5bdf290fa34a63ac58d561296d)] - `feat` view dependency update | ||
* [[db0444d](http://gitlab.alibaba-inc.com/nuke/scroll-view/commit/db0444da70f0b94bcc665b6f600732eae33938dc)] - `fix` fix h5 pull to refresh | ||
## 0.0.3 / 2017-06-16 | ||
## 0.0.2 / 2017-05-25 | ||
* [[db0444d](http://gitlab.alibaba-inc.com/nuke/scroll-view/commit/db0444da70f0b94bcc665b6f600732eae33938dc)] - `fix` fix h5 pull to refresh | ||
* [[75e1636](http://gitlab.alibaba-inc.com/nuke/scroll-view/commit/75e16362fc21c29d0ed0aa1a97a2b0db0cb91094)] - `docs` pub docs | ||
## 0.0.2 / 2017-05-25 | ||
## 0.0.1 / 2017-05-10 | ||
* [[75e1636](http://gitlab.alibaba-inc.com/nuke/scroll-view/commit/75e16362fc21c29d0ed0aa1a97a2b0db0cb91094)] - `docs` pub docs | ||
* [[62b8ca5](http://gitlab.alibaba-inc.com/nuke/scroll-view/commit/62b8ca5dddb1ad22ab4ba65b9b62b870586978a3)] - `feat` first init | ||
## 0.0.1 / 2017-05-10 | ||
* [[62b8ca5](http://gitlab.alibaba-inc.com/nuke/scroll-view/commit/62b8ca5dddb1ad22ab4ba65b9b62b870586978a3)] - `feat` first init |
100
lib/index.js
@@ -36,2 +36,4 @@ 'use strict'; | ||
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
@@ -61,9 +63,9 @@ | ||
var ScrollViewTest = function (_Component) { | ||
_inherits(ScrollViewTest, _Component); | ||
var ScrollView = function (_Component) { | ||
_inherits(ScrollView, _Component); | ||
function ScrollViewTest(props) { | ||
_classCallCheck(this, ScrollViewTest); | ||
function ScrollView(props) { | ||
_classCallCheck(this, ScrollView); | ||
var _this = _possibleConstructorReturn(this, (ScrollViewTest.__proto__ || Object.getPrototypeOf(ScrollViewTest)).call(this, props)); | ||
var _this = _possibleConstructorReturn(this, (ScrollView.__proto__ || Object.getPrototypeOf(ScrollView)).call(this, props)); | ||
@@ -175,6 +177,34 @@ _this.lastScrollDistance = 0; | ||
_createClass(ScrollViewTest, [{ | ||
_createClass(ScrollView, [{ | ||
key: 'splitChildren', | ||
value: function splitChildren() { | ||
var _this2 = this; | ||
var children = this.props.children; | ||
var contents = []; | ||
var headerContent = void 0; | ||
var refreshContent = void 0; | ||
if (Array.isArray(children)) { | ||
children.map(function (child, index) { | ||
if (child && child.type && child.type.displayName === _nukeRefreshControl2.default.displayName) { | ||
refreshContent = child; | ||
// format to px | ||
_this2.refreshHeight = child.props.style && child.props.style.height && formatRemToPx(child.props.style.height) || 80; | ||
_this2.onRefresh = child.props.onRefresh; | ||
} else { | ||
contents.push(child); | ||
} | ||
}); | ||
} | ||
this.childrenAll = { | ||
contents: contents, | ||
headerContent: headerContent, | ||
refreshContent: refreshContent | ||
}; | ||
} | ||
}, { | ||
key: 'render', | ||
value: function render() { | ||
var _this2 = this; | ||
var _this3 = this; | ||
@@ -190,3 +220,4 @@ var _props = this.props, | ||
onScroll = _props.onScroll, | ||
children = _props.children; | ||
children = _props.children, | ||
horizontal = _props.horizontal; | ||
@@ -197,6 +228,6 @@ // In weex must be int value | ||
var contentContainerStyle = [this.props.horizontal && styles.contentContainerHorizontal, this.props.contentContainerStyle]; | ||
var contentContainerStyle = [horizontal && styles.contentContainerHorizontal, this.props.contentContainerStyle]; | ||
// bugfix: fix scrollview flex in ios 78 | ||
if (!isWeex && !this.props.horizontal) { | ||
if (!isWeex && !horizontal) { | ||
contentContainerStyle.push(styles.containerWebStyle); | ||
@@ -207,3 +238,3 @@ } | ||
var childLayoutProps = ['alignItems', 'justifyContent'].filter(function (prop) { | ||
return _this2.props.style[prop] !== undefined; | ||
return _this3.props.style[prop] !== undefined; | ||
}); | ||
@@ -216,30 +247,21 @@ | ||
var refreshContainer = null; | ||
var contentChild = void 0; | ||
if (Array.isArray(children)) { | ||
contentChild = children.map(function (child, index) { | ||
if (child && child.type && child.type.displayName == _nukeRefreshControl2.default.displayName) { | ||
refreshContainer = child; | ||
// format to px | ||
_this2.refreshHeight = child.props.style && child.props.style.height && formatRemToPx(child.props.style.height) || 80; | ||
_this2.onRefresh = child.props.onRefresh; | ||
} else { | ||
return child; | ||
} | ||
}); | ||
} else { | ||
contentChild = children; | ||
} | ||
this.splitChildren(); | ||
var contentChild = this.childrenAll.contents; | ||
var refreshContent = this.childrenAll.refreshContent; | ||
var contentContainer = (0, _rax.createElement)( | ||
_nukeView2.default, | ||
{ ref: 'contentContainer', style: contentContainerStyle }, | ||
{ | ||
x: 'contentContainer', | ||
ref: 'contentContainer', | ||
style: contentContainerStyle | ||
}, | ||
contentChild | ||
); | ||
var baseStyle = this.props.horizontal ? styles.baseHorizontal : styles.baseVertical; | ||
var baseStyle = horizontal ? styles.horizontal : styles.vertical; | ||
var scrollerStyle = _extends({}, baseStyle, this.props.style); | ||
var scrollerStyle = Object.assign.apply(Object, [{}, horizontal ? styles.horizontal : styles.vertical].concat(_toConsumableArray(this.props.style))); | ||
var showsScrollIndicator = this.props.horizontal ? showsHorizontalScrollIndicator : showsVerticalScrollIndicator; | ||
var showsScrollIndicator = horizontal ? showsHorizontalScrollIndicator : showsVerticalScrollIndicator; | ||
@@ -259,3 +281,3 @@ if (isWeex) { | ||
}), | ||
refreshContainer, | ||
refreshContent, | ||
contentContainer | ||
@@ -292,4 +314,4 @@ ); | ||
} | ||
if (refreshContainer) { | ||
var childEle = (0, _rax.cloneElement)(refreshContainer); | ||
if (refreshContent) { | ||
var childEle = (0, _rax.cloneElement)(refreshContent); | ||
var childProps = childEle.props; | ||
@@ -323,6 +345,6 @@ return (0, _rax.createElement)( | ||
return ScrollViewTest; | ||
return ScrollView; | ||
}(_rax.Component); | ||
ScrollViewTest.defaultProps = { | ||
ScrollView.defaultProps = { | ||
scrollEventThrottle: DEFAULT_SCROLL_CALLBACK_THROTTLE, | ||
@@ -358,7 +380,7 @@ onEndReachedThreshold: DEFAULT_END_REACHED_THRESHOLD, | ||
var styles = { | ||
baseVertical: { | ||
vertical: { | ||
flex: 1, | ||
flexDirection: 'column' | ||
}, | ||
baseHorizontal: { | ||
horizontal: { | ||
flex: 1, | ||
@@ -375,3 +397,3 @@ flexDirection: 'row' | ||
exports.default = ScrollViewTest; | ||
exports.default = ScrollView; | ||
module.exports = exports['default']; |
@@ -140,3 +140,4 @@ 'use strict'; | ||
RefreshControl.displayName = 'RefreshControl'; | ||
exports.default = RefreshControl; | ||
module.exports = exports['default']; |
{ | ||
"name": "nuke-scroll-view", | ||
"version": "2.0.0", | ||
"version": "2.0.1", | ||
"description": "滚动组件", | ||
"main": "lib/index", | ||
"files": [ | ||
"lib", | ||
"docs", | ||
"theme", | ||
"README.md", | ||
"HISTORY.md" | ||
], | ||
"keywords": [ | ||
"nuke", | ||
"nuke-scroll-view" | ||
], | ||
"files": ["lib", "docs", "theme", "README.md", "HISTORY.md"], | ||
"keywords": ["nuke", "nuke-scroll-view"], | ||
"author": { | ||
@@ -18,0 +9,0 @@ "name": "leanhunter", |
36782
513