diff --git a/src/components/collection/collection.scss b/src/components/collection/collection.scss index 817a02a..1fda799 100644 --- a/src/components/collection/collection.scss +++ b/src/components/collection/collection.scss @@ -24,6 +24,13 @@ width: 70%; } + .fixed { + position: fixed; + top: 0; + overflow-y: auto; + height: 100vh; + } + #buttons { border-radius: 5px; border-color: transparent; diff --git a/src/components/collection/index.js b/src/components/collection/index.js index f311088..26e56a9 100644 --- a/src/components/collection/index.js +++ b/src/components/collection/index.js @@ -14,13 +14,23 @@ export default class Home extends React.Component { @observable ext = false; @observable content = []; @observable card_img = API.card_back; + @observable menu_fixed = false; - componentDidMount() { + constructor() { + super(); let ext = localStorage.getItem("extended"); if (ext == null) this.ext = false; this.ext = (/true/i).test(ext); } + componentDidMount() { + window.addEventListener('scroll', this.handleScroll); + } + + componentWillUnmount() { + window.removeEventListener('scroll', this.handleScroll); + } + handleContent(content) { this.content = content; this.p = 1; @@ -36,12 +46,32 @@ export default class Home extends React.Component { localStorage.setItem("extended", this.ext); } + + + handleScroll = (event) => { + if (this.menu_fixed !== null) { + if (window.scrollY >= 220) { + if (!this.menu_fixed.classList.contains("fixed")) + { + this.menu_fixed.classList.add("fixed"); + // this.menu_fixed.className = "fixed"; + } + } + else if (this.menu_fixed.classList.contains("fixed")) { + // this.menu_fixed.className = ""; + this.menu_fixed.classList.remove("fixed"); + } + } + }; + render() { return (
- {if (n) this.changeImage = n.getInstance().changeImage}} /> - +
this.menu_fixed = ref}> + {if (n) this.changeImage = n.getInstance().changeImage}} /> + +
diff --git a/src/components/collection/search/index.js b/src/components/collection/search/index.js index 9373bd1..f2769a9 100644 --- a/src/components/collection/search/index.js +++ b/src/components/collection/search/index.js @@ -240,7 +240,6 @@ export default class SearchCollection extends React.Component {
-