nuke-scroll-view
Advanced tools
Comparing version 2.1.3 to 2.1.4
@@ -6,2 +6,14 @@ # Change Log | ||
<a name="2.1.4"></a> | ||
## [2.1.4](https://gitlab.alibaba-inc.com/nuke/scroll-view/compare/v2.1.3...v2.1.4) (2018-08-15) | ||
### Bug Fixes | ||
* eslint for import {isWeb} from nuke-env ([d856e2c](https://gitlab.alibaba-inc.com/nuke/scroll-view/commit/d856e2c)) | ||
<a name="2.1.3"></a> | ||
@@ -8,0 +20,0 @@ ## [2.1.3](https://gitlab.alibaba-inc.com/nuke/scroll-view/compare/v2.1.2...v2.1.3) (2018-08-15) |
@@ -64,3 +64,3 @@ { | ||
"defaultValue": { | ||
"value": "() => { }", | ||
"value": "() => {}", | ||
"computed": false | ||
@@ -67,0 +67,0 @@ }, |
@@ -5,3 +5,3 @@ 'use strict'; | ||
import { Component, createElement, findDOMNode, PropTypes } from 'rax'; | ||
import Env from 'nuke-env'; | ||
import { isWeex, isWeb } from 'nuke-env'; | ||
import View from 'nuke-view'; | ||
@@ -12,3 +12,2 @@ import RefreshControl from 'nuke-refresh-control'; | ||
const SCROLLVIEW_CLS = 'rax-scrollview'; | ||
const { isWeex, isWeb } = Env; | ||
@@ -44,6 +43,3 @@ const LOADMORE_THRESHOLD = 500; | ||
const now = new Date().getTime(); | ||
if ( | ||
this.lastScrollEventTriggerTime > 0 && | ||
now - this.lastScrollEventTriggerTime > 200 | ||
) { | ||
if (this.lastScrollEventTriggerTime > 0 && now - this.lastScrollEventTriggerTime > 200) { | ||
this.scrollStartFlag = false; | ||
@@ -56,9 +52,3 @@ clearTimeout(this.timer); | ||
handleScroll(e) { | ||
const { | ||
onScroll, | ||
onScrollStart, | ||
horizontal, | ||
onEndReached, | ||
onEndReachedThreshold, | ||
} = this.props; | ||
const { onScroll, onScrollStart, horizontal, onEndReached, onEndReachedThreshold } = this.props; | ||
if (isWeb) { | ||
@@ -89,21 +79,12 @@ if (!this.scrollStartFlag) { | ||
this.scrollerNodeSize = horizontal | ||
? this.scrollerNode.offsetWidth | ||
: this.scrollerNode.offsetHeight; | ||
this.scrollerNodeSize = horizontal ? this.scrollerNode.offsetWidth : this.scrollerNode.offsetHeight; | ||
} | ||
// NOTE:in iOS7/8 offsetHeight/Width is is inaccurate ( use scrollHeight/Width ) | ||
const scrollContentSize = horizontal | ||
? this.scrollerNode.scrollWidth | ||
: this.scrollerNode.scrollHeight; | ||
const scrollDistance = horizontal | ||
? this.scrollerNode.scrollLeft | ||
: this.scrollerNode.scrollTop; | ||
const isEndReached = | ||
scrollContentSize - scrollDistance - this.scrollerNodeSize < | ||
onEndReachedThreshold; | ||
const scrollContentSize = horizontal ? this.scrollerNode.scrollWidth : this.scrollerNode.scrollHeight; | ||
const scrollDistance = horizontal ? this.scrollerNode.scrollLeft : this.scrollerNode.scrollTop; | ||
const isEndReached = scrollContentSize - scrollDistance - this.scrollerNodeSize < onEndReachedThreshold; | ||
const isScrollToEnd = scrollDistance > this.lastScrollDistance; | ||
const isLoadedMoreContent = | ||
scrollContentSize !== this.lastScrollContentSize; | ||
const isLoadedMoreContent = scrollContentSize !== this.lastScrollContentSize; | ||
@@ -179,7 +160,5 @@ if (isEndReached && isScrollToEnd && isLoadedMoreContent) { | ||
if (horizontal) { | ||
findDOMNode(this.refs.scroller).scrollLeft = | ||
refDOM.offsetLeft + pixelRatio * offset; | ||
findDOMNode(this.refs.scroller).scrollLeft = refDOM.offsetLeft + pixelRatio * offset; | ||
} else { | ||
findDOMNode(this.refs.scroller).scrollTop = | ||
refDOM.offsetTop + pixelRatio * offset; | ||
findDOMNode(this.refs.scroller).scrollTop = refDOM.offsetTop + pixelRatio * offset; | ||
} | ||
@@ -244,11 +223,6 @@ // } | ||
if (typeof showScrollBar === 'undefined') { | ||
showScrollBar = horizontal | ||
? showsHorizontalScrollIndicator | ||
: showsVerticalScrollIndicator; | ||
showScrollBar = horizontal ? showsHorizontalScrollIndicator : showsVerticalScrollIndicator; | ||
} | ||
const contentContainerStyle = [ | ||
horizontal && styles.contentContainerHorizontal, | ||
this.props.contentContainerStyle, | ||
]; | ||
const contentContainerStyle = [horizontal && styles.contentContainerHorizontal, this.props.contentContainerStyle]; | ||
@@ -272,8 +246,3 @@ // bugfix: fix scrollview flex in ios 78 | ||
const scrollerStyle = Object.assign( | ||
{}, | ||
baseStyle, | ||
isWeb ? styles.scrollerWeb : {}, | ||
this.props.style | ||
); | ||
const scrollerStyle = Object.assign({}, baseStyle, isWeb ? styles.scrollerWeb : {}, this.props.style); | ||
@@ -417,3 +386,3 @@ if (isWeex) { | ||
onScrollEnd: null, | ||
onEndReached: () => { }, | ||
onEndReached: () => {}, | ||
scrollEventThrottle: ON_SCROLL_THROTTLE, | ||
@@ -420,0 +389,0 @@ onEndReachedThreshold: LOADMORE_THRESHOLD, |
{ | ||
"name": "nuke-scroll-view", | ||
"version": "2.1.3", | ||
"version": "2.1.4", | ||
"description": "滚动组件", | ||
@@ -43,5 +43,5 @@ "main": "lib/index", | ||
"nuke-env": "^2.1.3", | ||
"nuke-refresh-control": "^2.1.3", | ||
"nuke-refresh-control": "^2.1.4", | ||
"nuke-text": "^2.1.3", | ||
"nuke-view": "^2.1.3" | ||
"nuke-view": "^2.1.4" | ||
}, | ||
@@ -55,9 +55,9 @@ "devDependencies": { | ||
"eslint-plugin-react": "7.1.0", | ||
"nuke-button": "^2.1.3", | ||
"nuke-button": "^2.1.4", | ||
"nuke-dimensions": "^0.x.x", | ||
"nuke-iconfont": "^2.1.3", | ||
"nuke-input": "^2.1.3", | ||
"nuke-modal": "^2.1.3", | ||
"nuke-page": "^2.1.3", | ||
"nuke-tabbar": "^2.1.3", | ||
"nuke-input": "^2.1.4", | ||
"nuke-modal": "^2.1.4", | ||
"nuke-page": "^2.1.4", | ||
"nuke-tabbar": "^2.1.4", | ||
"nuke-text": "^2.1.0" | ||
@@ -69,3 +69,3 @@ }, | ||
"license": "Apache", | ||
"gitHead": "c5505fdafa2a561e741007ab32582394b5f028aa" | ||
"gitHead": "8b2a213253ed6cdf6d613a10bea387e80043fa6a" | ||
} |
@@ -5,3 +5,3 @@ 'use strict'; | ||
import { Component, createElement, findDOMNode, PropTypes } from 'rax'; | ||
import Env from 'nuke-env'; | ||
import { isWeex, isWeb } from 'nuke-env'; | ||
import View from 'nuke-view'; | ||
@@ -12,3 +12,2 @@ import RefreshControl from 'nuke-refresh-control'; | ||
const SCROLLVIEW_CLS = 'rax-scrollview'; | ||
const { isWeex, isWeb } = Env; | ||
@@ -44,6 +43,3 @@ const LOADMORE_THRESHOLD = 500; | ||
const now = new Date().getTime(); | ||
if ( | ||
this.lastScrollEventTriggerTime > 0 && | ||
now - this.lastScrollEventTriggerTime > 200 | ||
) { | ||
if (this.lastScrollEventTriggerTime > 0 && now - this.lastScrollEventTriggerTime > 200) { | ||
this.scrollStartFlag = false; | ||
@@ -56,9 +52,3 @@ clearTimeout(this.timer); | ||
handleScroll(e) { | ||
const { | ||
onScroll, | ||
onScrollStart, | ||
horizontal, | ||
onEndReached, | ||
onEndReachedThreshold, | ||
} = this.props; | ||
const { onScroll, onScrollStart, horizontal, onEndReached, onEndReachedThreshold } = this.props; | ||
if (isWeb) { | ||
@@ -89,21 +79,12 @@ if (!this.scrollStartFlag) { | ||
this.scrollerNodeSize = horizontal | ||
? this.scrollerNode.offsetWidth | ||
: this.scrollerNode.offsetHeight; | ||
this.scrollerNodeSize = horizontal ? this.scrollerNode.offsetWidth : this.scrollerNode.offsetHeight; | ||
} | ||
// NOTE:in iOS7/8 offsetHeight/Width is is inaccurate ( use scrollHeight/Width ) | ||
const scrollContentSize = horizontal | ||
? this.scrollerNode.scrollWidth | ||
: this.scrollerNode.scrollHeight; | ||
const scrollDistance = horizontal | ||
? this.scrollerNode.scrollLeft | ||
: this.scrollerNode.scrollTop; | ||
const isEndReached = | ||
scrollContentSize - scrollDistance - this.scrollerNodeSize < | ||
onEndReachedThreshold; | ||
const scrollContentSize = horizontal ? this.scrollerNode.scrollWidth : this.scrollerNode.scrollHeight; | ||
const scrollDistance = horizontal ? this.scrollerNode.scrollLeft : this.scrollerNode.scrollTop; | ||
const isEndReached = scrollContentSize - scrollDistance - this.scrollerNodeSize < onEndReachedThreshold; | ||
const isScrollToEnd = scrollDistance > this.lastScrollDistance; | ||
const isLoadedMoreContent = | ||
scrollContentSize !== this.lastScrollContentSize; | ||
const isLoadedMoreContent = scrollContentSize !== this.lastScrollContentSize; | ||
@@ -179,7 +160,5 @@ if (isEndReached && isScrollToEnd && isLoadedMoreContent) { | ||
if (horizontal) { | ||
findDOMNode(this.refs.scroller).scrollLeft = | ||
refDOM.offsetLeft + pixelRatio * offset; | ||
findDOMNode(this.refs.scroller).scrollLeft = refDOM.offsetLeft + pixelRatio * offset; | ||
} else { | ||
findDOMNode(this.refs.scroller).scrollTop = | ||
refDOM.offsetTop + pixelRatio * offset; | ||
findDOMNode(this.refs.scroller).scrollTop = refDOM.offsetTop + pixelRatio * offset; | ||
} | ||
@@ -244,11 +223,6 @@ // } | ||
if (typeof showScrollBar === 'undefined') { | ||
showScrollBar = horizontal | ||
? showsHorizontalScrollIndicator | ||
: showsVerticalScrollIndicator; | ||
showScrollBar = horizontal ? showsHorizontalScrollIndicator : showsVerticalScrollIndicator; | ||
} | ||
const contentContainerStyle = [ | ||
horizontal && styles.contentContainerHorizontal, | ||
this.props.contentContainerStyle, | ||
]; | ||
const contentContainerStyle = [horizontal && styles.contentContainerHorizontal, this.props.contentContainerStyle]; | ||
@@ -272,8 +246,3 @@ // bugfix: fix scrollview flex in ios 78 | ||
const scrollerStyle = Object.assign( | ||
{}, | ||
baseStyle, | ||
isWeb ? styles.scrollerWeb : {}, | ||
this.props.style | ||
); | ||
const scrollerStyle = Object.assign({}, baseStyle, isWeb ? styles.scrollerWeb : {}, this.props.style); | ||
@@ -417,3 +386,3 @@ if (isWeex) { | ||
onScrollEnd: null, | ||
onEndReached: () => { }, | ||
onEndReached: () => {}, | ||
scrollEventThrottle: ON_SCROLL_THROTTLE, | ||
@@ -420,0 +389,0 @@ onEndReachedThreshold: LOADMORE_THRESHOLD, |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
58666
964
Updatednuke-refresh-control@^2.1.4
Updatednuke-view@^2.1.4