Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 32 additions & 25 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -1,27 +1,34 @@
{
"version": "2.0.0",
"tasks": [
{
"type": "npm",
"script": "app:dev",
"problemMatcher": [],
"label": "App: Development server",
"detail": "nuxt dev"
},
{
"type": "npm",
"script": "app:build",
"group": "build",
"problemMatcher": [],
"label": "App: Build",
"detail": "nuxt build"
},
{
"type": "npm",
"script": "app:analyze",
"problemMatcher": [],
"label": "App: Analyze",
"detail": "nuxi analyze"
}
]
"version": "2.0.0",
"tasks": [
{
"type": "npm",
"script": "app:dev",
"problemMatcher": [],
"label": "App: Development server",
"detail": "nuxt dev"
},
{
"type": "npm",
"script": "app:build",
"group": "build",
"problemMatcher": [],
"label": "App: Build",
"detail": "nuxt build"
},
{
"type": "npm",
"script": "app:analyze",
"problemMatcher": [],
"label": "App: Analyze",
"detail": "nuxi analyze"
},
{
"type": "shell",
"command": "npx eslint --fix ${file}",
"problemMatcher": [],
"label": "lint current file",
"detail": "eslint --fix"
}
]
}
42 changes: 41 additions & 1 deletion components/content/prose-img.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,12 @@
:alt="alt"
format="webp"
lazy
tabindex="0"
class="post-content-image"
@click="showZoomPreview"
@focus="isFocused = true"
@blur="isFocused = false"
@keyup.space="handleSpaceKeyDown"
/>
</template>

Expand All @@ -26,7 +30,43 @@ const fullpath = computed(() => {
});

const showZoomPreview = () => {
isZoomFeatureEnabled && imageZoom.show("image", fullpath.value) ;
if (isZoomFeatureEnabled) {
imageZoom.show("image", fullpath.value);
isZoomed.value = true;
}
};

const hideZoomPreview = () => {
if (isZoomFeatureEnabled) {
imageZoom.hide();
isZoomed.value = false;
}
};

// opening img by space key
const isFocused = ref(false);
const isZoomed = ref(false);

const disableSpaceScroll = (event: KeyboardEvent) => {
if (event.code === "Space") {
event.preventDefault();
}
};

watch(isFocused, () => {
if (isFocused.value) {
document.addEventListener("keydown", disableSpaceScroll);
return;
}
document.removeEventListener("keydown", disableSpaceScroll);
});

const handleSpaceKeyDown = () => {
if (isZoomed.value) {
hideZoomPreview();
return;
}
showZoomPreview();
};
</script>

Expand Down
Loading