vue模拟冒泡排序算法的可视化流程效果代码

代码语言:html

所属分类:动画

代码描述:vue模拟冒泡排序算法的可视化流程效果代码

代码标签: 排序 算法 可视化 流程 效果

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

<!DOCTYPE html>
<html lang="en" >
<head>
<meta charset="UTF-8">
<style>
    @import url("https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css");
*, *::before, *::after {
  box-sizing: border-box;
}

html {
  font: 700 16px/1 'Titillium Web', sans-serif;
}

body {
  margin: 40px 0;
  color: #fff;
  background-color: #000;
}

#app {
  width: 640px;
  margin: 0 auto;
}

.cards {
  position: relative;
  height: 400px;
}

.card-wrapper {
  position: absolute;
  bottom: 0;
  width: 6.25%;
  transition: -webkit-transform 200ms cubic-bezier(0.175, 0.885, 0.32, 1.275);
  transition: transform 200ms cubic-bezier(0.175, 0.885, 0.32, 1.275);
  transition: transform 200ms cubic-bezier(0.175, 0.885, 0.32, 1.275), -webkit-transform 200ms cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.card {
  position: relative;
  height: 100%;
  margin: 0 5px;
  border: 1px solid #ff3179;
  background-color: #000;
  box-shadow: 0 0 25px #c2255c;
}

.card-active {
  -webkit-filter: hue-rotate(200deg);
          filter: hue-rotate(200deg);
}

.card-locked {
  -webkit-filter: hue-rotate(280deg);
          filter: hue-rotate(280deg);
}

.value {
  position: absolute;
  bottom: 5px;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 1.25rem;
}

.control-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 30px 5px 0;
  padding-top: 20px;
  border-top: 1px solid #fff;
}

h1 {
  margin: 0;
  font-size: 2.5rem;
}

button {
  -webkit-appearance: none;
     -moz-appearance: none;
          appearance: none;
  background: none;
  border: none;
  color: #ff3179;
  font-size: 1.5rem;
  cursor: pointer;
}

@media only screen and (min-width: 880px) {
  #app {
    width: 800px;
  }

  .value {
    font-size: 1.5rem;
  }
}
@media only screen and (min-width: 1084px) {
  #app {
    width: 1024px;
  }

  .value {
    font-size: 1.75rem;
  }
}

</style>

</head>
<body>

<div id="app">
	<div class="cards">
		<sort-card v-for="(card, index) in store.state.cards" :key="index" :value="card.value" :sort-index="card.sortIndex" :is-active="card.isActive" :is-locked="card.isLocked"></sort-card>
	</div>
	<div class="control-panel">
		<h1>Bubble Sort Visualizer</h1>
		<button aria-label="Reset" v-if="store.state.done" @click="reset(SORT_ARRAY)">
			<i class="fa fa-refresh" aria-hidden="true"></i>
		</button>
	</div>
</div>

<script type="text/x-template" id="sort-card-template">

	<!-- 绑定内联样式,通过 height 和 transform 来显示不同的div -->
	<div class="card-wrapper" :data-sort-index="sortIndex" v-bind:style="{height: value * HEIGHT_INCREMENT + 'px',transform: 'translateX('+sortIndex*100+'%)'}">
	<!-- 通过改变class,来改变颜色 -->
	<div class="card" :class="cardClassObject">
	<div class="value">{{value}}</div>
	</div>
	</div>
  
</script>

<script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/vue@2.6.1.js".........完整代码请登录后点击上方下载按钮下载查看

网友评论0