Show More
@@ -83,16 +83,21 b' PopupImageViewer.prototype.view = functi' | |||
|
83 | 83 | |
|
84 | 84 | var win_w = win.width(); |
|
85 | 85 | var win_h = win.height(); |
|
86 | //new image size | |
|
86 | ||
|
87 | // New image size | |
|
88 | var w_scale = 1; | |
|
89 | var h_scale = 1; | |
|
87 | 90 | if (img_w > win_w) { |
|
88 |
|
|
|
89 | img_w = win_w - margin; | |
|
91 | w_scale = img_w / (win_w - margin); | |
|
90 | 92 | } |
|
91 | 93 | if (img_h > win_h) { |
|
92 |
|
|
|
93 | img_h = win_h - margin; | |
|
94 | h_scale = img_h / (win_h - margin); | |
|
94 | 95 | } |
|
95 | 96 | |
|
97 | var scale = Math.max(w_scale, h_scale) | |
|
98 | img_w = img_w / scale; | |
|
99 | img_h = img_h / scale; | |
|
100 | ||
|
96 | 101 | var img_pv = new Image(); |
|
97 | 102 | var newImage = $(img_pv); |
|
98 | 103 | newImage.addClass('img-full') |
@@ -107,19 +112,22 b' PopupImageViewer.prototype.view = functi' | |||
|
107 | 112 | }) |
|
108 | 113 | //scaling preview |
|
109 | 114 | .mousewheel(function(event, delta) { |
|
110 |
var cx = event.originalEvent.clientX |
|
|
111 |
cy = event.originalEvent.clientY |
|
|
112 | i_w = parseFloat(newImage.width()), | |
|
113 |
|
|
|
114 | newIW = i_w * (delta > 0 ? 1.25 : 0.8), | |
|
115 | newIH = i_h * (delta > 0 ? 1.25 : 0.8); | |
|
115 | var cx = event.originalEvent.clientX; | |
|
116 | var cy = event.originalEvent.clientY; | |
|
117 | ||
|
118 | var i_w = parseFloat(newImage.width()); | |
|
119 | var i_h = parseFloat(newImage.height()); | |
|
120 | ||
|
121 | var newIW = i_w * (delta > 0 ? 1.25 : 0.8); | |
|
122 | var newIH = i_h * (delta > 0 ? 1.25 : 0.8); | |
|
116 | 123 | |
|
117 | 124 | newImage.width(newIW); |
|
118 | 125 | newImage.height(newIH); |
|
119 |
// |
|
|
126 | // Set position | |
|
127 | var oldPosition = newImage.position(); | |
|
120 | 128 | newImage.css({ |
|
121 |
left: parseInt(cx - (newIW/i_w) * (cx - parseInt( |
|
|
122 |
top: parseInt(cy - (newIH/i_h) * (cy - parseInt( |
|
|
129 | left: parseInt(cx - (newIW/i_w) * (cx - parseInt(oldPosition.left, 10)), 10), | |
|
130 | top: parseInt(cy - (newIH/i_h) * (cy - parseInt(oldPosition.top, 10)), 10) | |
|
123 | 131 | }); |
|
124 | 132 | |
|
125 | 133 | return false; |
General Comments 0
You need to be logged in to leave comments.
Login now