Forum Discussion
Copy text from screen of published module?
Hey Phil,
The Script has to regularly poll the DOM and iterate over the SVG text elements.
It's not perfect, hence being a prototype, but it solves a problem I have.
var a11y = {
intervalId: null,
toUnlock: [],
pollForSVGTextElements: function() {
var textEls = document.querySelectorAll('svg g.vector-text-item');
a11y.toUnlock = [];
var textElParent = null;
textEls.forEach((textEl) => {
textElParent = textEl.parentElement;
if (textElParent.classList.contains('uneventable')) {
a11y.toUnlock.push(textElParent);
}
});
a11y.removeClass();
},
removeClass: function() {
a11y.toUnlock.forEach((lockedEl) => {
lockedEl.classList.remove('uneventable');
});
},
init: function() {
a11y.intervalId = setInterval(function() {
a11y.pollForSVGTextElements();
}, 1000);
}
}
a11y.init();
Thanks for sharing.
Related Content
- 9 months ago
- 21 days ago