gsap实现鼠标任意位置点击成群爬虫出现交互动画效果代码

代码语言:html

所属分类:动画

代码描述:gsap实现鼠标任意位置点击成群爬虫出现交互动画效果代码

代码标签: gsap 鼠标 任意 位置 点击 成群 爬虫 出现 交互 动画

下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开

<!DOCTYPE html>
<html lang="en" >

<head>
  <meta charset="UTF-8">
  

  
<style>
body {
  font: bold 100%/1 sans-serif;
}

.flex {
  align-items: center;
  display: flex;
  justify-content: center;
}

.scene {
  background-color: white;
  height: 100vh;
}

.canvas svg {
  position: absolute;
  width: 100vw;
  height: 100vh;
  top: 0;
  left: 0;
}
.canvas svg:hover {
  cursor: pointer;
}

p {
  -webkit-user-select: none;
     -moz-user-select: none;
      -ms-user-select: none;
          user-select: none;
  pointer-events: none;
}
</style>

  
</head>

<body >
  <section class="flex scene">
	<figure class="canvas">
		<svg viewBox="0 0 1600 900" role="presentational" />
	</figure>
	<p>
		Click anywhere
	</p>
</section>
<script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/gsap.3.9.1.js"></script>
      <script  >
(function(){
	const svg = document.querySelector("svg");
	const isAnimationOk = window.matchMedia('(prefers-reduced-motion: no-preference)').matches;
	const positions = [-250, -200, -175, -150, -125, -200, -75, -50, 50, 75, 125, 150, 175, 200, 250];
	const shapeCount = 14;
	let mouse = {
		x: window.innerWidth/2,
		y: window.innerHeight/2
	};

	setViewBox();
	
	svg.addEventListener("click", function(e) {
		setMouseCoords(e);
		animate();
	});
	
	window.addEventListener('resize', function(e) {
		setViewBox();
	});

	function setMouseCoords(event) {
		mouse.x = event.clientX;
		mouse.y = event.clientY;.........完整代码请登录后点击上方下载按钮下载查看

网友评论0