This repository has been archived by the owner on May 24, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(marquee): Adds marquee effect to title if needed
- fixes #460
- Loading branch information
1 parent
84f04e9
commit 0e982a8
Showing
10 changed files
with
130 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { setStyles, hasOverflow, addClasses, removeClasses } from 'utils/dom' | ||
|
||
const marquee = el => { | ||
const scroller = el.firstChild | ||
|
||
setStyles({ | ||
'overflow-x': 'auto', | ||
'white-space': 'nowrap' | ||
})(scroller) | ||
|
||
setStyles({ | ||
height: `${el.offsetHeight}px` | ||
})(el) | ||
|
||
setStyles({ | ||
height: `${scroller.offsetHeight}px` | ||
})(scroller) | ||
|
||
if (hasOverflow(scroller)) { | ||
addClasses('marquee-container')(el) | ||
addClasses('marquee')(scroller) | ||
} else { | ||
removeClasses('marquee-container')(el) | ||
removeClasses('marquee')(scroller) | ||
} | ||
|
||
setStyles({ | ||
'overflow-x': 'visible' | ||
})(scroller) | ||
} | ||
|
||
export default { | ||
bind (el) { | ||
marquee(el) | ||
window.addEventListener('resize', () => marquee(el)) | ||
}, | ||
update: marquee | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
/* global MutationObserver */ | ||
|
||
export default { | ||
bind (el, { value }) { | ||
const observer = new MutationObserver(value) | ||
|
||
observer.observe(el, { childList: true }) | ||
window.addEventListener('resize', value) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
.marquee-container { | ||
overflow: hidden; | ||
position: relative; | ||
|
||
.marquee { | ||
position: absolute; | ||
width: 100%; | ||
height: 100%; | ||
margin: 0; | ||
text-align: left; | ||
|
||
/* Starting position */ | ||
transform: translateX(0%); | ||
|
||
/* Apply animation to this element */ | ||
animation: scroll 10s linear infinite; | ||
} | ||
|
||
/* 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% { | ||
opacity: 1; | ||
} | ||
90% { | ||
opacity: 0; | ||
transform: translateX(-110%); | ||
} | ||
100% { | ||
opacity: 0; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters