Comments (13)
no problem, and thank you as well. If you don't mind please share with me the fix once you find it so I can learn from the experience as well.
from universal-tilt.js.
I made the above changes and didn't notice any difference. I will wait for the screen recording, because it is possible that I don't notice this problem on my computer.
from universal-tilt.js.
here is attached gif, as you can see, the scale only occurs when my mouse accidentally slips out side the bounds for a moment, but when it's inside the bounds of the item and moving it does not scale.
from universal-tilt.js.
and you can see here if I do not move my mouse, the scale works as intended.
from universal-tilt.js.
and one more of it not working just for good measure.
from universal-tilt.js.
Thank You.
I need one more info - what values of the options you have set?
from universal-tilt.js.
here is the code. all 3 containers have the same issue.
<div id="card-container">
<ReactTilt
options={{
reverse: true,
scale: 1.1,
speed: 800,
easing: 'ease',
'disable-y': true,
shine: true,
'shine-opacity': .7
}} className="wl-card">
<img className="gift-img" src="http://www.qygjxz.com/data/out/92/5171375-gift-images.jpeg" alt=""/>
</ReactTilt>
<ReactTilt
options={{
reverse: true,
scale: 1.1,
speed: 500,
easing: 'ease',
'disable-y': true,
shine: true,
'shine-opacity': .7
}} className="wl-card">
</ReactTilt>
<ReactTilt
options={{
reverse: true,
scale: 1.1,
speed: 800,
easing: 'ease',
'disable-y': true,
shine: true,
'shine-opacity': .7
}} className="wl-card">
</ReactTilt>
from universal-tilt.js.
I made this last one to show you something though. This is the same bug happening with only scale: 1.3 and speed: 800.
for me the bug appears with any setting as long as I use scale. However, if you do not increase the speed to above 800, it is not noticeable because the transition is so quick. The higher that you set the speed option, the longer the scale take and the more noticeable it becomes. at only 300 ms it's hardly even detectable.
from universal-tilt.js.
I have recreated the error on my computer. The error wasn't visible with default easing option. I will look into the problem tomorrow.
Thanks!
from universal-tilt.js.
Here is what I did, I'm not sure if it is right but I hope it may help. Sadly I''m too much of a noob to even figure out how to test this myself with out importing the library via npm :(
onMouseMove(e) {
// set event
this.event = e;
this.updateElementPosition();
window.requestAnimationFrame(() => this.update("mouseMoveFunc")); <=== sends a string to update
if (typeof this.settings.onMouseMove === 'function')
this.settings.onMouseMove(this.element);
}
update(func) {
const values = this.getValues();
this.element.style.transform = `perspective(${this.settings.perspective}px)
rotateX(${
this.settings.disabled && this.settings.disabled.toUpperCase() === 'X'
? 0
: values.tiltY
}deg)
rotateY(${
this.settings.disabled && this.settings.disabled.toUpperCase() === 'Y'
? 0
: values.tiltX
}deg)`
//Check if this is being sent by the onMouseMove function or not
if (func !== 'mouseMoveFunc'){
this.element.style.transform =`scale3d(${this.settings.scale}, ${this.settings.scale}, ${
this.settings.scale
})`;}
from universal-tilt.js.
just an update, I did eventually start testing my code and It does not fix the issue. I did however discover while testing that it does not only effect scaling like I originally thought. This bug actually effects the rotate-x and rotate-y as well. Tried to fix it, but it's gotten late and it's time for bed for me. attached is a gif displaying the bug in action on rotate x and y
my settings
const elems = document.querySelectorAll('.tilt');
const universalTilt = new UniversalTilt(elems, {
scale: 1.1,
speed: 800,
easing: 'ease'
});
The change to the source code I made that did not work
{
key: "onMouseMove",
value: function onMouseMove(e) {
var _this2 = this;
// set event
this.event = e;
this.updateElementPosition();
window.requestAnimationFrame(function () {
return _this2.update('onMouseMoveFunc');
});
if (typeof this.settings.onMouseMove === 'function') this.settings.onMouseMove(this.element);
}
}
key: "update",
value: function update(func) {
if(func !== 'onMouseMoveFunc' ){
var values = this.getValues();
this.element.style.transform = "perspective(".concat(this.settings.perspective, "px)\n rotateX(").concat(this.settings.disabled && this.settings.disabled.toUpperCase() === 'X' ? 0 : values.tiltY, "deg)\n rotateY(").concat(this.settings.disabled && this.settings.disabled.toUpperCase() === 'Y' ? 0 : values.tiltX, "deg)\n scale3d(").concat(this.settings.scale, ", ").concat(this.settings.scale, ", ").concat(this.settings.scale, ")");
}else {var values = this.getValues();
this.element.style.transform = "perspective(".concat(this.settings.perspective, "px)\n rotateX(").concat(this.settings.disabled && this.settings.disabled.toUpperCase() === 'X' ? 0 : values.tiltY, "deg)\n rotateY(").concat(this.settings.disabled && this.settings.disabled.toUpperCase() === 'Y' ? 0 : values.tiltX, "deg)");
}
from universal-tilt.js.
I have 2 ideas to solve the problem:
- Block the onMouseMove() action until the transition animation completes.
- Set maximum speed value of the enter / exit animation time to reduce delay.
from universal-tilt.js.
Your 1st idea is something I had the intention of trying last night but ran out of time. Two things I did notice.
1)When I removed scale3d from the onmousemove it stopped working completely.
2) this (I think) was because the onmouseenter did not run the update function so I was thinking to maybe add only the scaling portion to on mouse enter and leave the on mouse move alone.
The only issue with this thought process was the additional bug I found last night where the rotate x and y values are also not working during the transition time too, and I believe that they should still be operational while scaling is happening
from universal-tilt.js.
Related Issues (20)
- Uncaught TypeError: UniversalTilt.init is not a function HOT 7
- 5 cents to nice plugin HOT 1
- Data exclude /(iPod|iPhone|iPad|Android)/ not working HOT 9
- Problem with base option HOT 3
- Add tilt effect with full page listening HOT 4
- works on desktop but not on mobile... HOT 7
- Invert tilt for parallax children
- Add shine over parallax children
- Disable tilt for parallax children
- Feature request: enhancements to base=window
- Adjust shadow color to tilt element color (clone?)
- Fix husky
- Export types
- Add alternatives
- Convert to monorepo
- Rewrite with TypeScript
- Update tests
- Clean up
- Mobile device flat on surface to get tilt position 0 HOT 1
- Allow interaction in gyroscope mode on touch devices. HOT 2
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 universal-tilt.js.