gp-designer 1.0.103 → 1.0.104

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,3 +1,5 @@
1
+
2
+
1
3
  $(function () {
2
4
  // 判断是否为移动端 (1200px 以下)
3
5
  if (window.innerWidth <= 1200) {
@@ -102,4 +104,3 @@ $(function () {
102
104
  }
103
105
  });
104
106
  });
105
-
@@ -0,0 +1,32 @@
1
+ import PhotoSwipe from '../photoswipe/photoswipe.esm.min.js';
2
+
3
+ $(function () {
4
+ // 获取所有的 gp-designer-image-preview 的 data-preview 属性的值
5
+ const previews = $('.gp-designer-image-preview').map(function () {
6
+ return $(this).data('preview');
7
+ }).get();
8
+ const dataSource = previews.map(c => {
9
+ return {
10
+ src: c,
11
+ width: 360,
12
+ height: 360
13
+ }
14
+ });
15
+ const options = { dataSource };
16
+
17
+ // 图片预览
18
+ $('.gp-designer-image-preview').on('click', function () {
19
+ if (!PhotoSwipe || previews.length === 0) {
20
+ return;
21
+ }
22
+ const preview = $(this).data('preview');
23
+ options.index = previews.indexOf(preview);
24
+ const pswp = new PhotoSwipe(options);
25
+ pswp.init();
26
+ });
27
+ });
28
+
29
+
30
+
31
+
32
+