|
99 | 99 | this.$overlay = $('#lightboxOverlay');
|
100 | 100 | this.$outerContainer = this.$lightbox.find('.lb-outerContainer');
|
101 | 101 | this.$container = this.$lightbox.find('.lb-container');
|
| 102 | + this.$nav = this.$lightbox.find('.lb-nav') |
102 | 103 |
|
103 | 104 | // Store css values for future lookup
|
104 | 105 | this.containerTopPadding = parseInt(this.$container.css('padding-top'), 10);
|
|
144 | 145 | return false;
|
145 | 146 | });
|
146 | 147 |
|
| 148 | + /* |
| 149 | + Show context menu for image on right-click |
| 150 | +
|
| 151 | + There is a div containing the navigation that spans the entire image and lives above of it. If |
| 152 | + you right-click, you are right clicking this div and not the image. This prevents users from |
| 153 | + saving the image or using other context menu actions with the image. |
| 154 | +
|
| 155 | + To fix this, when we detect the right mouse button is pressed down, but not yet clicked, we |
| 156 | + set pointer-events to none on the nav div. This is so that the upcoming right-click event on |
| 157 | + the next mouseup will bubble down to the image. Once the right-click/contextmenu event occurs |
| 158 | + we set the pointer events back to auto for the nav div so it can capture hover and left-click |
| 159 | + events as usual. |
| 160 | + */ |
| 161 | + this.$nav.on('mousedown', function(event) { |
| 162 | + if (event.which === 3) { |
| 163 | + self.$nav.css('pointer-events', 'none'); |
| 164 | + |
| 165 | + self.$lightbox.on('contextmenu', function() { |
| 166 | + setTimeout(function() { |
| 167 | + this.$nav.css('pointer-events', 'auto'); |
| 168 | + }.bind(self), 0) |
| 169 | + }); |
| 170 | + } |
| 171 | + }) |
| 172 | + |
| 173 | + |
147 | 174 | this.$lightbox.find('.lb-loader, .lb-close').on('click', function() {
|
148 | 175 | self.end();
|
149 | 176 | return false;
|
|
0 commit comments