lmdd+vue实现可拖拽动态可编辑卡片效果代码

代码语言:html

所属分类:拖放

代码描述:lmdd+vue实现可拖拽动态可编辑卡片效果代码,点击加号可添加卡片,可编辑卡片文字和颜色、还可拖拽变换位置。

代码标签: lmdd vue 拖拽 动态 编辑 卡片

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

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

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

  
<link type="text/css" rel="stylesheet" href="//repo.bfw.wiki/bfwrepo/css/materialize.css">
<link rel='stylesheet' href='https://fonts.googleapis.com/icon?family=Material+Icons'>
<link type="text/css" rel="stylesheet" href="//repo.bfw.wiki/bfwrepo/css/lmdd.min.css">
  
<style>
html{
    overflow-y: scroll;
}
.palette{
  display:flex;
  flex-flow:row nowrap;
  width:100%;
  padding:15px;
}
.sub-color{
  transition: 0.2s;
/*   flex: 1 1 0px; */
}
.sub-color:hover{
  transform: rotateZ(5deg)
}
.color:hover .sub-color{
  flex: 1 1 auto;
  border:1px solid white;
}
.color{
  flex:1 1 auto;
  transition:0.3s;
  width:75px;
  height:75px;
/*   margin:15px; */
  display:flex;
  flex-flow:row nowrap;
}
.color:hover{
  width:100%;
}

.control{
  position:absolute;
  right:5px;
  top:5px;
  display:flex;
  flex-flow:row nowrap;
}
.control .btn-floating{
  margin:5px;
  opacity:0.6;
  width:24px;
  height:24px;
  line-height:24px;
  padding-top:2px;
}
.control .btn-floating i{
  position:absolute;
  font-size:20px;
  line-height:20px;
}
.control .btn-floating:hover{
  opacity:1;
  transform:rotate(-360deg);
}
.panel .btn-floating {
    width: 32px;
    height: 32px;
    line-height: 32px;
    padding:7px;
}
.panel .btn-floating i{
  position:absolute;  
  width: 18px;
    height: 18px;
    line-height: 18px;
  font-size:18px;
}
#example {
  padding:15px;
}

.panel {
  z-index: 1;
  transition: 0.3s;
  opacity: 0.75;
}

.panel .pulse {
  opacity: 0.5;
  transform:rotate(-360deg);
}

.panel .pulse:hover {
  opacity: 0.75;
}
/* .dragged > .card, .dragged > .card::before{
  transition:5s;
} */
.card {
  transition: transform 0.3s, opacity 0s;
}

.context > .card {
  transition:0.3s;
  transform: scale(1.1, 1.1);
}
.card::before{
  content:'';
  transform:translate3d(0px,0px,0px);
  transition:0.3s;
  opacity:0.5;
  display: block;
  position: absolute;
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;
  background-color: inherit;
  border-radius: inherit;
  z-index: -1;
}
.edit > .card {
  box-shadow: 5px 5px 3px 0px rgba(0,0,0,0.75);
  opacity:1 !important;
}
.mockup::before{
  content:'';
  display:block;
  transform:rotate(2deg);
  width:100%;
  height:100%;
  background-color:inherit;
  border-radius:inherit;
}
.mockup{
  opacity:0.4;
  transform:rotate(-1deg);
}
.mockup:hover{
  opacity:0.8; 
  transform:rotate(0deg);
}
.mockup-fab{
  position:absolute;
  opacity:1;
  top:-20px;
  right:10px;
}
.lmdd-block{
  box-sizing:border-box;
}
</style>

  
  
  
</head>

<body translate="no">
  <div id="example">
  <panel v-if="!dragEvent" @switch="editMode = !editMode" :edit="editMode"></panel>
  <div class="row" id="lmdd-scope">
    <div class="col s12 m3 lmdd-block">
      <div class="black card mockup">
        <div class="card-content white-text">
          <span class="card-title">Add new card</span>
          <p>This is a demonstration of HTML editing and building tools using Vue (for reactivity), Materialize (for CSS) and LMDD (for drag & drop)</p>
        </div>
        <div class="card-action">
          <a class="mockup-fab btn-floating waves-effect waves-light red" @click="addNewCard"><i class="material-icons">add</i></a>
          <a href="https://vuejs.org/" target="_blank">Vue</a><a href="http://materializecss.com/" target="_blank">Materialize</a><a href="" target="_blank">LMDD</a></div>
      </div>
    </div>
    <template v-for="(card,index) in cards">
    <card @context="apply" @removecard="removecard" :card="card" :index="index" :key="card"></card>
    </template>
  </div>
  <a class="waves-effect waves-light btn black" href="" target="_blank">More Examples...</a>

  <div id="colorpalette" class="modal bottom-sheet">
    <div class="palette">
      <div v-for="color in colors" class="color" :class="color">
        <div class="title"></div>
        <div v-for="variant in colorVariants" class="sub-color waves-effect waves-light" :class="[color,variant]" @click="updatecolor(color,variant)"></div>
      </div>
    </div>
  </div>
</div>
<script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/lmdd.min.js"></script>
<script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/vue@2.6.1-dev.js"></script>
<script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/jquery-3.2.1.min.js"></script>
<script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/materialize.js"></script>
      <script  >
$(document).ready(function () {
  $('.modal').modal();
});
var defaultTitle = "Card Title";
var defaultBody = "I am a very simple card. I am good at containing small bits of information, I am convenient because I require little markup to use effectively.";
var defaultLink = "#";
console.log(Vue);
Vue.component('editable', {
  template: '<span v-bind:contenteditable="state" @input="update"></span>',
  props: [&.........完整代码请登录后点击上方下载按钮下载查看

网友评论0