Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
scroll(offset){
const element = this.list;
const width = element.offsetWidth;
const scrollWidth = element.scrollWidth;
const toScroll = scrollWidth - width;
const futurePosition = this.state.currentScroll + offset;
const offSetToMin = 0 + futurePosition;
const offSetToMax = toScroll - futurePosition;
// case where we are going to be resetting scroll, which does it as well if there are only 100px left or less
if(futurePosition <= 0 || offSetToMin <= 100){
animateScrollTo(0, {minDuration: 500, element, horizontal: true});
this.setState({currentScroll: 0, isBeginning: true})
}
// case where we are going to be scrolling to the end, which does it as well if there are only 100px left or less
else if(futurePosition >= toScroll || offSetToMax <= 100){
animateScrollTo(toScroll, {minDuration: 500, element, horizontal: true});
this.setState({currentScroll: toScroll, isEnd: true})
}
// case where we have not reached an endge
else{
animateScrollTo(futurePosition, {minDuration: 500, element, horizontal: true});
this.setState({currentScroll: futurePosition, isBeginning: false, isEnd: false})
}
}
const offSetToMin = 0 + futurePosition;
const offSetToMax = toScroll - futurePosition;
// case where we are going to be resetting scroll, which does it as well if there are only 100px left or less
if(futurePosition <= 0 || offSetToMin <= 100){
animateScrollTo(0, {minDuration: 500, element, horizontal: true});
this.setState({currentScroll: 0, isBeginning: true})
}
// case where we are going to be scrolling to the end, which does it as well if there are only 100px left or less
else if(futurePosition >= toScroll || offSetToMax <= 100){
animateScrollTo(toScroll, {minDuration: 500, element, horizontal: true});
this.setState({currentScroll: toScroll, isEnd: true})
}
// case where we have not reached an endge
else{
animateScrollTo(futurePosition, {minDuration: 500, element, horizontal: true});
this.setState({currentScroll: futurePosition, isBeginning: false, isEnd: false})
}
}
const element = this.list;
const width = element.offsetWidth;
const scrollWidth = element.scrollWidth;
const toScroll = scrollWidth - width;
const futurePosition = this.state.currentScroll + offset;
const offSetToMin = 0 + futurePosition;
const offSetToMax = toScroll - futurePosition;
// case where we are going to be resetting scroll, which does it as well if there are only 100px left or less
if(futurePosition <= 0 || offSetToMin <= 100){
animateScrollTo(0, {minDuration: 500, element, horizontal: true});
this.setState({currentScroll: 0, isBeginning: true})
}
// case where we are going to be scrolling to the end, which does it as well if there are only 100px left or less
else if(futurePosition >= toScroll || offSetToMax <= 100){
animateScrollTo(toScroll, {minDuration: 500, element, horizontal: true});
this.setState({currentScroll: toScroll, isEnd: true})
}
// case where we have not reached an endge
else{
animateScrollTo(futurePosition, {minDuration: 500, element, horizontal: true});
this.setState({currentScroll: futurePosition, isBeginning: false, isEnd: false})
}
}
scrollToEvents() {
const el = this.el
animateScrollTo(0, {
minDuration: 750,
horizontal: false,
offset: el.offsetTop
})
}
scrollToIndustries() {
const el = this.el
animateScrollTo(0, {
minDuration: 750,
horizontal: false,
offset: el.offsetTop - 250
})
}
setInterval(() => {
animateScrollTo(9999999, {
minDuration: duration,
element: containerNode
})
setTimeout(() => {
animateScrollTo(0, {
minDuration: duration,
element: containerNode
})
}, duration)
}, duration)
}
let nextUrl = prevBaseUrl;
let paramsString = '';
if (paramsObject) {
paramsString = queryString.stringify(paramsObject);
}
nextUrl += `${paramsString ? '?' : ''}${paramsString}`;
if (replace) {
window.history.pushState(null, '', nextUrl);
}
animateScrollTo(0);
return nextUrl;
};
scrollToBottom() {
this.isScrollingToBottom = true;
animateScrollTo(this.$refs.window.scrollHeight, {
speed: 250,
element: this.$refs.window,
onComplete: () => {
this.isScrollingToBottom = false;
this.updateIsScrolledToBottom();
},
});
},
},