Spot.js
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了Spot.js,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含2340字,纯文字阅读大概需要4分钟。
内容图文
![Spot.js](/upload/InfoBanner/zyjiaocheng/408/e3c3354096af4516927c36c1e3df1005.jpg)
spot.js
Track mouse position relative to elements in your website.With spot.js, you can:
- Add the CSS class "spot-shadow" to any element on a website to automatically create dynamic shadows relative to the mouse position.
- Add the CSS class "spot-rotate" to any element on a website to automatically rotate an element to face wherever the mouse is.
- Track mouse angle relative to an element's horizontal axis.
- Track mouse distance relative to an element's center.
- Have an easy time developing with on-screen helpers by adding the CSS class "spot-indicator" to any element on a website.
- Get creativewith mouse events using CSS transforms.
Live demos
Click here for a spot.js live demo
Installation
Add spot.jsto your HTML document with a script tag:
And voila! Now you can add the following classes to any element on your website to create different effects:
- spot-shadow: gives the element a dynamic drop-shadowfilter which changes on mouse move, to simulate a light coming from your mouse cursor. Uses filter: drop-shadow();
- spot-rotate: this CSS class rotatesthe element to face your mouse cursor and updates on mouse move. Uses transform: rotate;
- spot-indicator: this adds helpful debugging overlaysto the selected element. The info shown stands for distance between the mouse cursor and the element's center and the degree (related to the horizontal axis from the center of the element) at which your mouse cursor stands in every instant.
- spot-area: add this CSS class to any element to restrict where spot.jswill listen to mouse move events. If no element has been given this class, the entire window will listen to mouse move events.
Current development goals
- I'm planning to add many more effects to this library. Feel free to contribute with your own ideas.
- There are several performance issues that need to be tackled. This is mostly due to the nature of CSS filters but I guess I can also improve my throttling function and probably use requestAnimationFrame();or something. Suggestions are welcome.
- The shadow effect doesn't work well together with the rotation effect. They work great separately though.
License
See theLICENSE file for license rights and limitations (MIT).
Feel free to collaborate!
内容总结
以上是互联网集市为您收集整理的Spot.js全部内容,希望文章能够帮你解决Spot.js所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。