Giter Site home page Giter Site logo

Comments (20)

juli2a avatar juli2a commented on May 18, 2024 9

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.

diabysidim avatar diabysidim commented on May 18, 2024 9

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.

Hackinet avatar Hackinet commented on May 18, 2024 2

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.

batata004 avatar batata004 commented on May 18, 2024 2

No update into this? This bug still happens in JUL/2019!

from tilt.js.

jonathanarbely avatar jonathanarbely commented on May 18, 2024 2

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.

vrockcm avatar vrockcm commented on May 18, 2024 1

https://gyazo.com/16e39433f8684cf0bf75bad42207f70e
It only happens when you are scrolling for some reason.

e2d060a1fde9a330f06d730476332e1d

from tilt.js.

brograhamer avatar brograhamer commented on May 18, 2024

I have the same issue.

from tilt.js.

bumper-yusuf-ozunlu avatar bumper-yusuf-ozunlu commented on May 18, 2024

Same here too

from tilt.js.

gijsroge avatar gijsroge commented on May 18, 2024

Please provide a demo showing this issue. Either by Codepen, jsfiddle, anything really.. :)

from tilt.js.

gijsroge avatar gijsroge commented on May 18, 2024

@vrockcm thanks but please read my previous reply. Thanks!

from tilt.js.

vrockcm avatar vrockcm commented on May 18, 2024

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.

vrockcm avatar vrockcm commented on May 18, 2024

https://codepen.io/anon/pen/oJoMRJ
Here you go.

from tilt.js.

LachieKimber avatar LachieKimber commented on May 18, 2024

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.

stilltli avatar stilltli commented on May 18, 2024

Any updates on the issue? I get the same error

from tilt.js.

PowerMostafa avatar PowerMostafa commented on May 18, 2024

I fix it by this way I hope it works
<div data-tilt-axis="x" ></div>

from tilt.js.

toddpadwick avatar toddpadwick commented on May 18, 2024

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.

MaksymJ avatar MaksymJ commented on May 18, 2024

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.

ali-vs avatar ali-vs commented on May 18, 2024

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.

bmrafiq avatar bmrafiq commented on May 18, 2024

I have the same issue :(

from tilt.js.

bmrafiq avatar bmrafiq commented on May 18, 2024

@diabysidim thank you. Your solution is worked for me.

from tilt.js.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.