Travis build: 448
This commit is contained in:
@ -1862,8 +1862,9 @@ A hover effect where the gradient follows the mouse cursor.
|
|||||||
```js
|
```js
|
||||||
var btn = document.querySelector('.mouse-cursor-gradient-tracking')
|
var btn = document.querySelector('.mouse-cursor-gradient-tracking')
|
||||||
btn.onmousemove = function(e) {
|
btn.onmousemove = function(e) {
|
||||||
var x = e.pageX - btn.offsetLeft - btn.offsetParent.offsetLeft
|
var rect = e.target.getBoundingClientRect()
|
||||||
var y = e.pageY - btn.offsetTop - btn.offsetParent.offsetTop
|
var x = e.clientX - rect.left
|
||||||
|
var y = e.clientY - rect.top
|
||||||
btn.style.setProperty('--x', x + 'px')
|
btn.style.setProperty('--x', x + 'px')
|
||||||
btn.style.setProperty('--y', y + 'px')
|
btn.style.setProperty('--y', y + 'px')
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user