更新 #1:根据下面的答案,在 MacBook Pro 上,这在 Safari 中有效但在 Chrome 中无效。
更新 #2:这个问题可以通过下面的 JSfiddle 和 Chrome 与 ReactJS 复现。然而,除非将 Chrome 放入开发工具移动设备模式并将其添加到 index.html,否则它永远不会在 Meteor(即 react-packages
Atmosphere 包)中起作用。
<meta name="viewport" content="initial-scale=1" />
在ReactJS应用程序中使用Semantic UI的无限滚动时,onBottomVisible()
没有被调用。当滚动到页面底部时,onBottomVisible
从未被调用。
我尝试将<div className="myfeed">
强制设置为height
,但这只会在加载时触发onBottomVisible()
回调,而不是滚动到底部时触发。
请参见以下代码和这些JSfiddle:
- ReactJS版本:http://jsfiddle.net/2wvfjpy9/9/
- 非React版本:https://jsfiddle.net/4p6d7x86/12/
CSS:
.myfeed {
height: 200px;
}
ReactJS / JavaScript:
var App = React.createClass({
componentDidMount: function() {
$('.myfeed').visibility({
once: false,
// update size when new content loads
observeChanges: true,
// load content on bottom edge visible
onBottomVisible: function() {
console.log("infiniateScroll ... called.");
alert("infiniateScroll ... called.");
}
});
},
render: function() {
var showFeedHTML = [];
for (var i=0; i < 20; i++) {
showFeedHTML[i] = (
<li key={ i }>
{ i }: stuff
</li>
);
}
return (
<div className="myfeed">
<h3>Semantic UI & ReactJS: Infinite Scroll Example</h3>
{ showFeedHTML }
</div>
);
}
});
React.render(<App />, document.getElementById('container'));
版本44.0.2403.130
。 - knowbody