Set search params when popup movie & check for and read on load
This commit is contained in:
@@ -86,7 +86,12 @@
|
|||||||
<span :class="truncatedDescription ? 'truncated' : null">{{
|
<span :class="truncatedDescription ? 'truncated' : null">{{
|
||||||
movie.overview
|
movie.overview
|
||||||
}}</span>
|
}}</span>
|
||||||
<button class="truncate-toggle"><i>⬆</i></button>
|
<button
|
||||||
|
v-if="movie.overview && movie.overview.length > 220"
|
||||||
|
class="truncate-toggle"
|
||||||
|
>
|
||||||
|
<i>⬆</i>
|
||||||
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<div v-else class="movie__description">
|
<div v-else class="movie__description">
|
||||||
<loading-placeholder :count="5" />
|
<loading-placeholder :count="5" />
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import Movie from './Movie';
|
import Movie from "./Movie";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
props: {
|
props: {
|
||||||
@@ -26,27 +26,50 @@ export default {
|
|||||||
methods: {
|
methods: {
|
||||||
checkEventForEscapeKey(event) {
|
checkEventForEscapeKey(event) {
|
||||||
if (event.keyCode == 27) {
|
if (event.keyCode == 27) {
|
||||||
this.$popup.close()
|
this.$popup.close();
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
updateQueryParams(id = false) {
|
||||||
|
const params = new URLSearchParams(window.location.search);
|
||||||
|
if (params.has("movie")) {
|
||||||
|
params.delete("movie");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (id) {
|
||||||
|
params.append("movie", id);
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(params.toString());
|
||||||
|
|
||||||
|
window.history.replaceState(
|
||||||
|
{},
|
||||||
|
"search",
|
||||||
|
`${window.location.protocol}//${window.location.hostname}${
|
||||||
|
window.location.port ? `:${window.location.port}` : ""
|
||||||
|
}${window.location.pathname}${
|
||||||
|
params.toString().length ? `?${params}` : ""
|
||||||
|
}`
|
||||||
|
);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
created(){
|
created() {
|
||||||
window.addEventListener('keyup', this.checkEventForEscapeKey)
|
this.updateQueryParams(this.id);
|
||||||
document.getElementsByTagName("body")[0].classList += " no-scroll";
|
window.addEventListener("keyup", this.checkEventForEscapeKey);
|
||||||
|
document.getElementsByTagName("body")[0].classList.add("no-scroll");
|
||||||
},
|
},
|
||||||
beforeDestroy() {
|
beforeDestroy() {
|
||||||
window.removeEventListener('keyup', this.checkEventForEscapeKey)
|
this.updateQueryParams();
|
||||||
|
window.removeEventListener("keyup", this.checkEventForEscapeKey);
|
||||||
document.getElementsByTagName("body")[0].classList.remove("no-scroll");
|
document.getElementsByTagName("body")[0].classList.remove("no-scroll");
|
||||||
}
|
}
|
||||||
|
};
|
||||||
}
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss">
|
<style lang="scss">
|
||||||
@import "./src/scss/variables";
|
@import "./src/scss/variables";
|
||||||
@import "./src/scss/media-queries";
|
@import "./src/scss/media-queries";
|
||||||
|
|
||||||
.movie-popup{
|
.movie-popup {
|
||||||
position: fixed;
|
position: fixed;
|
||||||
top: 0;
|
top: 0;
|
||||||
left: 0;
|
left: 0;
|
||||||
@@ -56,19 +79,20 @@ export default {
|
|||||||
background: rgba($dark, 0.93);
|
background: rgba($dark, 0.93);
|
||||||
-webkit-overflow-scrolling: touch;
|
-webkit-overflow-scrolling: touch;
|
||||||
overflow: auto;
|
overflow: auto;
|
||||||
&__box{
|
&__box {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
height: 0;
|
||||||
max-width: 768px;
|
max-width: 768px;
|
||||||
position: relative;
|
position: relative;
|
||||||
z-index: 5;
|
z-index: 5;
|
||||||
background: $background-color-secondary;
|
background: var(--background-40);
|
||||||
padding-bottom: 50px;
|
padding-bottom: 50px;
|
||||||
@include tablet-min{
|
@include tablet-min {
|
||||||
padding-bottom: 0;
|
padding-bottom: 0;
|
||||||
margin: 40px auto;
|
margin: 40px auto;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
&__close{
|
&__close {
|
||||||
display: block;
|
display: block;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 0;
|
top: 0;
|
||||||
@@ -80,7 +104,7 @@ export default {
|
|||||||
transition: background 0.5s ease;
|
transition: background 0.5s ease;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
&:before,
|
&:before,
|
||||||
&:after{
|
&:after {
|
||||||
content: "";
|
content: "";
|
||||||
display: block;
|
display: block;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
@@ -90,13 +114,13 @@ export default {
|
|||||||
height: 2px;
|
height: 2px;
|
||||||
background: $white;
|
background: $white;
|
||||||
}
|
}
|
||||||
&:before{
|
&:before {
|
||||||
transform: rotate(45deg);
|
transform: rotate(45deg);
|
||||||
}
|
}
|
||||||
&:after{
|
&:after {
|
||||||
transform: rotate(-45deg);
|
transform: rotate(-45deg);
|
||||||
}
|
}
|
||||||
&:hover{
|
&:hover {
|
||||||
background: $green;
|
background: $green;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user