1const JumpLinkMixin = { 2 methods: { 3 setFocus(element) { 4 element.setAttribute('tabindex', '-1'); 5 element.focus(); 6 // Reason: https://axesslab.com/skip-links/#update-3-a-comment-from-gov-uk 7 element.removeAttribute('tabindex'); 8 }, 9 scrollToOffset(event) { 10 // Select element to scroll to 11 const ref = event.target.getAttribute('data-ref'); 12 const element = this.$refs[ref].$el; 13 14 // Set focus and tabindex on selected element 15 this.setFocus(element); 16 17 // Set scroll offset below header 18 const offset = element.offsetTop - 50; 19 window.scroll({ 20 top: offset, 21 behavior: 'smooth', 22 }); 23 }, 24 }, 25}; 26 27export default JumpLinkMixin; 28