Skip to content
Advertisement

Smooth blend/transition between images on mousemove

Recently I’ve approached a website where on mousemove the background is changing nicely, it is somehow connected with the mouse position. Please take a look here.

In fact there are only two images showing and there is a smooth transition between them. That is why I was trying to achieve the same with my own fiddle.

My html is here:

JavaScript

CSS:

JavaScript

and JS (taken from that website):

JavaScript

As you can imagine, my solution does not work. At the moment I’m getting an error: Uncaught TypeError: n.getElement is not a function

And IMHO it’s connected with defining the var o which is not present in my html (but when I’ve checked source of that website, the element from variable is not anyhow connected to that I’m trying to reproduce). How to achieve this effect?

my current jsfiddle is here: https://jsfiddle.net/kcpuz238/2/

Advertisement

Answer

The function getElement is from a jquery like library named mootools. Honestly, I have never heard of it before. I transpiled the code to plain js and attached below.

Working demo

JavaScript
JavaScript
JavaScript
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement