diff --git a/addons/website/static/src/js/content/zoomodoo.js b/addons/website/static/src/js/content/zoomodoo.js index de4683a0dff..1e85e46062f 100644 --- a/addons/website/static/src/js/content/zoomodoo.js +++ b/addons/website/static/src/js/content/zoomodoo.js @@ -27,7 +27,7 @@ var defaults = { linkAttribute: 'data-zoom-image', // event to trigger zoom - event: 'click', //or mousenter + event: 'click', //or mouseenter // Prevent clicks on the zoom image link. preventClicks: true, @@ -83,7 +83,7 @@ ZoomOdoo.prototype._init = function () { } $attach.parent().on('mousemove.zoomodoo touchmove.zoomodoo', $.proxy(this._onMove, this)); $attach.parent().on('mouseleave.zoomodoo touchend.zoomodoo', $.proxy(this._onLeave, this)); - this.$target.parent().on(this.opts.event + '.zoomodoo touchstart.zoomodoo', $.proxy(this._onEnter, this)); + this.$target.on(this.opts.event + '.zoomodoo touchstart.zoomodoo', $.proxy(this._onEnter, this)); if (this.opts.preventClicks) { this.$target.on('click.zoomodoo', function (e) { e.preventDefault(); }); diff --git a/addons/website/static/src/less/website.zoomodoo.less b/addons/website/static/src/less/website.zoomodoo.less index da90921b1c2..3d855c96a96 100644 --- a/addons/website/static/src/less/website.zoomodoo.less +++ b/addons/website/static/src/less/website.zoomodoo.less @@ -17,19 +17,18 @@ z-index: 100; overflow: hidden; background: #FFF; + top: 0; + width: 100%; + height: 100%; + img { + max-width: 500%; + } } .zoomodoo-hover .zoomodoo-flyout { - top: 0; left: 0; - width: 100%; - height: 100%; } .zoomodoo-next .zoomodoo-flyout { - top: 0; left: 100%; - width: 100%; - height: 100%; - margin-left: 20px; } \ No newline at end of file diff --git a/addons/website_sale/static/src/js/website_sale.js b/addons/website_sale/static/src/js/website_sale.js index ddbcf60319d..8aacaf136ed 100644 --- a/addons/website_sale/static/src/js/website_sale.js +++ b/addons/website_sale/static/src/js/website_sale.js @@ -482,8 +482,24 @@ odoo.define('website_sale.website_sale', function (require) { } }); - // Deactivate image zoom for mobile devices, since it might prevent users to scroll + // Do not activate image zoom for mobile devices, since it might prevent users from scrolling the page if (!config.device.isMobile) { - $('.ecom-zoomable img[data-zoom]').zoomOdoo({ attach: '#o-carousel-product'}); + + var autoZoom = $('.ecom-zoomable').data('ecom-zoom-auto') || false, + factorZoom = parseFloat($('.ecom-zoomable').data('ecom-zoom-factor')) || 1.5, + attach = '#o-carousel-product'; + _.each($('.ecom-zoomable img[data-zoom]'), function (el) { + var $img = $(el); + $img.load(function(e) { + var el = e.currentTarget; + if (!_.str.endsWith(el.src, el.dataset.zoomImage) || // if zoom-img != img + el.naturalWidth >= $(attach).width() * factorZoom || el.naturalHeight >= $(attach).height() * factorZoom) { + $img.zoomOdoo({event: autoZoom ? 'mouseenter' : 'click', attach: attach}); + } + else { + $img.removeAttr('data-zoom'); // remove cursor + } + }); + }); } }); diff --git a/addons/website_sale/static/src/less/website_sale.less b/addons/website_sale/static/src/less/website_sale.less index 1a6119603f7..8de9cc6a492 100644 --- a/addons/website_sale/static/src/less/website_sale.less +++ b/addons/website_sale/static/src/less/website_sale.less @@ -782,12 +782,11 @@ a.no-decoration { } #o-carousel-product { - .carousel-inner div.item { + .carousel-inner div.item, .carousel-control { height: 400px; - - img { - max-height: 100%; - } + } + .carousel-inner div.item img { + max-height: 100%; } .carousel-control { @@ -829,8 +828,15 @@ a.no-decoration { } .ecom-zoomable { - img[data-zoom] { - cursor: zoom-in; + &:not(.ecom-autozoom) { + img[data-zoom] { + cursor: zoom-in; + } + } + &.ecom-autozoom { + img[data-zoom] { + cursor: crosshair; + } } .o_editable img[data-zoom] { cursor: pointer; diff --git a/addons/website_sale/views/templates.xml b/addons/website_sale/views/templates.xml index 6dfe832cf1f..52b15d8eb7e 100644 --- a/addons/website_sale/views/templates.xml +++ b/addons/website_sale/views/templates.xml @@ -420,7 +420,7 @@