我一直在网站上工作,并试图从革命滑块复制多通的悬停效果。- https://revolution.themepunch.com/wordpress-duotone-effect-add-on/
我似乎想不出如何将悬停效应应用到我的测试现场。我想要相同的悬停效果从多通主滑块到我的测试站点主旗帜。- http://ittiz2.qadracreatives.com/
如有任何建议或帮助,将不胜感激。更大的力量
注:我不会使用滑块革命插件,但我只是“复制”的效果水平视差滚动。
实际上,我已经找到了一段代码,但是效果被破坏了,下面是我复制的代码: pastebin.com/raw/Jc9Apavi
发布于 2018-08-13 10:00:47
悬停效应可以通过以下步骤实现:
group-1、group-2和group-3。也可以将元素组织在同一个组中,并使用父div包装它们。以下步骤采用父div方法。(slider_width / 2, slider_height / 2)。您可以缓存中心位置。mouse over event绑定到幻灯片。对于每个鼠标超过事件,得到鼠标的位置,并计算其相对位置与幻灯片的位置比较。现在你得到鼠标在我们坐标系中的位置。transform向下移动父div)。如果鼠标位于中心下方,则将所有三组移动到更高的位置。左边和右边一样。例如,让我们尝试计算水平移动(垂直方向相同)://negative number means mouse is on the left, positive means it is on the right.
let mouseHorizontalDistance;
//you can adjust this to decide how far you wanna move the elements
let k = 1.3;
let baseMoveDistance = -(mouseHorizontalDistance) * k;
let horizontalTextGroupMoveDistance = baseMoveDistance + "px";
//in the demo, the near triangles move further than text
let horizontalNearTrianglesGroupMoveDistance = baseMoveDistance * 1.1 + "px";
//and the far triangles move even further.
let horizontalFarTriangleGroupMoveDistance = baseMoveDistance * 1.3 + "px";
document.querySelector('#textGroup').style.transform = translate(vertical, horizontalTextGroupMoveDistance);
//do the same for near and far triangles.https://stackoverflow.com/questions/51818927
复制相似问题