Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 64c9a31

Browse files
committed
图片 zoom
1 parent 911fdab commit 64c9a31

File tree

5 files changed

+64
-3
lines changed

5 files changed

+64
-3
lines changed

static/css/zoom.css

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
img[data-action="zoom"] {
2+
cursor: pointer;
3+
cursor: -webkit-zoom-in;
4+
cursor: -moz-zoom-in;
5+
}
6+
.zoom-img,
7+
.zoom-img-wrap {
8+
position: relative;
9+
z-index: 666;
10+
-webkit-transition: all 300ms;
11+
-o-transition: all 300ms;
12+
transition: all 300ms;
13+
}
14+
img.zoom-img {
15+
cursor: pointer;
16+
cursor: -webkit-zoom-out;
17+
cursor: -moz-zoom-out;
18+
}
19+
.zoom-overlay {
20+
z-index: 420;
21+
background: #fff;
22+
position: fixed;
23+
top: 0;
24+
left: 0;
25+
right: 0;
26+
bottom: 0;
27+
pointer-events: none;
28+
filter: "alpha(opacity=0)";
29+
opacity: 0;
30+
-webkit-transition: opacity 300ms;
31+
-o-transition: opacity 300ms;
32+
transition: opacity 300ms;
33+
}
34+
.zoom-overlay-open .zoom-overlay {
35+
filter: "alpha(opacity=100)";
36+
opacity: 1;
37+
}
38+
.zoom-overlay-open,
39+
.zoom-overlay-transitioning {
40+
cursor: default;
41+
}

static/js/comment.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,12 @@
160160
var url = $(this).attr('href');
161161
$(this).attr('target', '_blank');
162162
});
163+
164+
$('.comment-list .markdown img').attr('data-action', 'zoom');
165+
166+
$('.comment-list .markdown img').on('click', function() {
167+
$(this).parents('.box_white').css('overflow', 'visible');
168+
});
163169
}
164170
$('.comment-list .words').removeClass('hide');
165171

static/js/common.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -459,8 +459,12 @@ jQuery(document).ready(function($) {
459459

460460
// 图片响应式
461461
setTimeout(function(){
462-
$('.page .content img').addClass('img-responsive');
463-
}, 2000);
462+
$('.page .content img').addClass('img-responsive').attr('data-action', 'zoom');
463+
464+
$('.page .content img').on('click', function() {
465+
$(this).parents('.box_white').css('overflow', 'visible');
466+
});
467+
}, 1000);
464468

465469
// 表格响应式
466470
setTimeout(function() {

static/js/libs/zoom.min.js

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

template/common/layout.html

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
<!--<link href="http://netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap-glyphicons.css" rel="stylesheet">-->
1818
<link rel="stylesheet" href="//cdn.bootcss.com/font-awesome/4.7.0/css/font-awesome.min.css">
1919
<link href="/static/css/main.css?v=1.4" rel="stylesheet"/>
20+
<link href="/static/css/zoom.css" rel="stylesheet"/>
2021
{{template "css" .}}
2122
<style type="text/css">
2223
#bottom .nav-content {
@@ -252,6 +253,7 @@
252253
<script type="text/javascript" src="/static/js/libs/bootstrap-3.2.0.min.js"></script>
253254
<script src="/static/js/libs/jquery.timeago.js?v=1.5.4"></script>
254255
<script src="/static/js/libs/jquery.timeago.zh-CN.js?v=1.5.4"></script>
256+
<script src="/static/js/libs/zoom.min.js"></script>
255257
<script src="/static/js/libs/md5.js"></script>
256258
<script type="text/javascript">
257259
var uid = {{.me.Uid}};
@@ -264,7 +266,7 @@
264266
}
265267
var GLaunchTime = {{timestamp .app.LaunchTime}}*1000;
266268
</script>
267-
<script src="/static/js/common.js?v=1.2"></script>
269+
<script src="/static/js/common.js?v=1.7"></script>
268270
<script src="//cdn.bootcss.com/lscache/1.1.0/lscache.min.js"></script>
269271
<script type="text/javascript" src="/static/js/libs/paste-upload-image.js"></script>
270272
{{template "js" .}}

0 commit comments

Comments
 (0)