Created
November 11, 2021 22:19
-
-
Save ethanmay/40d1a88e1dd1e0ea72c1b4516a13ebae to your computer and use it in GitHub Desktop.
Simply include GSAP & the GSAP CSS Plugin, change myBtnSelector to a CSS selector of your choice, and enjoy.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const myBtnSelector = '.wp-block-button__link' | |
const initFancyButtons = () => { | |
$(myBtnSelector).prepend('<span class="circle"></span>') | |
$(myBtnSelector).each( function() { | |
const $circle = $(this).find('.circle') | |
$(this).on('mouseenter tap', function( evt ) { | |
const $target = $(this) | |
const x = evt.clientX - $target.offset().left | |
const y = evt.clientY - $target.offset().top | |
const tl = gsap.timeline() | |
tl.set( $circle, { | |
x: x, | |
y: y, | |
}) | |
tl.fromTo( $circle, { | |
background: '#F49301' | |
},{ | |
scale: $target.outerWidth() * 2, | |
background: '#ffffff', | |
duration: 0.65, | |
ease: 'none' | |
}).to( $circle, { | |
background: 'transparent', | |
delay: 0.15, | |
duration: 0.25, | |
ease: 'none' | |
}).set( $circle, { | |
scale: 1 | |
}) | |
}) | |
}) | |
} | |
initFancyButtons() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment