DZone
Web Dev Zone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
  • Refcardz
  • Trend Reports
  • Webinars
  • Zones
  • |
    • Agile
    • AI
    • Big Data
    • Cloud
    • Database
    • DevOps
    • Integration
    • IoT
    • Java
    • Microservices
    • Open Source
    • Performance
    • Security
    • Web Dev
DZone > Web Dev Zone > How to Correct An Error of the Fotorama Module in Magento 2

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.

Max Lukyanenko user avatar by
Max Lukyanenko
·
Dec. 19, 16 · Web Dev Zone · Tutorial
Like (1)
Save
Tweet
6.02K Views

Join the DZone community and get the full member experience.

Join For Free

As 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;
}


Magento

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • Five Tips to Fasten Your Skewed Joins in Apache Spark
  • Top 7 Features in Jakarta EE 10 Release
  • How Java Apps Litter Beyond the Heap
  • Component Testing of Frontends: Karate Netty Project

Comments

Web Dev Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • MVB Program
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends:

DZone.com is powered by 

AnswerHub logo