How to Correct An Error of the Fotorama Module in Magento 2
A code snippet on how to fix a Fotorama module bug when using the Magento 2 CMS.
Join the DZone community and get the full member experience.
Join For FreeAs you know, Magento 2 has a defect, which is present at 2.1.2. as well as in the previous versions. This is a problem related to vertical rolling of the product image on the product's details page. This is the mobile devices module — Fotorama.
When we try to scroll down the page while being at the image, we turn over it left or right. In order to get rid of such inconvenience we must correct the function onMove(e) inside the Fotorama library.
That file can be found here: MAGENTO_ROOT/lib/web/fotorama/fotorama.js
We should open it in editor, find the onMove(e) function (it is located on the line 1418), and change it with the new correction:
function onMove(e) {
if ((e.touches && e.touches.length > 1)
|| (MS_POINTER && !e.isPrimary)
|| moveEventType !== e.type
|| !touchEnabledFLAG) {
touchEnabledFLAG && onEnd();
(options.onTouchEnd || noop)();
return;
}
extendEvent(e);
var xDiff = Math.abs(e._x - startEvent._x), // opt _x → _pageX
yDiff = Math.abs(e._y - startEvent._y),
xyDiff = xDiff - yDiff,
xWin = (tail.go || tail.x || xyDiff >= 0) && !tail.noSwipe,
yWin = xyDiff < 0;
if (touchFLAG && !tail.checked) {
if (touchEnabledFLAG = xWin) {
stopEvent(e);
}
}
else {
stopEvent(e);
(options.onMove || noop).call(el, e, {touch: touchFLAG});
}
if (!moved && Math.sqrt(Math.pow(xDiff, 2) + Math.pow(yDiff, 2)) > tolerance) {
moved = true;
}
tail.checked = tail.checked || xWin || yWin;
}
Opinions expressed by DZone contributors are their own.
Trending
-
A Complete Guide to AWS File Handling and How It Is Revolutionizing Cloud Storage
-
The SPACE Framework for Developer Productivity
-
Implementing a Serverless DevOps Pipeline With AWS Lambda and CodePipeline
-
Top 10 Pillars of Zero Trust Networks
Comments