admin管理员组文章数量:1400681
I am trying to use framer-motion in a Next/React app, starting with some working examples. But it is a bit hard to see what is going on, in some cases and know how to access some pieces of information. For example in the following code:
docs.map(doc => (
<motion.div className="img-wrap" key={doc.id}
layout
whileHover={{opacity:1}}
onClick={() => setSelectedImg(doc.imageRefer)} >
<motion.img src={doc.imageRefer} alt="uploaded picture"
initial={{opacity:0}}
animate={{opacity:1}}
whileHover={{x:-100,y:-100}}
transition={{delay:1}} />
....
</motion.div>
))
The line : whileHover={{x:-100,y:-100}} is having the effect I want. But instead of having arbitrary values (-100), I would like to set values depending on the width and height of the image. And this the question:
How can I get the size (width & height) of the image provided in the src attribute of motion.img ?
本文标签: reactjsWorking with framermotiongetting the image sizeStack Overflow
版权声明:本文标题:reactjs - Working with framer-motion, getting the image size - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744244799a2596958.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论