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

Commit

Permalink
fix(title): Fixes scrolling issue in title when overflowing
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander-heimbuch committed Mar 2, 2018
1 parent 471b7b6 commit 052ceca
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
12 changes: 9 additions & 3 deletions src/core/directives/marquee.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import { setStyles, hasOverflow, addClasses, removeClasses } from 'utils/dom'
import { setStyles, addClasses, removeClasses } from 'utils/dom'

const marquee = el => {
const scroller = el.firstChild

const animationDuration = scroller.scrollWidth / 50

setStyles({
'overflow-x': 'auto',
'white-space': 'nowrap'
Expand All @@ -13,12 +15,16 @@ const marquee = el => {
})(el)

setStyles({
height: `${scroller.offsetHeight}px`
height: `${scroller.offsetHeight}px`,
width: `${scroller.scrollWidth}px`
})(scroller)

if (hasOverflow(scroller)) {
if (scroller.scrollWidth > el.offsetWidth) {
addClasses('marquee-container')(el)
addClasses('marquee')(scroller)
setStyles({
'animation-duration': `${animationDuration > 10 ? animationDuration : 10}s` // min 10s
})(scroller)
} else {
removeClasses('marquee-container')(el)
removeClasses('marquee')(scroller)
Expand Down
13 changes: 4 additions & 9 deletions src/styles/_marquee.scss
Original file line number Diff line number Diff line change
Expand Up @@ -19,24 +19,19 @@
/* Move it (define the animation) */
@keyframes scroll {
0% {
opacity: 1;
transform: translateX(0%); }
20% {
opacity: 1;
transform: translateX(0%); }
40% {
opacity: 1;
transform: translateX(0%);
}
80% {
20% {
opacity: 1;
transform: translateX(0%);
}
90% {
opacity: 0;
transform: translateX(-110%);
opacity: 1;
}
100% {
opacity: 0;
transform: translateX(-100%);
}
}
}

0 comments on commit 052ceca

Please sign in to comment.