Skip to content

Commit f22017e

Browse files
authored
Merge pull request #32 from tanthammar/2.x
Fix destroyed when element visibility changes
2 parents 23f00a2 + cbe8e75 commit f22017e

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

resources/views/components/turnstile.blade.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,20 @@
3434
}
3535
3636
$wire.on('reset-captcha', () => resetCaptcha())
37+
38+
const observer = new IntersectionObserver((entries) => {
39+
entries.forEach(entry => {
40+
if (entry.isIntersecting &&
41+
window.turnstile &&
42+
!$refs.turnstile.querySelector('.cf-turnstile')) {
43+
turnstile.render($refs.turnstile, options);
44+
}
45+
});
46+
}, { threshold: 0.1 })
47+
48+
if ($refs.turnstile) {
49+
observer.observe($refs.turnstile);
50+
}
3751
})()"
3852
>
3953
<div data-sitekey="{{config('turnstile.turnstile_site_key')}}"

0 commit comments

Comments
 (0)