Skip to content

Instantly share code, notes, and snippets.

@dbismut
Last active July 18, 2023 17:40
Show Gist options
  • Save dbismut/2ddf2de912e5d0cd02a16b2eff6c9263 to your computer and use it in GitHub Desktop.
Save dbismut/2ddf2de912e5d0cd02a16b2eff6c9263 to your computer and use it in GitHub Desktop.
// OPTION 1
// Close Icon managed by CTO, alert managed by CTO
TryOn.init({
events: {
close: () => {
window.modal.close(); // closes the popin embedding the CTO experience
}
}
});
// OPTION 2
// Close Icon managed by Parent, alert managed by CTO
TryOn.init({
events: {
status: (status) => {
switch(status) {
case "ar":
// icon.<method> are all pseudo functions to be implemented on the parent page side
icon.setFill('#fff');
icon.setShadow(true);
icon.show();
break;
case "search":
case "home":
icon.setFill('#000');
icon.setShadow(false);
break;
case "product":
icon.hide();
break;
}
}
}
});
const originalModalClose = window.modal.close
window.modal.close = () => {
try {
await TryOn.requestClose();
originalModalClose();
}
catch {}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment