I am struggling to get direction-aware hover and css transitions to work properly. Basically I am trying to have a grid of elements with a front and back face, and when on hover have a css transition to flip that element to show the back face.

我正在努力让方向感知悬停和css转换正常工作。基本上我正在尝试使用具有正面和背面的元素网格,并且当悬停时具有css过渡以翻转该元素以显示背面。

Transition example (without direction-aware): fiddle

转换示例(没有方向感知):小提琴

As you can see, no matter which way your mouse enters an element it always flips up. I want it to flip whichever way the mouse enters in/out.

正如您所看到的,无论您的鼠标以哪种方式进入元素,它总是会翻转。我想让它以鼠标进/出的方式翻转。

Example:

And here is my attempt with direction-aware: fiddle

这是我对方向感知的尝试:小提琴

I am using jQuery to add classes relevant to the mouse in/out direction.

我正在使用jQuery添加与鼠标进/出方向相关的类。

.hover-in-top {}
.hover-in-right {}
.hover-in-bottom {}
.hover-in-left {}

.hover-out-top {}
.hover-out-right {}
.hover-out-bottom {}
.hover-out-left {}

As you can see from the direction-aware example it kind of works but there are major glitches which I can't get my head round. (I've been overthinking this and my brain has just imploded.)

正如你从方向感知的例子中看到的那样它有点有用,但是有一些重大的故障我无法理解。 (我一直在思考这个,我的大脑刚刚崩溃。)

Anyway I hope this makes sense. Thanks.

无论如何,我希望这是有道理的。谢谢。

2 个解决方案

#1


1

I believe that the best way to approach the problem is not to use CSS transitions.

我认为解决问题的最佳方法是不使用CSS转换。

You can easily implement it using jQuery's animate, utilizing jQuery animations queue to keep all of your animations synced.

您可以使用jQuery的动画轻松实现它,利用jQuery动画队列来保持所有动画同步。

I modified your example to animate the transition in JavaScript.

我修改了您的示例以动画JavaScript中的过渡。

Code example

更多相关文章

  1. 动态左侧的GreenSock javascript动画
  2. 从屏幕外动画div,没有绝对位置?
  3. Linux职业发展方向
  4. 提供一个Android原生的Progress——SwipeToRefreshLayout下拉刷
  5. Android 5.X Activity过渡动画,以及漂亮的共享元素效果
  6. Android动画精讲一:从setTranslationX谈属性动画和view动画的区别
  7. [置顶] Animation之TranslateAnimation(平移动画)
  8. Android 属性动画(Property Animation)
  9. Android使用SVG矢量图打造酷炫动画效果

随机推荐

  1. 对ASP.NET中的MVC引擎开发插系统进行详解
  2. 浅析Asp.Net使用Image/ImageButton空间显
  3. C#如何实现自动更新本地程序的实例分析
  4. 代码分析:在.Net Core中使用ref和Span<T>
  5. C#中关于Timer定时器重入问题的解决方法
  6. ASP.NET如何实现进度条效果的实例讲解
  7. MongoDB在.Net中的使用方法详解
  8. 对MVC进行数据验证详解
  9. C#中关于foreach遍历使用的深入理解
  10. 完美解决SqlDataReader指定转换无效