forked from jointakahe/takahe
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement image viewer (jointakahe#363)
- Loading branch information
Showing
5 changed files
with
80 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<script type="text/hyperscript"> | ||
def imageviewer.show(source) | ||
set source_url to (<img /> in source) @data-original-url | ||
set source_alt to (<img /> in source) @alt | ||
set image to <#image-viewer img /> | ||
set figcaption to <#image-viewer figcaption /> | ||
|
||
-- fill information | ||
set image@src to source_url | ||
set image@alt to source_alt | ||
set figcaption's textContent to source_alt | ||
|
||
-- show image viewer | ||
show #image-viewer with display:flex | ||
transition #image-viewer's opacity from 0 to 1 over 300ms | ||
focus() on first <#image-viewer button /> | ||
end | ||
def imageviewer.close() | ||
transition #image-viewer's opacity to 0 over 300ms | ||
hide #image-viewer | ||
set <#image-viewer img /> @src to '' | ||
set <#image-viewer img /> @alt to '' | ||
set <#image-viewer figcaption />'s textContent to '' | ||
end | ||
</script> | ||
<figure id="image-viewer" style="display: none" _="on click imageviewer.close()"> | ||
<picture> | ||
<img src="" alt=""/> | ||
</picture> | ||
<figcaption></figcaption> | ||
<button aria-label="Close"> | ||
<i class="fa fa-3x fa-times"></i> | ||
</button> | ||
</figure> |
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