mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-01-02 21:32:42 +00:00
Throttle brew move function
This commit is contained in:
@@ -43,8 +43,7 @@ const Editor = createClass({
|
|||||||
},
|
},
|
||||||
getInitialState : function() {
|
getInitialState : function() {
|
||||||
return {
|
return {
|
||||||
view : 'text', //'text', 'style', 'meta'
|
view : 'text' //'text', 'style', 'meta'
|
||||||
isBrewScrolling : false
|
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -198,20 +197,15 @@ const Editor = createClass({
|
|||||||
const bounceDelay = 100;
|
const bounceDelay = 100;
|
||||||
const scrollDelay = 500;
|
const scrollDelay = 500;
|
||||||
|
|
||||||
if(!this.state.isBrewScrolling) {
|
if(!this.throttleBrewMove) {
|
||||||
this.setState({
|
this.throttleBrewMove = _.throttle((currentPos, interimPos, targetPos)=>{
|
||||||
isBrewScrolling : true
|
brewRenderer.scrollTo({ top: currentPos + interimPos, behavior: 'smooth' });
|
||||||
});
|
setTimeout(()=>{
|
||||||
brewRenderer.scrollTo({ top: currentPos + interimPos, behavior: 'smooth' });
|
brewRenderer.scrollTo({ top: currentPos + targetPos, behavior: 'smooth', block: 'start' });
|
||||||
setTimeout(()=>{
|
}, bounceDelay);
|
||||||
brewRenderer.scrollTo({ top: currentPos + targetPos, behavior: 'smooth', block: 'start' });
|
}, scrollDelay, { leading: true });
|
||||||
}, bounceDelay);
|
};
|
||||||
setTimeout(()=>{
|
this.throttleBrewMove(currentPos, interimPos, targetPos);
|
||||||
this.setState({
|
|
||||||
isBrewScrolling : false
|
|
||||||
});
|
|
||||||
}, scrollDelay);
|
|
||||||
}
|
|
||||||
|
|
||||||
// const hashPage = (page != 1) ? `p${page}` : '';
|
// const hashPage = (page != 1) ? `p${page}` : '';
|
||||||
// window.location.hash = hashPage;
|
// window.location.hash = hashPage;
|
||||||
|
|||||||
Reference in New Issue
Block a user