Vue3 useKeepAliveWindowScrollTop hook
import { onDeactivated, watch, onActivated } from 'vue'
import { useWindowScroll } from '@vueuse/core'
import { useState } from '@/hooks'
export default function () {
const { scrollTop, scrollLeft } = (function () {
const { x, y } = useWindowScroll()
return { scrollTop: y, scrollLeft: x }
})()
const [scrollTopCache, setScrollTopCache] = useState(0)
const [isScrollTopSet, setIsScrollTopSet] = useState(false)
watch(scrollTop, (value) => {
if (!isScrollTopSet.value) return
setScrollTopCache(value)
})
onActivated(() => {
window.scrollTo(scrollLeft.value ?? 0, scrollTopCache.value)
setIsScrollTopSet(true)
})
onDeactivated(() => {
setIsScrollTopSet(false)
})
}
Congratulations to Day 3's winners @ElySimpTq, @Wolfthedark15! Please send the required information to [email protected]. Retweet the original post each day and you might have a chance to win all the rewards!
#ArknightsCelebration #Arknights #Yostar
Arknights_EN: Dear Doctor, we're holding a giveaway event to celebrate Arknights' 1.5 anniversary. Retweet this post with your wish (words or images) for Arknights and 2 tags: #ArknightsCelebration #Arknights, and you will get a chance to win the following rewards!
#Yostar
Update
@use 'sass:math';
@mixin _flex-gap($gap, $row: true, $wrap: false) {
$margin: math.div($gap, 2);
$transform: calc(#{$margin} * -1);
$size: calc(100% + #{$margin} * 2);
@if $row {
margin-left: #{$transform};
width: #{$size};
} @else {
margin-top: #{$transform};
height: #{$size};
}
> * {
@if $row {
margin-left: $margin;
margin-right: $margin;
} @else {
margin-top: $margin;
margin-bottom: $margin;
}
}
}
@mixin flex-gap($gap, $flex-flow: 'row nowrap') {
@if $flex-flow== 'row nowrap' or $flex-flow== 'row-reverse nowrap' {
@include _flex-gap($gap, true);
} @else if $flex-flow== 'column nowrap' or $flex-flow== 'column-reverse nowrap' {
@include _flex-gap($gap, false);
} @else {
@include _flex-gap($gap, true, true);
@include _flex-gap($gap, false, true);
}
}
#明日方舟
【新增服饰】
//轻风 LB01 - 红
MARTHE [珊瑚海岸/CoralCoast]轻风系列泳衣首发01款。基于整体性考量设计的泳装冲锋衣套组,必定能满足您在水边的运动着衣需求。
_____________
狩猎水里的猎物需要些新装备,红正在尝试使用它们。
Flex gap mixins:
@use 'sass:math';
@mixin flex-gap($gap, $row: true, $reverse: false) {
$margin: math.div($gap, 2);
> * {
@if $row {
margin-left: $margin;
margin-right: $margin;
&:first-child {
@if $reverse {
margin-right: 0;
} @else {
margin-left: 0;
}
}
&:last-child {
@if $reverse {
margin-left: 0;
} @else {
margin-right: 0;
}
}
} @else {
margin-top: $margin;
margin-bottom: $margin;
&:first-child {
@if $reverse {
margin-bottom: 0;
} @else {
margin-top: 0;
}
}
&:last-child {
@if $reverse {
margin-top: 0;
} @else {
margin-bottom: 0;
}
}
}
}
}
一个postcss的网格系统插件:Lost Grid
今天在edge上发现flex box里面的gap没有生效,才注意到gap其实是grid布局的属性,只有部分浏览器支持flex gap。有一个PostCSS的polyfill(基于margin实现,本质上还是和真正的gap有一定差距): https://www.npmjs.com/package/flex-gap-polyfill
Chinese 🇨🇳 / Dictatorial Admin / Mastodon Code Contributor / 摸鱼技术布道师
Steam: https://steamcommunity.com/id/MashiroBest
Epic: https://store.epicgames.com/en-US/u/d211c824cbd94aaeba898db6bb823ff7
原批交流群:966322309