Skip to content

Instantly share code, notes, and snippets.

@mmackh
Last active August 24, 2020 12:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mmackh/7839afd12051e159bdbd00910e6be879 to your computer and use it in GitHub Desktop.
Save mmackh/7839afd12051e159bdbd00910e6be879 to your computer and use it in GitHub Desktop.
  1. Created an iFrame on the product page with the content 'Loading...' to adjust the styling to fit the page
  2. Added iFrame to top of product page on Mobile, adjusted properties to collapsed & hidden on page load
  3. Added custom JS code that will check if: Mobile, Product Page URL contains appropriate model substring.
import wixWindow from 'wix-window';
import wixLocation from 'wix-location';

$w.onReady(function () {
	wixLocation.onChange( (location) => {
		updateArKitFrame();
	});
	updateArKitFrame();
});

function updateArKitFrame () {
	let iframe = $w('#html1');
	
	if(wixWindow.formFactor !== "Mobile") {
		return;
	} 
	
	let url = wixLocation.url;
	
	var model = null;
	if (url.indexOf('1855') !== -1) {
		model = '1855';
	}
	if (url.indexOf('libert') !== -1) {
		model = 'liberte';
	}
	if (url.indexOf('minerali') !== -1) {
		model = 'mineralite';
	}
	if (url.indexOf('decant') !== -1) {
		model = 'decanter';
	}
	if (url.indexOf('versati') !== -1) {
		model = 'versatile';
	}
	if (url.indexOf('water') !== -1) {
		model = 'water';
	}
	if (url.indexOf('carafe') !== -1) {
		model = 'carafe';
	}
	if (url.indexOf('champa') !== -1) {
		model = 'champagne';
	}
	if (url.indexOf('cru') !== -1) {
		model = 'cru';
	}

	if(model) {
		iframe.src = 'https://grasslglass.com/api/preview?model=' + model;
		iframe.show();
		iframe.expand();
	} else {
		iframe.hide();
		iframe.collapsed();
	}	
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment