@cornerstonejs/core
Version:
Cornerstone3D Core
33 lines (32 loc) • 1.13 kB
JavaScript
const MANAGED_PROPERTIES = [
{ name: 'touch-action', attribute: 'data-prior-touch-action' },
{ name: 'user-select', attribute: 'data-prior-user-select' },
{ name: '-webkit-user-select', attribute: 'data-prior-webkit-user-select' },
{
name: '-webkit-touch-callout',
attribute: 'data-prior-webkit-touch-callout',
},
];
export function setElementTouchActionNone(element) {
MANAGED_PROPERTIES.forEach(({ name, attribute }) => {
if (!element.hasAttribute(attribute)) {
element.setAttribute(attribute, element.style.getPropertyValue(name));
}
element.style.setProperty(name, 'none');
});
}
export function restoreElementTouchAction(element) {
MANAGED_PROPERTIES.forEach(({ name, attribute }) => {
if (!element.hasAttribute(attribute)) {
return;
}
const priorValue = element.getAttribute(attribute);
if (priorValue) {
element.style.setProperty(name, priorValue);
}
else {
element.style.removeProperty(name);
}
element.removeAttribute(attribute);
});
}