Skip to content
This repository has been archived by the owner on May 24, 2021. It is now read-only.

chore(marquee): fixes scrollbar on small viewport #841

Merged
merged 1 commit into from
Nov 10, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
chore(marquee): fixes scrollbar on small viewport
  • Loading branch information
alexander-heimbuch committed Nov 10, 2018
commit 61b1a0c24b446b0596998160432cdfb859ce59b6
33 changes: 16 additions & 17 deletions src/core/directives/marquee.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ const marquee = el => {
const animationDuration = scroller.scrollWidth / 50

setStyles({
'white-space': 'nowrap'
'white-space': 'nowrap',
'overflow-x': 'hidden'
})(scroller)

setStyles({
Expand All @@ -18,25 +19,23 @@ const marquee = el => {
width: 'auto'
})(scroller)

setStyles({
'overflow': 'auto'
})(scroller)

if (scroller.scrollWidth > el.offsetWidth) {
addClasses('marquee-container')(el)
addClasses('marquee')(scroller)
setStyles({
'animation-duration': `${animationDuration > 10 ? animationDuration : 10}s`, // min 10s
width: `${scroller.scrollWidth}px`
})(scroller)
} else {
removeClasses('marquee-container')(el)
removeClasses('marquee')(scroller)
}

setStyles({
'overflow-x': 'visible'
})(scroller)

setTimeout(() => {
if (scroller.scrollWidth > el.offsetWidth) {
addClasses('marquee-container')(el)
addClasses('marquee')(scroller)
setStyles({
'animation-duration': `${animationDuration > 10 ? animationDuration : 10}s`, // min 10s
width: `${scroller.scrollWidth}px`
})(scroller)
} else {
removeClasses('marquee-container')(el)
removeClasses('marquee')(scroller)
}
}, 0)
}

export default {
Expand Down