Giter Site home page Giter Site logo

Comments (13)

ChanceTheHacker avatar ChanceTheHacker commented on June 7, 2024 1

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.

JB1905 avatar JB1905 commented on June 7, 2024

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.

ChanceTheHacker avatar ChanceTheHacker commented on June 7, 2024

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.

scale-gif2

from universal-tilt.js.

ChanceTheHacker avatar ChanceTheHacker commented on June 7, 2024

and you can see here if I do not move my mouse, the scale works as intended.
scale-working

from universal-tilt.js.

ChanceTheHacker avatar ChanceTheHacker commented on June 7, 2024

and one more of it not working just for good measure.

scale-gif

from universal-tilt.js.

JB1905 avatar JB1905 commented on June 7, 2024

Thank You.
I need one more info - what values of the options you have set?

from universal-tilt.js.

ChanceTheHacker avatar ChanceTheHacker commented on June 7, 2024

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.

ChanceTheHacker avatar ChanceTheHacker commented on June 7, 2024

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.

scale-3

from universal-tilt.js.

JB1905 avatar JB1905 commented on June 7, 2024

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.

ChanceTheHacker avatar ChanceTheHacker commented on June 7, 2024

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.

ChanceTheHacker avatar ChanceTheHacker commented on June 7, 2024

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

rotate-bug

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.

JB1905 avatar JB1905 commented on June 7, 2024

I have 2 ideas to solve the problem:

  1. Block the onMouseMove() action until the transition animation completes.
  2. Set maximum speed value of the enter / exit animation time to reduce delay.

from universal-tilt.js.

ChanceTheHacker avatar ChanceTheHacker commented on June 7, 2024

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)

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.