question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Scale not transitioning smoothly while mouse moves.

See original GitHub issue

So the bug I am currently experiencing is that when I enter an object which has the scale option, it only scales in a smooth manner if I leave my mouse completely still as the transition occurs. If I continue to move my mouse as the transition is occurring, the scale will not occur at all, and then once the allotted time has passed (set by speed option) the animation jumps to completed, and the item grows to full size with no transition played at all. I will attempt to get a screencast gif later tonight when I am home from work.

I have forked the repository and had a peek at the code. I am currently at work so I do not have much time available to me but I believe I have found the issue. When I am home from work tonight, I will attempt to fix it if it is not fixed by you already by then. I am only a beginning coder though, so perhaps I will be unable to fix it.

anyways, what I believe is the issue is the combination of onMouseMove() and update() which updates scale 3d. I think if you continue to move the mouse fast enough, it just keeps updating the scale to the same size because onMouseMove() is constantly being called before the transition has enough time to take effect.

What I planned to do is move the scale portion into it’s own function called updateScale() and only call that on onMouseEnter and onMouseLeave.

  onMouseMove(e) {
    // set event
    this.event = e;
    this.updateElementPosition();


    window.requestAnimationFrame(() => this.update());   <======================

    if (typeof this.settings.onMouseMove === 'function')
      this.settings.onMouseMove(this.element);
  }

and

update() {
    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)
      scale3d(${this.settings.scale}, ${this.settings.scale}, ${     <=========
      this.settings.scale                                            <=========
    })`;

    if (this.settings.shine) {
      Object.assign(this.shineElement.style, {
        transform: `rotate(${values.angle}deg) translate3d(-50%, -50%, 0)`,
        opacity: `${this.settings['shine-opacity']}`
      });
    }

    // tilt position change event
    this.element.dispatchEvent(
      new CustomEvent('tiltChange', {
        detail: values
      })
    );
  }

Issue Analytics

  • State:open
  • Created 5 years ago
  • Comments:13 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
ChanceTheHackercommented, Aug 28, 2018

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.

0reactions
ChanceTheHackercommented, Aug 29, 2018

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

Read more comments on GitHub >

github_iconTop Results From Across the Web

Scale not transitioning smoothly while mouse moves. · Issue #6
So the bug I am currently experiencing is that when I enter an object which has the scale option, it only scales in...
Read more >
CSS hover effect does not move smoothly - Stack Overflow
As my title says, when I try to hover on my container, it instantly scales up instead of smoothly transitioning from its original...
Read more >
Scale on Hover with Transition - CSS-Tricks
I was stuck with smooth scaling for 2 hours – and here I found this ... 'fade' is not a CSS property so...
Read more >
Align monitors like a BOSS - avoid edges - tips and tricks.
Align monitors like a BOSS - avoid edges - smooth mouse movement - tips ... Keep mouse from bouncing up and down when...
Read more >
Smoothly Reverting CSS Animations - Pragmatic Pineapple
Figure out how to revert a CSS transition when hover is over. ... move our mouse away, it will revert smoothly using our...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found