Comments (20)
This error appears if you didn't moving a mouse over a tilt element before, and you are scrolling a page and cursor is over the tilt element, and then leaves it, without moving of mouse. In this case the tilt effect doesn't work only on this element
from tilt.js.
Go to your file src/tilt.jquery.js
Check if this.mousePositions is null just like this.
if(this.mousePositions){
const percentageX = (this.mousePositions.x - left) / width;
const percentageY = (this.mousePositions.y - top) / height;
// x or y position inside instance / width of instance = percentage of position inside instance * the max tilt value
const tiltX = ((this.settings.maxTilt / 2) - ((percentageX) * this.settings.maxTilt)).toFixed(2);
const tiltY = (((percentageY) * this.settings.maxTilt) - (this.settings.maxTilt / 2)).toFixed(2);
// angle
const angle = Math.atan2(this.mousePositions.x - (left+width/2),- (this.mousePositions.y - (top+height/2)) )*(180/Math.PI);
// Return x & y tilt values
return {tiltX, tiltY, 'percentageX': percentageX * 100, 'percentageY': percentageY * 100, angle};
}
from tilt.js.
Well, I just disabled the X-axis. Tbh the change in effect isn't even much noticeable.
$('.someClass').tilt({
maxTilt: 10,
disableAxis: 'X', // What axis should be disabled. Can be X or Y.
});
from tilt.js.
No update into this? This bug still happens in JUL/2019!
from tilt.js.
Put the whole block in a try/catch:
try {
const percentageX = (this.mousePositions.x - left) / width;
const percentageY = (this.mousePositions.y - top) / height;
// x or y position inside instance / width of instance = percentage of position inside instance * the max tilt value
const tiltX = ((this.settings.maxTilt / 2) - ((percentageX) * this.settings.maxTilt)).toFixed(2);
const tiltY = (((percentageY) * this.settings.maxTilt) - (this.settings.maxTilt / 2)).toFixed(2);
// angle
const angle = Math.atan2(this.mousePositions.x - (left+width/2),- (this.mousePositions.y - (top+height/2)) )*(180/Math.PI);
// Return x & y tilt values
return {tiltX, tiltY, 'percentageX': percentageX * 100, 'percentageY': percentageY * 100, angle};
} catch(e){}
from tilt.js.
https://gyazo.com/16e39433f8684cf0bf75bad42207f70e
It only happens when you are scrolling for some reason.
from tilt.js.
I have the same issue.
from tilt.js.
Same here too
from tilt.js.
Please provide a demo showing this issue. Either by Codepen, jsfiddle, anything really.. :)
from tilt.js.
@vrockcm thanks but please read my previous reply. Thanks!
from tilt.js.
I tried to do it in jsfiddle but the error didn't pop up. Ill try codepen and see what happens tomorrow. π
from tilt.js.
https://codepen.io/anon/pen/oJoMRJ
Here you go.
from tilt.js.
I can't replicate the issue intentionally, but yes the issue happens to me. The error prevents the element that caused the tilt issue to no longer tilt. I even managed to somehow replicate the issue in the above codepen.
from tilt.js.
Any updates on the issue? I get the same error
from tilt.js.
I fix it by this way I hope it works
<div data-tilt-axis="x" ></div>
from tilt.js.
I get the same issue, when scrolling, if the mouse ends up over an element, it triggers an error blocking the script from re-running on that element even when the mouse starts moving again.
from tilt.js.
Go to your file src/tilt.jquery.js
Check if this.mousePositions is null just like this.if(this.mousePositions){
const percentageX = (this.mousePositions.x - left) / width; const percentageY = (this.mousePositions.y - top) / height; // x or y position inside instance / width of instance = percentage of position inside instance * the max tilt value const tiltX = ((this.settings.maxTilt / 2) - ((percentageX) * this.settings.maxTilt)).toFixed(2); const tiltY = (((percentageY) * this.settings.maxTilt) - (this.settings.maxTilt / 2)).toFixed(2); // angle const angle = Math.atan2(this.mousePositions.x - (left+width/2),- (this.mousePositions.y - (top+height/2)) )*(180/Math.PI); // Return x & y tilt values return {tiltX, tiltY, 'percentageX': percentageX * 100, 'percentageY': percentageY * 100, angle}; }
thank you so much, that solves this small issue!
from tilt.js.
Go to your file src/tilt.jquery.js
Check if this.mousePositions is null just like this.if(this.mousePositions){
const percentageX = (this.mousePositions.x - left) / width; const percentageY = (this.mousePositions.y - top) / height; // x or y position inside instance / width of instance = percentage of position inside instance * the max tilt value const tiltX = ((this.settings.maxTilt / 2) - ((percentageX) * this.settings.maxTilt)).toFixed(2); const tiltY = (((percentageY) * this.settings.maxTilt) - (this.settings.maxTilt / 2)).toFixed(2); // angle const angle = Math.atan2(this.mousePositions.x - (left+width/2),- (this.mousePositions.y - (top+height/2)) )*(180/Math.PI); // Return x & y tilt values return {tiltX, tiltY, 'percentageX': percentageX * 100, 'percentageY': percentageY * 100, angle}; }
Where should i put this code?
from tilt.js.
I have the same issue :(
from tilt.js.
@diabysidim thank you. Your solution is worked for me.
from tilt.js.
Related Issues (20)
- why paralax effect not work HOT 1
- Scrolling fast problem HOT 2
- Add effect to element from mouse over page HOT 4
- Lag in chrome based browsers for duration of the value of the speed option HOT 4
- transform: translateZ(20px) only activates when hover HOT 3
- Outzooming cause issue
- Targeting consecutive nested elements for parallax effect HOT 1
- Disable on Mobile HOT 1
- Does tilt work with images HOT 1
- Mouse events wrong on documentation
- Accessibility concerns?
- Glare on images/svgs?
- test
- SVG Inner Elements
- transform: translateZ(20px); is apply before hover HOT 2
- What does maxTilt option do?
- Add just a little tilt
- Tilt effect isn't working on mobile HOT 1
- I donβt see a tilt on mobile
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tilt.js.